Commit ca07274c authored by Christian Brauner's avatar Christian Brauner Committed by David Sterba

btrfs: allow idmapped rename inode op

Enable btrfs_rename() to handle idmapped mounts. This is just a matter
of passing down the mount's userns.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b3b6f5b9
...@@ -9550,6 +9550,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9550,6 +9550,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans, static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct user_namespace *mnt_userns,
struct inode *dir, struct inode *dir,
struct dentry *dentry) struct dentry *dentry)
{ {
...@@ -9562,7 +9563,7 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans, ...@@ -9562,7 +9563,7 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
if (ret) if (ret)
return 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.name,
dentry->d_name.len, dentry->d_name.len,
btrfs_ino(BTRFS_I(dir)), btrfs_ino(BTRFS_I(dir)),
...@@ -9599,7 +9600,8 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans, ...@@ -9599,7 +9600,8 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, 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, struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags) unsigned int flags)
{ {
...@@ -9791,8 +9793,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -9791,8 +9793,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
} }
if (flags & RENAME_WHITEOUT) { if (flags & RENAME_WHITEOUT) {
ret = btrfs_whiteout_for_rename(trans, root, old_dir, ret = btrfs_whiteout_for_rename(trans, root, mnt_userns,
old_dentry); old_dir, old_dentry);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -9842,7 +9844,8 @@ static int btrfs_rename2(struct user_namespace *mnt_userns, struct inode *old_di ...@@ -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, return btrfs_rename_exchange(old_dir, old_dentry, new_dir,
new_dentry); 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 { struct btrfs_delalloc_work {
......
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