From: Filipe Manana Date: Tue, 13 Jan 2026 12:39:53 +0000 (+0000) Subject: btrfs: use may_create_dentry() in btrfs_mksubvol() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c91c776a92315a02e020fd558c5319864f1f104;p=thirdparty%2Fkernel%2Flinux.git 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 Link: https://patch.msgid.link/adf8c802c77ec1c855ea9fe12491120ccc29a294.1768307858.git.fdmanana@suse.com Reviewed-by: David Sterba Signed-off-by: Christian Brauner --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 2d0b2619309d7..d1ab03691606c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -815,19 +815,6 @@ free_pending: return ret; } -/* copy of may_create in fs/namei.c() */ -static inline int btrfs_may_create(struct mnt_idmap *idmap, - struct inode *dir, const struct dentry *child) -{ - if (d_really_is_positive(child)) - return -EEXIST; - if (IS_DEADDIR(dir)) - return -ENOENT; - if (!fsuidgid_has_mapping(dir->i_sb, idmap)) - return -EOVERFLOW; - return inode_permission(idmap, dir, MAY_WRITE | MAY_EXEC); -} - /* * Create a new subvolume below @parent. This is largely modeled after * 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, if (IS_ERR(dentry)) return PTR_ERR(dentry); - ret = btrfs_may_create(idmap, dir, dentry); + ret = may_create_dentry(idmap, dir, dentry); if (ret) goto out_dput;