From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6D4D363C71; Tue, 11 Nov 2025 14:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762870414; cv=none; b=o+EaEDyNpEHC3IXc8eAo7V9WZEga8zCv4V/wWnQ6Tss70a5duwAQAnysoR4eCm94vWpy14yD9sA5pdo78glY6ygYAdGCOqeX3y8QNz0GR+h05t95xou65dey+Y2YxhkVlRrkthyqhM84zMyMNF7IvvW2pRbmVQhTRzzdbWT4OYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762870414; c=relaxed/simple; bh=xYYzPncnr5v6WTYsf79FmQQV0HF9Y2wtQ2qoyImEjMg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rgwDqTzcyWlfx80QEQ5UwSisMkmsDPMBzoPACuU+rqLIOdc7P7ltTXXLelOlIne7tXXBF5TJ1mBKpON8tNV/icb0vwXpSnn/A6SOUfsLyVj6bGSJYbKC85ccFv3FqqbnSpB68+dgS6jLIhWXhvgY7xC5MJwS51m4/Ky5jENF8sg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q4kDu+k+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q4kDu+k+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 255FAC4CEF7; Tue, 11 Nov 2025 14:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762870414; bh=xYYzPncnr5v6WTYsf79FmQQV0HF9Y2wtQ2qoyImEjMg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Q4kDu+k+If9JEXW8BIUNK8FPt9mJ9+IxAJzmdBkSrWBzctyyrwqFdTtW9cgC2noOJ Ibwv54F574WmiFdFw2QMdCS7ZvrB8yRYAcEm8BwcnW7YjvzcVhRIOxAukZ6QLjxQ3W 1MifA6vO3zGCaFSzmtYEXkYk0mscZMC9fhsJu6tJELkJ1nei1hWFLnHS81SgXl57ts YdlKO712ByZzuN12iZ5NNUFADpf0BDcZ/ppIU1QdK/KV7zsdycJelayiv1wmBc9azT Hm18TSMcU/3a/+QCzzkqpj2q7+Ske7onNQ+WcSle+YbNt54r7Tx+LfgpbYahZ1iDXh iZYj/NhpGDJeQ== From: Jeff Layton Date: Tue, 11 Nov 2025 09:12:50 -0500 Subject: [PATCH v6 09/17] vfs: clean up argument list for vfs_create() Precedence: bulk X-Mailing-List: netfs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251111-dir-deleg-ro-v6-9-52f3feebb2f2@kernel.org> References: <20251111-dir-deleg-ro-v6-0-52f3feebb2f2@kernel.org> In-Reply-To: <20251111-dir-deleg-ro-v6-0-52f3feebb2f2@kernel.org> To: Miklos Szeredi , Alexander Viro , Christian Brauner , Jan Kara , Chuck Lever , Alexander Aring , Trond Myklebust , Anna Schumaker , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , David Howells , Tyler Hicks , NeilBrown , Olga Kornievskaia , Dai Ngo , Amir Goldstein , Namjae Jeon , Steve French , Sergey Senozhatsky , Carlos Maiolino , Kuniyuki Iwashima , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, netfs@lists.linux.dev, ecryptfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, netdev@vger.kernel.org, linux-api@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6754; i=jlayton@kernel.org; h=from:subject:message-id; bh=xYYzPncnr5v6WTYsf79FmQQV0HF9Y2wtQ2qoyImEjMg=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBpE0RoDrRWliVdlAWm7FbEld26hIGo4FNf+p2VI CX7IlZSJFWJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaRNEaAAKCRAADmhBGVaC FYh6EAC1spozRwwDuXFZqsWAXuf9rmOCVnSEkdDZKWm2rCwdgiVoLrDOEfHkd+L8wEdgeMHsAAc xXS9f64/AelzlQ1E6LO+TJTCnFfmfDTWtZIBIVT/i3cRxJZ840kh7Dkrug4pu3Gufw/yoppfSQB WWNdEiMcfB64/o/0DgEDMSk7PaUok6TyB9kirxOMneOV10NEG8PLvvkWWhKurh1Ip/tkPL60Hd6 9eq4VlPQ3sfhwWIuZ3ugmsTDDruf+9d8gw63pFIBEhS7vtnXCjS4Z0lyQM1ePo6zBdED+Kl9VoC 62Z7NoMy8EoaxnyY+GSkFPSHuFblQzhwk9tL/OrKGVlkVF5QEqvivKuu42QWsOVJ2075HuCHWWp PoQWeOtcOLOZavNcz1TT17WtHAbuv89iCHPReGBVzyxq5K3xPUen+0qCJSLWn7Mu2jSB76puxxn qLA0pV67PXaCa2pK42pmiP3At5H/12HuRUHF1MHk2dXisAM7j46SArryIaZjEIkqVG5eQcCK194 1ee6SyEh6pxTKBz/gPRzZGzw73/4TiWHoWzp+mwgJhANokPqRs5acMmQRdPT//UBLIA9gdW+DjG oKt3tgzpiZWJfi1x9h+g+Tk6PYvk29R/cVoHJF/FLa05sgjWe2GJ+zzTPg0TWXZ9DvQECunzaDg BK+vI+1RzO8iZ+Q== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 As Neil points out: "I would be in favour of dropping the "dir" arg because it is always d_inode(dentry->d_parent) which is stable." ...and... "Also *every* caller of vfs_create() passes ".excl = true". So maybe we don't need that arg at all." Drop both arguments from vfs_create() and fix up the callers. Reviewed-by: Jan Kara Reviewed-by: NeilBrown Signed-off-by: Jeff Layton --- fs/ecryptfs/inode.c | 3 +-- fs/namei.c | 11 ++++------- fs/nfsd/nfs3proc.c | 2 +- fs/nfsd/vfs.c | 3 +-- fs/open.c | 4 +--- fs/overlayfs/overlayfs.h | 2 +- fs/smb/server/vfs.c | 3 +-- include/linux/fs.h | 3 +-- 8 files changed, 11 insertions(+), 20 deletions(-) diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 88631291b32535f623a3fbe4ea9b6ed48a306ca0..d109e3763a88150bfe64cd2d5564dc9802ef3386 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -188,8 +188,7 @@ ecryptfs_do_create(struct inode *directory_inode, rc = lock_parent(ecryptfs_dentry, &lower_dentry, &lower_dir); if (!rc) - rc = vfs_create(&nop_mnt_idmap, lower_dir, - lower_dentry, mode, true); + rc = vfs_create(&nop_mnt_idmap, lower_dentry, mode); if (rc) { printk(KERN_ERR "%s: Failure to create dentry in lower fs; " "rc = [%d]\n", __func__, rc); diff --git a/fs/namei.c b/fs/namei.c index f439429bdfa271ccc64c937771ef4175597feb53..9586c6aba6eae05a9fc3c103b8501d98767bef53 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3461,10 +3461,8 @@ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap, /** * vfs_create - create new file * @idmap: idmap of the mount the inode was found from - * @dir: inode of the parent directory * @dentry: dentry of the child file * @mode: mode of the child file - * @want_excl: whether the file must not yet exist * * Create a new file. * @@ -3474,9 +3472,9 @@ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap, * On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_create(struct mnt_idmap *idmap, struct inode *dir, - struct dentry *dentry, umode_t mode, bool want_excl) +int vfs_create(struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode) { + struct inode *dir = d_inode(dentry->d_parent); int error; error = may_create(idmap, dir, dentry); @@ -3490,7 +3488,7 @@ int vfs_create(struct mnt_idmap *idmap, struct inode *dir, error = security_inode_create(dir, dentry, mode); if (error) return error; - error = dir->i_op->create(idmap, dir, dentry, mode, want_excl); + error = dir->i_op->create(idmap, dir, dentry, mode, true); if (!error) fsnotify_create(dir, dentry); return error; @@ -4383,8 +4381,7 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode, idmap = mnt_idmap(path.mnt); switch (mode & S_IFMT) { case 0: case S_IFREG: - error = vfs_create(idmap, path.dentry->d_inode, - dentry, mode, true); + error = vfs_create(idmap, dentry, mode); if (!error) security_path_post_mknod(idmap, dentry); break; diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index b6d03e1ef5f7a5e8dd111b0d56c061f1e91abff7..30ea7ffa2affdb9a959b0fd15a630de056d6dc3c 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -344,7 +344,7 @@ nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, status = fh_fill_pre_attrs(fhp); if (status != nfs_ok) goto out; - host_err = vfs_create(&nop_mnt_idmap, inode, child, iap->ia_mode, true); + host_err = vfs_create(&nop_mnt_idmap, child, iap->ia_mode); if (host_err < 0) { status = nfserrno(host_err); goto out; diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index c400ea94ff2e837fd59719bf2c4b79ef1d064743..464fd54675f3b16fce9ae5f05ad22e0e6b363eb3 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1552,8 +1552,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp, err = 0; switch (type) { case S_IFREG: - host_err = vfs_create(&nop_mnt_idmap, dirp, dchild, - iap->ia_mode, true); + host_err = vfs_create(&nop_mnt_idmap, dchild, iap->ia_mode); if (!host_err) nfsd_check_ignore_resizing(iap); break; diff --git a/fs/open.c b/fs/open.c index fdaa6f08f6f4cac5c2fefd3eafa5e430e51f3979..e440f58e3ce81e137aabdf00510d839342a19219 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1171,9 +1171,7 @@ struct file *dentry_create(const struct path *path, int flags, umode_t mode, if (IS_ERR(f)) return f; - error = vfs_create(mnt_idmap(path->mnt), - d_inode(path->dentry->d_parent), - path->dentry, mode, true); + error = vfs_create(mnt_idmap(path->mnt), path->dentry, mode); if (!error) error = vfs_open(path, f); diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index d215d7349489686b66bb66e939b27046f7d836f6..2bdc434941ebc70f6d4f57cca4f68125112a7bc4 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -235,7 +235,7 @@ static inline int ovl_do_create(struct ovl_fs *ofs, struct inode *dir, struct dentry *dentry, umode_t mode) { - int err = vfs_create(ovl_upper_mnt_idmap(ofs), dir, dentry, mode, true); + int err = vfs_create(ovl_upper_mnt_idmap(ofs), dentry, mode); pr_debug("create(%pd2, 0%o) = %i\n", dentry, mode, err); return err; diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c index c5f0f3170d586cb2dc4d416b80948c642797fb82..83ece2de4b23bf9209137e7ca414a72439b5cc2e 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -188,8 +188,7 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode) } mode |= S_IFREG; - err = vfs_create(mnt_idmap(path.mnt), d_inode(path.dentry), - dentry, mode, true); + err = vfs_create(mnt_idmap(path.mnt), dentry, mode); if (!err) { ksmbd_vfs_inherit_owner(work, d_inode(path.dentry), d_inode(dentry)); diff --git a/include/linux/fs.h b/include/linux/fs.h index 12873214e1c7811735ea5d2dee3d57e2a5604d8f..21876ef1fec90181b9878372c7c7e710773aae9f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2111,8 +2111,7 @@ bool inode_owner_or_capable(struct mnt_idmap *idmap, /* * VFS helper functions.. */ -int vfs_create(struct mnt_idmap *, struct inode *, - struct dentry *, umode_t, bool); +int vfs_create(struct mnt_idmap *, struct dentry *, umode_t); struct dentry *vfs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *, umode_t, struct delegated_inode *); int vfs_mknod(struct mnt_idmap *, struct inode *, struct dentry *, -- 2.51.1