GFS2: Fix & clean up GFS2 rename
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. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Cc: Peter Staubach <staubach@redhat.com>
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user