cluster/gfs-kernel/src/gfs inode.h ops_export.c
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: wcheng at sourceware.org 2007-01-16 20:39:03
Modified files:
gfs-kernel/src/gfs: inode.h ops_export.c
Log message:
Bugzilla 190475 (rename 3-1)
Yank get inode logic out of gfs_get_dentry() (currently only used by NFS file serving). This will allow gfs_rename (patch 3-3) to re-use (share) this logic to update its stale inode contents.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs-kernel/src/gfs/inode.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs-kernel/src/gfs/ops_export.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.2&r2=1.3.2.3
gfs-kernel/src/gfs/inode.h +2 -0
@@ -53,6 +53,8 @@int gfs_alloc_qinode (struct gfs_sbd *sdp);int gfs_alloc_linode (struct gfs_sbd *sdp); +struct inode *gfs_refresh_iobj (struct gfs_sbd *sdp,void *inum_obj,int *n); +/* Inlines */ static __inline__ int
gfs-kernel/src/gfs/ops_export.c +79 -44
184 lines not on this page · raw message
Hi,
Just wondering why this:
On Tue, 2007-01-16 at 20:39 +0000, wcheng at sourceware.org wrote:
[snip]
Quoted 51 lines
gfs-kernel/src/gfs/ops_export.c +13
-19@@ -280,62 +280,57 @@ }/** -* gfs_get_dentry - -* @param1: description -* @param2: description -* @param3: description +* gfs_refresh_iobj - +* @sdp: pointer to struct gfs_sbd +* @inum: pointer to struct gfs_inum +* @refresh: set to true if inode refreshed +* return: pointer to struct inode or errno * -* Function description +* This function was part of gfs_get_dentry where it +* - allocated a gfs_inode "ip" +* - disk-read in "ip" +* - allocated a vfs inode for this "ip". * -* Returns: what is returned +* We yank it out to allow gfs_rename() to re-use +* this logic. */ -struct dentry * -gfs_get_dentry (struct super_block *sb,void *inump) +struct inode *gfs_refresh_iobj (struct gfs_sbd *sdp,void *inum_obj,int *miss) { -struct gfs_sbd *sdp =vfs2sdp (sb); -struct inode_cookie *cookie = (struct inode_cookie *)inump; -struct gfs_inum inum;struct gfs_holder i_gh, ri_gh, rgd_gh;struct gfs_rgrpd *rgd;struct buffer_head *bh;struct gfs_dinode *di;struct gfs_inode *ip;struct inode *inode; -struct dentry *dentry; +struct gfs_inum *inum = (struct gfs_inum *) inum_obj;int error; -atomic_inc (&sdp->sd_ops_export); - -if (!cookie->formal_ino || - cookie->formal_ino == sdp->sd_jiinode->i_num.no_formal_ino || - cookie->formal_ino == sdp->sd_riinode->i_num.no_formal_ino || - cookie->formal_ino == sdp->sd_qinode->i_num.no_formal_ino || - cookie->formal_ino == sdp->sd_linode->i_num.no_formal_ino)
gfs-kernel/src/gfs/ops_export.c line 312
Quoted 10 lines
gfs-kernel/src/gfs/ops_export.c +1
-6-return ERR_PTR (-EINVAL ); - - inum.no_formal_ino = cookie->formal_ino; - inum.no_addr = cookie->formal_ino; - error =gfs_glock_nq_num (sdp, - inum.no_formal_ino, &gfs_inode_glops, + inum->no_formal_ino, &gfs_inode_glops,LM_ST_SHARED ,LM_FLAG_ANY |GL_LOCAL_EXCL , &i_gh);
needs the GL_LOCAL_EXCL flag. I would have thought an ordinary shared lock would be enough?
In GFS2 I'd like to try and eliminate this flag since it would be just as easy to use a combination of a mutex or rwsem and a glock to achieve the same thing and it makes the glock code simpler. Its only used in about three places anyway and I'm not so sure that its required at all in this case,
Steve.
Quoted 6 lines · Steven Whitehouse
Hi,
Just wondering why this:
On Tue, 2007-01-16 at 20:39 +0000, wcheng at sourceware.org wrote:
[snip]
Quoted 10 lines
gfs-kernel/src/gfs/ops_export.c line 312
Quoted 7 lines
gfs-kernel/src/gfs/ops_export.c +1
-2- error =gfs_glock_nq_num (sdp, - inum.no_formal_ino, &gfs_inode_glops, + inum->no_formal_ino, &gfs_inode_glops,LM_ST_SHARED ,LM_FLAG_ANY |GL_LOCAL_EXCL , &i_gh);needs the
GL_LOCAL_EXCLflag. I would have thought an ordinary shared lock would be enough?
It is required to prevent (by serializing) other process (on the same node) to create this gfs inode at the same time (equivalence of an semaphore or mutex). Lookup (and several other GFS1 mount/umount) code needs this flag too. This (my guess) is to reduce the need to create another set of semaphores/mutex. In summary, I think it has two advantages:
1. Less locks
2. Easier to track who owns what (since glock holder is easy to find when compared with sempahore/mutex).
The down-side is that it makes glock code difficult to understand. For GFS1, let's keep it this way. For GFS2, your call :) ...
-- Wendy
Quoted 10 lines
In GFS2 I'd like to try and eliminate this flag since it would be just as easy to use a combination of a mutex or rwsem and a glock to achieve the same thing and it makes the glock code simpler. Its only used in about three places anyway and I'm not so sure that its required at all in this case,
Steve.
Hi,
Quoted 17 lines · Wendy Cheng
Quoted 6 lines · Steven Whitehouse
Hi,
Just wondering why this:
On Tue, 2007-01-16 at 20:39 +0000, wcheng at sourceware.org wrote:
[snip]Quoted 10 lines
gfs-kernel/src/gfs/ops_export.c line 312
Quoted 7 lines
gfs-kernel/src/gfs/ops_export.c +1
-2- error =gfs_glock_nq_num (sdp, - inum.no_formal_ino, &gfs_inode_glops, + inum->no_formal_ino, &gfs_inode_glops,LM_ST_SHARED ,LM_FLAG_ANY |GL_LOCAL_EXCL , &i_gh);needs the
GL_LOCAL_EXCLflag. I would have thought an ordinary shared lock would be enough?
Quoted 9 lines
It is required to prevent (by serializing) other process (on the same node) to create this gfs inode at the same time (equivalence of an semaphore or mutex). Lookup (and several other GFS1 mount/umount) code needs this flag too. This (my guess) is to reduce the need to create another set of semaphores/mutex. In summary, I think it has two advantages:
1. Less locks
2. Easier to track who owns what (since glock holder is easy to find when compared with sempahore/mutex).
Ah, that kind of makes sense then for gfs1.
Quoted 3 lines
The down-side is that it makes glock code difficult to understand. For GFS1, let's keep it this way. For GFS2, your call :) ...
Yes, I don't want to go changing things like that in GFS1 at all :-) In GFS2 we use the inode cache as its supposed to be used and that deals with all the required local serialisation, so it looks to be redundant in that case.
Also in more recent kernels, lockdep deals with your point #2 above, so I can't see anything really standing in the way of swapping the few remaining cases for a mutex or rwsem and glock combination.
In fact one of the reason for doing this is to work towards the possibility of using lockdep with glocks. Lockdep has no concept of "local" and "remote" but it does have the concept of nested locks so its one step closer to being able to make use of that,
Steve.
Hi,
Here is a proposed patch for GFS2 to remove the local exclusive flag. In the other places it was used, mutex's are always held earlier in the call path, so it appears redundant.
Also, the GFS2 holders were setting local exclusive in any case where the requested lock was LM_ST_EXCLUSIVE. So the other places in the glock code where the flag was tested have been replaced with tests for the lock state being LM_ST_EXCLUSIVE in order to ensure the logic is the same as before.
Steve.
fs/gfs2/glock.c +3 -13
@@ -396,10 +396,6 @@ void gfs2_holder_init(struct gfs2_glock gh->gh_error =0 ; gh->gh_iflags =0 ;init_completion (&gh->gh_wait); - -if (gh->gh_state ==LM_ST_EXCLUSIVE ) - gh->gh_flags |=GL_LOCAL_EXCL ; -gfs2_glock_hold (gl); }
@@ -417,9 +413,6 @@ void gfs2_holder_reinit(unsigned int sta { gh->gh_state = state; gh->gh_flags = flags; -if (gh->gh_state ==LM_ST_EXCLUSIVE ) - gh->gh_flags |=GL_LOCAL_EXCL ; - gh->gh_iflags &=1 <<HIF_ALLOCED ; gh->gh_ip = (unsigned long )__builtin_return_address (0 ); }
@@ -537,11 +530,11 @@ static int rq_promote(struct gfs2_holderset_bit (GLF_LOCK , &gl->gl_flags); }else {struct gfs2_holder *next_gh; -if (gh->gh_flags &GL_LOCAL_EXCL ) +if (gh->gh_state ==LM_ST_EXCLUSIVE )return 1 ; next_gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list); -if (next_gh->gh_flags &GL_LOCAL_EXCL ) +if (next_gh->gh_state ==LM_ST_EXCLUSIVE )return 1 ; }
@@ -1470,10 +1463,7 @@ static int glock_compare(const void *argreturn 1 ;if (a->ln_number < b->ln_number)return -1 ; -if (gh_a->gh_state ==LM_ST_SHARED && gh_b->gh_state ==LM_ST_EXCLUSIVE ) -return 1 ; -if (!(gh_a->gh_flags &GL_LOCAL_EXCL ) && (gh_b->gh_flags &GL_LOCAL_EXCL )) -return 1 ; +BUG_ON (gh_a->gh_gl->gl_ops->go_type == gh_b->gh_gl->gl_ops->go_type);return 0 ; }
fs/gfs2/glock.h +0 -1
@@ -20,7 +20,6 @@ #define LM_FLAG_NOEXP 0x00000004#define LM_FLAG_ANY 0x00000008 #define LM_FLAG_PRIORITY 0x00000010 */ -#define GL_LOCAL_EXCL 0x00000020#define GL_ASYNC 0x00000040#define GL_EXACT 0x00000080#define GL_SKIP 0x00000100
fs/gfs2/glops.c +1 -1
@@ -295,7 +295,7 @@ static int inode_go_lock(struct gfs2_holif ((ip->i_di.di_flags &GFS2_DIF_TRUNC_IN_PROG ) && (gl->gl_state ==LM_ST_EXCLUSIVE ) && - (gh->gh_flags &GL_LOCAL_EXCL )) + (gh->gh_state ==LM_ST_EXCLUSIVE )) error =gfs2_truncatei_resume (ip);return error;
fs/gfs2/ops_export.c +1 -2
@@ -217,8 +217,7 @@ static struct dentry *gfs2_get_dentry(st } error =gfs2_glock_nq_num (sdp, inum->no_addr, &gfs2_inode_glops, -LM_ST_SHARED ,LM_FLAG_ANY |GL_LOCAL_EXCL , - &i_gh); +LM_ST_SHARED ,LM_FLAG_ANY , &i_gh);if (error)return ERR_PTR (error);
fs/gfs2/super.c +4 -7
@@ -359,8 +359,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdmutex_lock (&sdp->sd_jindex_mutex);for (;;) { - error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED , -GL_LOCAL_EXCL , ji_gh); + error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED ,0 , ji_gh);if (error)break ;
@@ -529,8 +528,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdpstruct gfs2_log_header_host head;int error; - error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED , -GL_LOCAL_EXCL , &t_gh); + error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED ,0 , &t_gh);if (error)return error;
@@ -583,9 +581,8 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdpgfs2_quota_sync (sdp);gfs2_statfs_sync (sdp); - error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED , -GL_LOCAL_EXCL |GL_NOCACHE , - &t_gh); + error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED ,GL_NOCACHE , + &t_gh);if (error && !test_bit (SDF_SHUTDOWN , &sdp->sd_flags))return error;