Skip to content

Commit 85bbffc

Browse files
jtlaytonbrauner
authored andcommitted
vfs: clean up argument list for vfs_create()
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 <jack@suse.cz> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20251111-dir-deleg-ro-v6-9-52f3feebb2f2@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 134796f commit 85bbffc

8 files changed

Lines changed: 11 additions & 20 deletions

File tree

fs/ecryptfs/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ ecryptfs_do_create(struct inode *directory_inode,
188188

189189
rc = lock_parent(ecryptfs_dentry, &lower_dentry, &lower_dir);
190190
if (!rc)
191-
rc = vfs_create(&nop_mnt_idmap, lower_dir,
192-
lower_dentry, mode, true);
191+
rc = vfs_create(&nop_mnt_idmap, lower_dentry, mode);
193192
if (rc) {
194193
printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
195194
"rc = [%d]\n", __func__, rc);

fs/namei.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3461,10 +3461,8 @@ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,
34613461
/**
34623462
* vfs_create - create new file
34633463
* @idmap: idmap of the mount the inode was found from
3464-
* @dir: inode of the parent directory
34653464
* @dentry: dentry of the child file
34663465
* @mode: mode of the child file
3467-
* @want_excl: whether the file must not yet exist
34683466
*
34693467
* Create a new file.
34703468
*
@@ -3474,9 +3472,9 @@ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,
34743472
* On non-idmapped mounts or if permission checking is to be performed on the
34753473
* raw inode simply pass @nop_mnt_idmap.
34763474
*/
3477-
int vfs_create(struct mnt_idmap *idmap, struct inode *dir,
3478-
struct dentry *dentry, umode_t mode, bool want_excl)
3475+
int vfs_create(struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode)
34793476
{
3477+
struct inode *dir = d_inode(dentry->d_parent);
34803478
int error;
34813479

34823480
error = may_create(idmap, dir, dentry);
@@ -3490,7 +3488,7 @@ int vfs_create(struct mnt_idmap *idmap, struct inode *dir,
34903488
error = security_inode_create(dir, dentry, mode);
34913489
if (error)
34923490
return error;
3493-
error = dir->i_op->create(idmap, dir, dentry, mode, want_excl);
3491+
error = dir->i_op->create(idmap, dir, dentry, mode, true);
34943492
if (!error)
34953493
fsnotify_create(dir, dentry);
34963494
return error;
@@ -4383,8 +4381,7 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode,
43834381
idmap = mnt_idmap(path.mnt);
43844382
switch (mode & S_IFMT) {
43854383
case 0: case S_IFREG:
4386-
error = vfs_create(idmap, path.dentry->d_inode,
4387-
dentry, mode, true);
4384+
error = vfs_create(idmap, dentry, mode);
43884385
if (!error)
43894386
security_path_post_mknod(idmap, dentry);
43904387
break;

fs/nfsd/nfs3proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
344344
status = fh_fill_pre_attrs(fhp);
345345
if (status != nfs_ok)
346346
goto out;
347-
host_err = vfs_create(&nop_mnt_idmap, inode, child, iap->ia_mode, true);
347+
host_err = vfs_create(&nop_mnt_idmap, child, iap->ia_mode);
348348
if (host_err < 0) {
349349
status = nfserrno(host_err);
350350
goto out;

fs/nfsd/vfs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,8 +1552,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
15521552
err = 0;
15531553
switch (type) {
15541554
case S_IFREG:
1555-
host_err = vfs_create(&nop_mnt_idmap, dirp, dchild,
1556-
iap->ia_mode, true);
1555+
host_err = vfs_create(&nop_mnt_idmap, dchild, iap->ia_mode);
15571556
if (!host_err)
15581557
nfsd_check_ignore_resizing(iap);
15591558
break;

fs/open.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,9 +1171,7 @@ struct file *dentry_create(const struct path *path, int flags, umode_t mode,
11711171
if (IS_ERR(f))
11721172
return f;
11731173

1174-
error = vfs_create(mnt_idmap(path->mnt),
1175-
d_inode(path->dentry->d_parent),
1176-
path->dentry, mode, true);
1174+
error = vfs_create(mnt_idmap(path->mnt), path->dentry, mode);
11771175
if (!error)
11781176
error = vfs_open(path, f);
11791177

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static inline int ovl_do_create(struct ovl_fs *ofs,
235235
struct inode *dir, struct dentry *dentry,
236236
umode_t mode)
237237
{
238-
int err = vfs_create(ovl_upper_mnt_idmap(ofs), dir, dentry, mode, true);
238+
int err = vfs_create(ovl_upper_mnt_idmap(ofs), dentry, mode);
239239

240240
pr_debug("create(%pd2, 0%o) = %i\n", dentry, mode, err);
241241
return err;

fs/smb/server/vfs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)
188188
}
189189

190190
mode |= S_IFREG;
191-
err = vfs_create(mnt_idmap(path.mnt), d_inode(path.dentry),
192-
dentry, mode, true);
191+
err = vfs_create(mnt_idmap(path.mnt), dentry, mode);
193192
if (!err) {
194193
ksmbd_vfs_inherit_owner(work, d_inode(path.dentry),
195194
d_inode(dentry));

include/linux/fs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,8 +2111,7 @@ bool inode_owner_or_capable(struct mnt_idmap *idmap,
21112111
/*
21122112
* VFS helper functions..
21132113
*/
2114-
int vfs_create(struct mnt_idmap *, struct inode *,
2115-
struct dentry *, umode_t, bool);
2114+
int vfs_create(struct mnt_idmap *, struct dentry *, umode_t);
21162115
struct dentry *vfs_mkdir(struct mnt_idmap *, struct inode *,
21172116
struct dentry *, umode_t, struct delegated_inode *);
21182117
int vfs_mknod(struct mnt_idmap *, struct inode *, struct dentry *,

0 commit comments

Comments
 (0)