summaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ops_inode.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-06-21 15:38:17 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2006-06-21 15:38:17 -0400
commitd9d1ca30505c6fed867e1724b16fdad0c281d7d1 (patch)
treeedcba6e6afe04246af51a1884fc6ad59b7f14de6 /fs/gfs2/ops_inode.c
parentbf9f424d9acf461fabcb0e9f47b356e08186d91f (diff)
[GFS2] Fix double locking problem in rename
The rename inode operation was trying to lock the same inode twice in the case of renaming with the source and destination directories the same. We now test for this and just lock once. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/ops_inode.c')
-rw-r--r--fs/gfs2/ops_inode.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 2fe37aeac7b..3a2769ebfe4 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -615,13 +615,19 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
goto out_gunlock_r;
}
+ num_gh = 1;
gfs2_holder_init(odip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
- gfs2_holder_init(ndip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
- gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 2);
- num_gh = 3;
+ if (odip != ndip) {
+ gfs2_holder_init(ndip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh);
+ num_gh++;
+ }
+ gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh);
+ num_gh++;
- if (nip)
- gfs2_holder_init(nip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh++);
+ if (nip) {
+ gfs2_holder_init(nip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh);
+ num_gh++;
+ }
error = gfs2_glock_nq_m(num_gh, ghs);
if (error)