Skip to content

Commit 6c91c77

Browse files
fdmananabrauner
authored andcommitted
btrfs: use may_create_dentry() in btrfs_mksubvol()
There is no longer the need to use btrfs_may_create(), which was a copy of the VFS private function may_create(), since now that functionality is exported by the VFS as a function named may_create_dentry(). So change btrfs_mksubvol() to use the VFS function and remove btrfs_may_create(). Note that the btrfs copy was missing an audit_inode_child() call that we have in the VFS function. This only reinforces the need to use a common function, as it's very easy for the btrfs copy to get out of sync and therefore a maintenance burden. Signed-off-by: Filipe Manana <fdmanana@suse.com> Link: https://patch.msgid.link/adf8c802c77ec1c855ea9fe12491120ccc29a294.1768307858.git.fdmanana@suse.com Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 5f84a10 commit 6c91c77

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

fs/btrfs/ioctl.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -815,19 +815,6 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
815815
return ret;
816816
}
817817

818-
/* copy of may_create in fs/namei.c() */
819-
static inline int btrfs_may_create(struct mnt_idmap *idmap,
820-
struct inode *dir, const struct dentry *child)
821-
{
822-
if (d_really_is_positive(child))
823-
return -EEXIST;
824-
if (IS_DEADDIR(dir))
825-
return -ENOENT;
826-
if (!fsuidgid_has_mapping(dir->i_sb, idmap))
827-
return -EOVERFLOW;
828-
return inode_permission(idmap, dir, MAY_WRITE | MAY_EXEC);
829-
}
830-
831818
/*
832819
* Create a new subvolume below @parent. This is largely modeled after
833820
* sys_mkdirat and vfs_mkdir, but we only do a single component lookup
@@ -849,7 +836,7 @@ static noinline int btrfs_mksubvol(struct dentry *parent,
849836
if (IS_ERR(dentry))
850837
return PTR_ERR(dentry);
851838

852-
ret = btrfs_may_create(idmap, dir, dentry);
839+
ret = may_create_dentry(idmap, dir, dentry);
853840
if (ret)
854841
goto out_dput;
855842

0 commit comments

Comments
 (0)