Skip to content

Commit

Permalink
[GFS2] Fix double locking problem in rename
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Whitehouse committed Jun 21, 2006
1 parent bf9f424 commit d9d1ca3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions fs/gfs2/ops_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d9d1ca3

Please sign in to comment.