Commit 51892bbb57e87854c27c105317797823f8891e68

Authored by Sage Weil
Committed by Al Viro
1 parent 9055cba711

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>

Showing 1 changed file with 14 additions and 11 deletions Side-by-side Diff

... ... @@ -3006,7 +3006,7 @@
3006 3006 static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
3007 3007 struct inode *new_dir, struct dentry *new_dentry)
3008 3008 {
3009   - struct inode *target;
  3009 + struct inode *target = new_dentry->d_inode;
3010 3010 int error;
3011 3011  
3012 3012 error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry);
3013 3013  
3014 3014  
... ... @@ -3014,19 +3014,22 @@
3014 3014 return error;
3015 3015  
3016 3016 dget(new_dentry);
3017   - target = new_dentry->d_inode;
3018 3017 if (target)
3019 3018 mutex_lock(&target->i_mutex);
  3019 +
  3020 + error = -EBUSY;
3020 3021 if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
3021   - error = -EBUSY;
3022   - else
3023   - error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
3024   - if (!error) {
3025   - if (target)
3026   - dont_mount(new_dentry);
3027   - if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE))
3028   - d_move(old_dentry, new_dentry);
3029   - }
  3022 + goto out;
  3023 +
  3024 + error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
  3025 + if (error)
  3026 + goto out;
  3027 +
  3028 + if (target)
  3029 + dont_mount(new_dentry);
  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 3033 if (target)
3031 3034 mutex_unlock(&target->i_mutex);
3032 3035 dput(new_dentry);