Fix rename locking issue
This patch fixes a locking issue in the rename code by ensuring that we hold the per sb rename lock over both directory and "other" renames which involve different parent directories.
At the same time, this moved the (only called from one place) function gfs2_ok_to_move into the file that its called from, so we can mark it static. This should make a code a bit easier to follow.
fs/gfs2/inode.c +0 -48
@@ -1140,54 +1140,6 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,return 0 ; } -/* -* gfs2_ok_to_move - check if it's ok to move a directory to another directory -* @this: move this -* @to: to here -* -* Follow @to back to the root and make sure we don't encounter @this -* Assumes we already hold the rename lock. -* -* Returns: errno -*/ - -int gfs2_ok_to_move (struct gfs2_inode *this,struct gfs2_inode *to) -{ -struct inode *dir = &to->i_inode; -struct super_block *sb = dir->i_sb; -struct inode *tmp; -struct qstr dotdot; -int error =0 ; - -gfs2_str2qstr (&dotdot,".." ); - -igrab (dir); - -for (;;) { -if (dir == &this->i_inode) { - error = -EINVAL ; -break ; - } -if (dir == sb->s_root->d_inode) { - error =0 ; -break ; - } - - tmp =gfs2_lookupi (dir, &dotdot,1 ); -if (IS_ERR (tmp)) { - error =PTR_ERR (tmp); -break ; - } - -iput (dir); - dir = tmp; - } - -iput (dir); - -return error; -} -/** * gfs2_readlinki - return the contents of a symlink * @ip: the symlink's inode
fs/gfs2/inode.h +0 -1
@@ -91,7 +91,6 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,int gfs2_unlink_ok (struct gfs2_inode *dip,const struct qstr *name,const struct gfs2_inode *ip);int gfs2_permission (struct inode *inode,int mask); -int gfs2_ok_to_move (struct gfs2_inode *this,struct gfs2_inode *to);int gfs2_readlinki (struct gfs2_inode *ip,char **buf,unsigned int *len);int gfs2_glock_nq_atime (struct gfs2_holder *gh);int gfs2_setattr_simple (struct gfs2_inode *ip,struct iattr *attr);
fs/gfs2/ops_inode.c +60 -11
99 lines not on this page · raw message
[Cluster-devel] [GFS2] bz231369 - GFS2 will panic if you misspell any mount options
This is the upstream patch. RHEL5 patch posted to rhkernel-list. The gfs2 superblock pointer is NULL after a failed mount. When control eventually goes to gfs2_kill_sb, we dereference this NULL pointer. This patch ensures that the gfs2 superblock pointer is not NULL before being dereferenced in gfs2_kill_sb.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bz231369-git.patch
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20080911/95253b9a/attachment.ksh>
[Cluster-devel] [GFS2] bz231369 - GFS2 will panic if you misspell any mount options
Quoted 8 lines · Abhijith Das
This is the upstream patch. RHEL5 patch posted to rhkernel-list. The gfs2 superblock pointer is NULL after a failed mount. When control eventually goes to
gfs2_kill_sb, we dereference this NULL pointer. This patch ensures that the gfs2 superblock pointer is not NULL before being dereferenced ingfs2_kill_sb.Signed-off-by Abhijith Das <[email protected]>
Corrected upstream patch.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bz231369-git.patch
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20080915/8fabfad4/attachment.ksh>
Steven Whitehouse
Applied[Cluster-devel] [GFS2] bz231369 - GFS2 will panic if you misspell any mount options
Hi,
Applied to the -nmw tree. Thanks,
Steve.
Quoted 42 lines · Abhijith Das
Quoted 8 lines · Abhijith Das
This is the upstream patch. RHEL5 patch posted to rhkernel-list. The gfs2 superblock pointer is NULL after a failed mount. When control eventually goes to
gfs2_kill_sb, we dereference this NULL pointer. This patch ensures that the gfs2 superblock pointer is not NULL before being dereferenced ingfs2_kill_sb.Signed-off-by Abhijith Das <[email protected]>Corrected upstream patch.
Signed-off-by Abhijith Das <[email protected]>plain text document attachment (bz231369-git.patch)
fs/gfs2/ops_fstype.c +9
-6@@ -1237,14 +1237,17 @@ static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,static void gfs2_kill_sb (struct super_block *sb) {struct gfs2_sbd *sdp = sb->s_fs_info; -gfs2_meta_syncfs (sdp); -dput (sdp->sd_root_dir); -dput (sdp->sd_master_dir); - sdp->sd_root_dir =NULL ; - sdp->sd_master_dir =NULL ; +if (sdp) { +gfs2_meta_syncfs (sdp); +dput (sdp->sd_root_dir); +dput (sdp->sd_master_dir); + sdp->sd_root_dir =NULL ; + sdp->sd_master_dir =NULL ; + }shrink_dcache_sb (sb);kill_block_super (sb); -gfs2_delete_debugfs_file (sdp); +if (sdp) +gfs2_delete_debugfs_file (sdp); }struct file_system_type gfs2_fs_type = {