]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: allow idmapped rename inode op
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 27 Jul 2021 10:48:42 +0000 (12:48 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Aug 2021 11:19:12 +0000 (13:19 +0200)
Enable btrfs_rename() to handle idmapped mounts. This is just a matter
of passing down the mount's userns.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 0f9017a207abbe5d9258aea32d86c4ea0ff67a6a..04a37b750a179d0a1973f25b043efeaca3ea0252 100644 (file)
@@ -9550,6 +9550,7 @@ out_notrans:
 
 static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
                                     struct btrfs_root *root,
+                                    struct user_namespace *mnt_userns,
                                     struct inode *dir,
                                     struct dentry *dentry)
 {
@@ -9562,7 +9563,7 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
        if (ret)
                return ret;
 
-       inode = btrfs_new_inode(trans, root, &init_user_ns, dir,
+       inode = btrfs_new_inode(trans, root, mnt_userns, dir,
                                dentry->d_name.name,
                                dentry->d_name.len,
                                btrfs_ino(BTRFS_I(dir)),
@@ -9599,9 +9600,10 @@ out:
        return ret;
 }
 
-static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-                          struct inode *new_dir, struct dentry *new_dentry,
-                          unsigned int flags)
+static int btrfs_rename(struct user_namespace *mnt_userns,
+                       struct inode *old_dir, struct dentry *old_dentry,
+                       struct inode *new_dir, struct dentry *new_dentry,
+                       unsigned int flags)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(old_dir->i_sb);
        struct btrfs_trans_handle *trans;
@@ -9791,8 +9793,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        }
 
        if (flags & RENAME_WHITEOUT) {
-               ret = btrfs_whiteout_for_rename(trans, root, old_dir,
-                                               old_dentry);
+               ret = btrfs_whiteout_for_rename(trans, root, mnt_userns,
+                                               old_dir, old_dentry);
 
                if (ret) {
                        btrfs_abort_transaction(trans, ret);
@@ -9842,7 +9844,8 @@ static int btrfs_rename2(struct user_namespace *mnt_userns, struct inode *old_di
                return btrfs_rename_exchange(old_dir, old_dentry, new_dir,
                                          new_dentry);
 
-       return btrfs_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
+       return btrfs_rename(mnt_userns, old_dir, old_dentry, new_dir,
+                           new_dentry, flags);
 }
 
 struct btrfs_delalloc_work {