1919#include <linux/list.h>
2020#include <linux/wait.h>
2121#include <linux/module.h>
22- #include <linux/rwsem.h>
2322#include <asm/uaccess.h>
2423#include <linux/seq_file.h>
2524#include <linux/debugfs.h>
@@ -60,7 +59,6 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
6059#define GLOCK_BUG_ON (gl ,x ) do { if (unlikely(x)) { __dump_glock(NULL, gl); BUG(); } } while(0)
6160static void do_xmote (struct gfs2_glock * gl , struct gfs2_holder * gh , unsigned int target );
6261
63- static DECLARE_RWSEM (gfs2_umount_flush_sem );
6462static struct dentry * gfs2_root ;
6563static struct workqueue_struct * glock_workqueue ;
6664struct workqueue_struct * gfs2_delete_workqueue ;
@@ -154,12 +152,14 @@ static unsigned int gl_hash(const struct gfs2_sbd *sdp,
154152static void glock_free (struct gfs2_glock * gl )
155153{
156154 struct gfs2_sbd * sdp = gl -> gl_sbd ;
157- struct inode * aspace = gl -> gl_aspace ;
155+ struct address_space * mapping = gfs2_glock2aspace (gl );
156+ struct kmem_cache * cachep = gfs2_glock_cachep ;
158157
159- if (aspace )
160- gfs2_aspace_put (aspace );
158+ GLOCK_BUG_ON (gl , mapping && mapping -> nrpages );
161159 trace_gfs2_glock_put (gl );
162- sdp -> sd_lockstruct .ls_ops -> lm_put_lock (gfs2_glock_cachep , gl );
160+ if (mapping )
161+ cachep = gfs2_glock_aspace_cachep ;
162+ sdp -> sd_lockstruct .ls_ops -> lm_put_lock (cachep , gl );
163163}
164164
165165/**
@@ -712,7 +712,6 @@ static void glock_work_func(struct work_struct *work)
712712 finish_xmote (gl , gl -> gl_reply );
713713 drop_ref = 1 ;
714714 }
715- down_read (& gfs2_umount_flush_sem );
716715 spin_lock (& gl -> gl_spin );
717716 if (test_and_clear_bit (GLF_PENDING_DEMOTE , & gl -> gl_flags ) &&
718717 gl -> gl_state != LM_ST_UNLOCKED &&
@@ -725,7 +724,6 @@ static void glock_work_func(struct work_struct *work)
725724 }
726725 run_queue (gl , 0 );
727726 spin_unlock (& gl -> gl_spin );
728- up_read (& gfs2_umount_flush_sem );
729727 if (!delay ||
730728 queue_delayed_work (glock_workqueue , & gl -> gl_work , delay ) == 0 )
731729 gfs2_glock_put (gl );
@@ -750,10 +748,11 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
750748 const struct gfs2_glock_operations * glops , int create ,
751749 struct gfs2_glock * * glp )
752750{
751+ struct super_block * s = sdp -> sd_vfs ;
753752 struct lm_lockname name = { .ln_number = number , .ln_type = glops -> go_type };
754753 struct gfs2_glock * gl , * tmp ;
755754 unsigned int hash = gl_hash (sdp , & name );
756- int error ;
755+ struct address_space * mapping ;
757756
758757 read_lock (gl_lock_addr (hash ));
759758 gl = search_bucket (hash , sdp , & name );
@@ -765,7 +764,10 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
765764 if (!create )
766765 return - ENOENT ;
767766
768- gl = kmem_cache_alloc (gfs2_glock_cachep , GFP_KERNEL );
767+ if (glops -> go_flags & GLOF_ASPACE )
768+ gl = kmem_cache_alloc (gfs2_glock_aspace_cachep , GFP_KERNEL );
769+ else
770+ gl = kmem_cache_alloc (gfs2_glock_cachep , GFP_KERNEL );
769771 if (!gl )
770772 return - ENOMEM ;
771773
@@ -784,18 +786,18 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
784786 gl -> gl_tchange = jiffies ;
785787 gl -> gl_object = NULL ;
786788 gl -> gl_sbd = sdp ;
787- gl -> gl_aspace = NULL ;
788789 INIT_DELAYED_WORK (& gl -> gl_work , glock_work_func );
789790 INIT_WORK (& gl -> gl_delete , delete_work_func );
790791
791- /* If this glock protects actual on-disk data or metadata blocks,
792- create a VFS inode to manage the pages/buffers holding them. */
793- if (glops == & gfs2_inode_glops || glops == & gfs2_rgrp_glops ) {
794- gl -> gl_aspace = gfs2_aspace_get (sdp );
795- if (!gl -> gl_aspace ) {
796- error = - ENOMEM ;
797- goto fail ;
798- }
792+ mapping = gfs2_glock2aspace (gl );
793+ if (mapping ) {
794+ mapping -> a_ops = & gfs2_meta_aops ;
795+ mapping -> host = s -> s_bdev -> bd_inode ;
796+ mapping -> flags = 0 ;
797+ mapping_set_gfp_mask (mapping , GFP_NOFS );
798+ mapping -> assoc_mapping = NULL ;
799+ mapping -> backing_dev_info = s -> s_bdi ;
800+ mapping -> writeback_index = 0 ;
799801 }
800802
801803 write_lock (gl_lock_addr (hash ));
@@ -812,10 +814,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
812814 * glp = gl ;
813815
814816 return 0 ;
815-
816- fail :
817- kmem_cache_free (gfs2_glock_cachep , gl );
818- return error ;
819817}
820818
821819/**
@@ -1510,35 +1508,10 @@ void gfs2_glock_thaw(struct gfs2_sbd *sdp)
15101508
15111509void gfs2_gl_hash_clear (struct gfs2_sbd * sdp )
15121510{
1513- unsigned long t ;
15141511 unsigned int x ;
1515- int cont ;
15161512
1517- t = jiffies ;
1518-
1519- for (;;) {
1520- cont = 0 ;
1521- for (x = 0 ; x < GFS2_GL_HASH_SIZE ; x ++ ) {
1522- if (examine_bucket (clear_glock , sdp , x ))
1523- cont = 1 ;
1524- }
1525-
1526- if (!cont )
1527- break ;
1528-
1529- if (time_after_eq (jiffies ,
1530- t + gfs2_tune_get (sdp , gt_stall_secs ) * HZ )) {
1531- fs_warn (sdp , "Unmount seems to be stalled. "
1532- "Dumping lock state...\n" );
1533- gfs2_dump_lockstate (sdp );
1534- t = jiffies ;
1535- }
1536-
1537- down_write (& gfs2_umount_flush_sem );
1538- invalidate_inodes (sdp -> sd_vfs );
1539- up_write (& gfs2_umount_flush_sem );
1540- msleep (10 );
1541- }
1513+ for (x = 0 ; x < GFS2_GL_HASH_SIZE ; x ++ )
1514+ examine_bucket (clear_glock , sdp , x );
15421515 flush_workqueue (glock_workqueue );
15431516 wait_event (sdp -> sd_glock_wait , atomic_read (& sdp -> sd_glock_disposal ) == 0 );
15441517 gfs2_dump_lockstate (sdp );
@@ -1685,7 +1658,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
16851658 dtime *= 1000000 /HZ ; /* demote time in uSec */
16861659 if (!test_bit (GLF_DEMOTE , & gl -> gl_flags ))
16871660 dtime = 0 ;
1688- gfs2_print_dbg (seq , "G: s:%s n:%u/%llu f:%s t:%s d:%s/%llu a:%d r:%d\n" ,
1661+ gfs2_print_dbg (seq , "G: s:%s n:%u/%llx f:%s t:%s d:%s/%llu a:%d r:%d\n" ,
16891662 state2str (gl -> gl_state ),
16901663 gl -> gl_name .ln_type ,
16911664 (unsigned long long )gl -> gl_name .ln_number ,
0 commit comments