diff options
author | Sage Weil <sage@newdream.net> | 2011-05-24 16:06:13 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-05-26 07:26:53 -0400 |
commit | 51892bbb57e87854c27c105317797823f8891e68 (patch) | |
tree | 8d7fd27631bc868ebac7de8c3baaab7a8111591b /fs/namei.c | |
parent | 9055cba711891a6313232629cd6bbca7c901e07f (diff) |
vfs: clean up vfs_rename_other
Simplify control flow to match vfs_rename_dir.
Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/namei.c b/fs/namei.c index ecb16d3727ea..f90f0593092a 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -3006,7 +3006,7 @@ out: | |||
3006 | static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, | 3006 | static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, |
3007 | struct inode *new_dir, struct dentry *new_dentry) | 3007 | struct inode *new_dir, struct dentry *new_dentry) |
3008 | { | 3008 | { |
3009 | struct inode *target; | 3009 | struct inode *target = new_dentry->d_inode; |
3010 | int error; | 3010 | int error; |
3011 | 3011 | ||
3012 | error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry); | 3012 | error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry); |
@@ -3014,19 +3014,22 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, | |||
3014 | return error; | 3014 | return error; |
3015 | 3015 | ||
3016 | dget(new_dentry); | 3016 | dget(new_dentry); |
3017 | target = new_dentry->d_inode; | ||
3018 | if (target) | 3017 | if (target) |
3019 | mutex_lock(&target->i_mutex); | 3018 | mutex_lock(&target->i_mutex); |
3019 | |||
3020 | error = -EBUSY; | ||
3020 | if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) | 3021 | if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) |
3021 | error = -EBUSY; | 3022 | goto out; |
3022 | else | 3023 | |
3023 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); | 3024 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); |
3024 | if (!error) { | 3025 | if (error) |
3025 | if (target) | 3026 | goto out; |
3026 | dont_mount(new_dentry); | 3027 | |
3027 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) | 3028 | if (target) |
3028 | d_move(old_dentry, new_dentry); | 3029 | dont_mount(new_dentry); |
3029 | } | 3030 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) |
3031 | d_move(old_dentry, new_dentry); | ||
3032 | out: | ||
3030 | if (target) | 3033 | if (target) |
3031 | mutex_unlock(&target->i_mutex); | 3034 | mutex_unlock(&target->i_mutex); |
3032 | dput(new_dentry); | 3035 | dput(new_dentry); |