Commit 9055cba7 authored by Sage Weil's avatar Sage Weil Committed by Al Viro

vfs: clean up vfs_rename_dir

Simplify control flow through vfs_rename_dir.
Signed-off-by: default avatarSage Weil <sage@newdream.net>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 912dbc15
...@@ -2963,7 +2963,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2963,7 +2963,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry) struct inode *new_dir, struct dentry *new_dentry)
{ {
int error = 0; int error = 0;
struct inode *target; struct inode *target = new_dentry->d_inode;
/* /*
* If we are going to change the parent - check write permissions, * If we are going to change the parent - check write permissions,
...@@ -2979,20 +2979,24 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2979,20 +2979,24 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
if (error) if (error)
return error; return error;
target = new_dentry->d_inode;
if (target) if (target)
mutex_lock(&target->i_mutex); mutex_lock(&target->i_mutex);
if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
error = -EBUSY; error = -EBUSY;
else if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry))
error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); goto out;
error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
if (error)
goto out;
if (target) { if (target) {
if (!error) { target->i_flags |= S_DEAD;
target->i_flags |= S_DEAD; dont_mount(new_dentry);
dont_mount(new_dentry);
}
mutex_unlock(&target->i_mutex);
} }
out:
if (target)
mutex_unlock(&target->i_mutex);
if (!error) if (!error)
if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE))
d_move(old_dentry,new_dentry); d_move(old_dentry,new_dentry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment