vfs: remove the excl argument from the ->create() inode_operation
Subsystems (43)
Jeff Layton
maintainerPATCH RESEND v3 1/1 vfs: remove the excl argument from the ->create() inode_operation
With three exceptions, ->create() methods provided by filesystems ignore the "excl" flag. Those exception are NFS, GFS2 and vboxsf which all also provide ->atomic_open.
Since ce8644fcadc5 ("lookup_open(): expand the call of vfs_create()"), the "excl" argument to the ->create() inode_operation is always set to true in vfs_create(). The ->create() call in lookup_open() sets it according to the O_EXCL open flag, but is never called if the filesystem provides ->atomic_open().
The excl flag is therefore always either ignored or true. Remove it, and change NFS, GFS2 and vboxsf to act as if it were always true.
---
I sent this a couple of weeks ago and never got a response from Christian, Al or Jan. This seems like it should be a no-brainer cleanup, and I think the Documentation/ updates will be helpful, so I'm guessing it just slipped through the cracks.
A little late at this point for v6.19, so consider for v7.0 ?
---
Changes in v3:
- fix use of excl in vboxsf_dir_mkfile()
- fix tab prefixes in Documentation/filesystems/vfs.rst
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- better describe why the argument isn't needed in the changelog
- updates do Documentation/
- Link to v1: https://lore.kernel.org/r/[email protected]
--- Documentation/filesystems/porting.rst | 12 ++++++++++++ Documentation/filesystems/vfs.rst | 13 ++++++++++--- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/affs/affs.h | 2 +- fs/affs/namei.c | 2 +- fs/afs/dir.c | 4 ++-- fs/bad_inode.c | 2 +- fs/bfs/dir.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/dir.c | 2 +- fs/coda/dir.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/efivarfs/inode.c | 2 +- fs/exfat/namei.c | 2 +- fs/ext2/namei.c | 2 +- fs/ext4/namei.c | 2 +- fs/f2fs/namei.c | 2 +- fs/fat/namei_msdos.c | 2 +- fs/fat/namei_vfat.c | 2 +- fs/fuse/dir.c | 2 +- fs/gfs2/inode.c | 5 ++--- fs/hfs/dir.c | 2 +- fs/hfsplus/dir.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/namei.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/dir.c | 4 ++-- fs/jfs/namei.c | 2 +- fs/minix/namei.c | 2 +- fs/namei.c | 4 ++-- fs/nfs/dir.c | 4 ++-- fs/nfs/internal.h | 2 +- fs/nilfs2/namei.c | 2 +- fs/ntfs3/namei.c | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 3 +-- fs/ocfs2/namei.c | 3 +-- fs/omfs/dir.c | 2 +- fs/orangefs/namei.c | 3 +-- fs/overlayfs/dir.c | 2 +- fs/ramfs/inode.c | 2 +- fs/smb/client/cifsfs.h | 2 +- fs/smb/client/dir.c | 2 +- fs/ubifs/dir.c | 2 +- fs/udf/namei.c | 2 +- fs/ufs/namei.c | 3 +-- fs/vboxsf/dir.c | 4 ++-- fs/xfs/xfs_iops.c | 3 +-- include/linux/fs.h | 4 ++-- ipc/mqueue.c | 2 +- mm/shmem.c | 2 +- 51 files changed, 78 insertions(+), 65 deletions(-)
Documentation/filesystems/porting.rst +12 -0
@@ -1322,3 +1322,15 @@ When vfs_mkdir() returns an error, and so both dputs() the original dentry and doesn't provide a replacement, it also unlocks the parent. Consequently the return value from vfs_mkdir() can be passed to end_creating() and the parent will be unlocked precisely when necessary. + +--- + +**mandatory** + +The ->create() operation has dropped the bool "excl" argument. This operation +should now always provide O_EXCL semantics (i.e. fail with -EEXIST if the file +exists). If the filesystem needs to handle the case where another entity could +create the file on the backing store after a negative lookup or revalidate +(e.g. it's a network filesystem and another client could create the file after +a negative lookup), then it will require ->atomic_open() in addition to +->create().
Documentation/filesystems/vfs.rst +10 -3
@@ -467,7 +467,7 @@ As of kernel 2.6.22, the following members are defined: .. code-block:: c struct inode_operations { - int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t, bool); + int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t); struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *);
@@ -505,7 +505,10 @@ otherwise noted. if you want to support regular files. The dentry you get should not have an inode (i.e. it should be a negative dentry). Here you will probably call d_instantiate() with the dentry and the - newly created inode + newly created inode. This operation should always provide O_EXCL + semantics (i.e. it should fail with -EEXIST if the file exists). + If the filesystem needs to mediate non-exclusive creation, + then the filesystem must also provide an ->atomic_open() operation. ``lookup`` called when the VFS needs to look up an inode in a parent
@@ -654,7 +657,11 @@ otherwise noted. handled by f_op->open(). If the file was created, FMODE_CREATED flag should be set in file->f_mode. In case of O_EXCL the method must only succeed if the file didn't exist and hence - FMODE_CREATED shall always be set on success. + FMODE_CREATED shall always be set on success. This method is + usually needed on filesystems where the dentry to be created could + unexpectedly become positive after the kernel has looked it up or + revalidated it. (e.g. another host racing in and creating the file + on an NFS server). ``tmpfile`` called in the end of O_TMPFILE open(). Optional, equivalent to
fs/9p/vfs_inode.c +1 -1
@@ -643,7 +643,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,static int v9fs_vfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct v9fs_session_info *v9ses =v9fs_inode2v9ses (dir);u32 perm =unixmode2p9mode (v9ses, mode);
fs/9p/vfs_inode_dotl.c +1 -1
@@ -218,7 +218,7 @@ int v9fs_open_to_dotl_flags(int flags)*/ static int v9fs_vfs_create_dotl (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t omode,bool excl) +struct dentry *dentry,umode_t omode) {return v9fs_vfs_mknod_dotl (idmap, dir, dentry, omode,0 ); }
fs/affs/affs.h +1 -1
@@ -167,7 +167,7 @@ extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int lextern struct dentry *affs_lookup (struct inode *dir,struct dentry *dentry,unsigned int );extern int affs_unlink (struct inode *dir,struct dentry *dentry);extern int affs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool ); +struct dentry *dentry,umode_t mode);extern struct dentry *affs_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode);extern int affs_rmdir (struct inode *dir,struct dentry *dentry);
fs/affs/namei.c +1 -1
@@ -243,7 +243,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)int affs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;
fs/afs/dir.c +2 -2
@@ -32,7 +32,7 @@ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *name, instatic bool afs_lookup_filldir (struct dir_context *ctx,const char *name,int nlen,loff_t fpos,u64 ino,unsigned dtype);static int afs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl); +struct dentry *dentry,umode_t mode);static struct dentry *afs_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode);static int afs_rmdir (struct inode *dir,struct dentry *dentry);
@@ -1637,7 +1637,7 @@ static const struct afs_operation_ops afs_create_operation = {* create a regular file on an AFS filesystem */ static int afs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct afs_operation *op;struct afs_vnode *dvnode =AFS_FS_I (dir);
fs/bad_inode.c +1 -1
@@ -29,7 +29,7 @@ static const struct file_operations bad_file_ops =static int bad_inode_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +umode_t mode) {return -EIO ; }
fs/bfs/dir.c +1 -1
@@ -76,7 +76,7 @@ const struct file_operations bfs_dir_operations = { };static int bfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {int err;struct inode *inode;
fs/btrfs/inode.c +1 -1
@@ -6825,7 +6825,7 @@ static int btrfs_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int btrfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;
fs/ceph/dir.c +1 -1
@@ -976,7 +976,7 @@ static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int ceph_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ceph_mknod (idmap, dir, dentry, mode,0 ); }
fs/coda/dir.c +1 -1
@@ -134,7 +134,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)/* creation routines: create, mknod, mkdir, link, symlink */ static int coda_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *de,umode_t mode,bool excl) +struct dentry *de,umode_t mode) {int error;const char *name=de->d_name.name;
fs/ecryptfs/inode.c +1 -1
@@ -268,7 +268,7 @@ int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,static int ecryptfs_create (struct mnt_idmap *idmap,struct inode *directory_inode,struct dentry *ecryptfs_dentry, -umode_t mode,bool excl) +umode_t mode) {struct inode *ecryptfs_inode;int rc;
fs/efivarfs/inode.c +1 -1
@@ -75,7 +75,7 @@ static bool efivarfs_valid_name(const char *str, int len) }static int efivarfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode =NULL ;struct efivar_entry *var;
fs/exfat/namei.c +1 -1
@@ -543,7 +543,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, }static int exfat_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;
fs/ext2/namei.c +1 -1
@@ -101,7 +101,7 @@ struct dentry *ext2_get_parent(struct dentry *child)*/ static int ext2_create (struct mnt_idmap * idmap,struct inode * dir,struct dentry * dentry, -umode_t mode,bool excl) +umode_t mode) {struct inode *inode;int err;
fs/ext4/namei.c +1 -1
@@ -2806,7 +2806,7 @@ static int ext4_add_nondir(handle_t *handle,* with d_instantiate(). */ static int ext4_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {handle_t *handle;struct inode *inode;
fs/f2fs/namei.c +1 -1
@@ -351,7 +351,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, }static int f2fs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct inode *inode;
fs/fat/namei_msdos.c +1 -1
@@ -262,7 +262,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,/***** Create a file */ static int msdos_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode =NULL ;
fs/fat/namei_vfat.c +1 -1
@@ -754,7 +754,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, }static int vfat_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;
fs/fuse/dir.c +1 -1
@@ -889,7 +889,7 @@ static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int fuse_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *entry,umode_t mode,bool excl) +struct dentry *entry,umode_t mode) {return fuse_mknod (idmap, dir, entry, mode,0 ); }
fs/gfs2/inode.c +2 -3
@@ -942,15 +942,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,* @dir: The directory in which to create the file * @dentry: The dentry of the new file * @mode: The mode of the new file -* @excl: Force fail if inode exists * * Returns: errno */ static int gfs2_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) { -return gfs2_create_inode (dir, dentry,NULL ,S_IFREG | mode,0 ,NULL ,0 , excl); +return gfs2_create_inode (dir, dentry,NULL ,S_IFREG | mode,0 ,NULL ,0 ,1 ); }/**
fs/hfs/dir.c +1 -1
@@ -190,7 +190,7 @@ static int hfs_dir_release(struct inode *inode, struct file *file)* the directory and the name (and its length) of the new file. */ static int hfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;int res;
fs/hfsplus/dir.c +1 -1
@@ -518,7 +518,7 @@ static int hfsplus_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int hfsplus_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return hfsplus_mknod (&nop_mnt_idmap, dir, dentry, mode,0 ); }
fs/hostfs/hostfs_kern.c +1 -1
@@ -593,7 +593,7 @@ static struct inode *hostfs_iget(struct super_block *sb, char *name) }static int hostfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;char *name;
fs/hpfs/namei.c +1 -1
@@ -129,7 +129,7 @@ static struct dentry *hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int hpfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {const unsigned char *name = dentry->d_name.name;unsigned len = dentry->d_name.len;
fs/hugetlbfs/inode.c +1 -1
@@ -992,7 +992,7 @@ static struct dentry *hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dirstatic int hugetlbfs_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +umode_t mode) {return hugetlbfs_mknod (idmap, dir, dentry, mode |S_IFREG ,0 ); }
fs/jffs2/dir.c +2 -2
@@ -25,7 +25,7 @@static int jffs2_readdir (struct file *,struct dir_context *);static int jffs2_create (struct mnt_idmap *,struct inode *, -struct dentry *,umode_t ,bool ); +struct dentry *,umode_t );static struct dentry *jffs2_lookup (struct inode *,struct dentry *,unsigned int );static int jffs2_link (struct dentry *,struct inode *,struct dentry *);
@@ -161,7 +161,7 @@ static int jffs2_readdir(struct file *file, struct dir_context *ctx)static int jffs2_create (struct mnt_idmap *idmap,struct inode *dir_i, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct jffs2_raw_inode *ri;struct jffs2_inode_info *f, *dir_f;
fs/jfs/namei.c +1 -1
@@ -60,7 +60,7 @@ static inline void free_ea_wmap(struct inode *inode)* */ static int jfs_create (struct mnt_idmap *idmap,struct inode *dip, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {int rc =0 ;tid_t tid;/* transaction id */
fs/minix/namei.c +1 -1
@@ -64,7 +64,7 @@ static int minix_tmpfile(struct mnt_idmap *idmap, struct inode *dir, }static int minix_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return minix_mknod (&nop_mnt_idmap, dir, dentry, mode,0 ); }
fs/namei.c +2 -2
@@ -4129,7 +4129,7 @@ int vfs_create(struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode, error =try_break_deleg (dir, di);if (error)return error; - error = dir->i_op->create (idmap, dir, dentry, mode, true); + error = dir->i_op->create (idmap, dir, dentry, mode);if (!error)fsnotify_create (dir, dentry);return error;
@@ -4438,7 +4438,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, } error = dir_inode->i_op->create (idmap, dir_inode, dentry, - mode, open_flag &O_EXCL ); + mode);if (error) goto out_dput; }
fs/nfs/dir.c +2 -2
@@ -2378,9 +2378,9 @@ static int nfs_do_create(struct inode *dir, struct dentry *dentry, }int nfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) { -return nfs_do_create (dir, dentry, mode, excl ?O_EXCL :0 ); +return nfs_do_create (dir, dentry, mode,O_EXCL ); }EXPORT_SYMBOL_GPL (nfs_create);
fs/nfs/internal.h +1 -1
@@ -398,7 +398,7 @@ extern unsigned long nfs_access_cache_scan(struct shrinker *shrink,struct dentry *nfs_lookup (struct inode *,struct dentry *,unsigned int );void nfs_d_prune_case_insensitive_aliases (struct inode *inode);int nfs_create (struct mnt_idmap *,struct inode *,struct dentry *, -umode_t ,bool ); +umode_t );struct dentry *nfs_mkdir (struct mnt_idmap *,struct inode *,struct dentry *,umode_t );int nfs_rmdir (struct inode *,struct dentry *);
fs/nilfs2/namei.c +1 -1
@@ -86,7 +86,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)* with d_instantiate(). */ static int nilfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;struct nilfs_transaction_info ti;
fs/ntfs3/namei.c +1 -1
@@ -105,7 +105,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,* ntfs_create - inode_operations::create */ static int ntfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ntfs_create_inode (idmap, dir, dentry,NULL ,S_IFREG | mode,0 ,NULL ,0 ,NULL );
fs/ocfs2/dlmfs/dlmfs.c +1 -2
@@ -454,8 +454,7 @@ static struct dentry *dlmfs_mkdir(struct mnt_idmap * idmap,static int dlmfs_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode, -bool excl) +umode_t mode) {int status =0 ;struct inode *inode;
fs/ocfs2/namei.c +1 -2
@@ -666,8 +666,7 @@ static struct dentry *ocfs2_mkdir(struct mnt_idmap *idmap,static int ocfs2_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode, -bool excl) +umode_t mode) {int ret;
fs/omfs/dir.c +1 -1
@@ -286,7 +286,7 @@ static struct dentry *omfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int omfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return omfs_add_node (dir, dentry, mode |S_IFREG ); }
fs/orangefs/namei.c +1 -2
@@ -18,8 +18,7 @@static int orangefs_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode, -bool exclusive) +umode_t mode) {struct orangefs_inode_s *parent =ORANGEFS_I (dir);struct orangefs_kernel_op_s *new_op;
fs/overlayfs/dir.c +1 -1
@@ -713,7 +713,7 @@ static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev, }static int ovl_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ovl_create_object (dentry, (mode &07777 ) |S_IFREG ,0 ,NULL ); }
fs/ramfs/inode.c +1 -1
@@ -129,7 +129,7 @@ static struct dentry *ramfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int ramfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ramfs_mknod (&nop_mnt_idmap, dir, dentry, mode |S_IFREG ,0 ); }
fs/smb/client/cifsfs.h +1 -1
@@ -50,7 +50,7 @@ extern void cifs_sb_deactive(struct super_block *sb);extern const struct inode_operations cifs_dir_inode_ops;extern struct inode *cifs_root_iget (struct super_block *);extern int cifs_create (struct mnt_idmap *,struct inode *, -struct dentry *,umode_t ,bool excl); +struct dentry *,umode_t );extern int cifs_atomic_open (struct inode *,struct dentry *,struct file *,unsigned ,umode_t ); extern struct dentry *cifs_lookup(struct inode *, struct dentry *,
fs/smb/client/dir.c +1 -1
@@ -566,7 +566,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, }int cifs_create (struct mnt_idmap *idmap,struct inode *inode, -struct dentry *direntry,umode_t mode,bool excl) +struct dentry *direntry,umode_t mode) {int rc;unsigned int xid =get_xid ();
fs/ubifs/dir.c +1 -1
@@ -303,7 +303,7 @@ static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry, }static int ubifs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info;
fs/udf/namei.c +1 -1
@@ -371,7 +371,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode) }static int udf_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode =udf_new_inode (dir, mode);
fs/ufs/namei.c +1 -2
@@ -70,8 +70,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, unsi* with d_instantiate(). */ static int ufs_create (struct mnt_idmap * idmap, -struct inode * dir,struct dentry * dentry,umode_t mode, -bool excl) +struct inode * dir,struct dentry * dentry,umode_t mode) {struct inode *inode;
fs/vboxsf/dir.c +2 -2
@@ -298,9 +298,9 @@ static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,static int vboxsf_dir_mkfile (struct mnt_idmap *idmap,struct inode *parent,struct dentry *dentry, -umode_t mode,bool excl) +umode_t mode) { -return vboxsf_dir_create (parent, dentry, mode, false, excl,NULL ); +return vboxsf_dir_create (parent, dentry, mode, false, true,NULL ); } static struct dentry *vboxsf_dir_mkdir(struct mnt_idmap *idmap,
fs/xfs/xfs_iops.c +1 -2
@@ -293,8 +293,7 @@ xfs_vn_create(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, - umode_t mode, - bool flags) + umode_t mode) { return xfs_generic_create(idmap, dir, dentry, mode, 0, NULL); }
include/linux/fs.h +2 -2
@@ -1991,8 +1991,8 @@ struct inode_operations {int (*readlink) (struct dentry *,char __user *,int ); -int (*create) (struct mnt_idmap *,struct inode *,struct dentry *, -umode_t ,bool ); +int (*create) (struct mnt_idmap *,struct inode *,struct dentry *, +umode_t );int (*link) (struct dentry *,struct inode *,struct dentry *);int (*unlink) (struct inode *,struct dentry *); int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,
ipc/mqueue.c +1 -1
@@ -610,7 +610,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg) }static int mqueue_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return mqueue_create_attr (dentry, mode,NULL ); }
mm/shmem.c +1 -1
@@ -3914,7 +3914,7 @@ static struct dentry *shmem_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int shmem_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return shmem_mknod (idmap, dir, dentry, mode |S_IFREG ,0 ); }
---
base-commit: d6ea5537c1a66a54d34f50d51ad201b1a2319ccf
change-id: 20251105-create-excl-2b366d9bf3bb
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 16 lines · Jeff Layton
With three exceptions, ->create() methods provided by filesystems ignore the "excl" flag. Those exception are NFS, GFS2 and vboxsf which all also provide ->atomic_open.
Since
ce8644fcadc5("lookup_open(): expand the call ofvfs_create()"), the "excl" argument to the ->create()inode_operationis always set to true invfs_create(). The ->create() call inlookup_open()sets it according to theO_EXCLopen flag, but is never called if the filesystem provides ->atomic_open().The excl flag is therefore always either ignored or true. Remove it, and change NFS, GFS2 and vboxsf to act as if it were always true.
Reviewed-by Dominique Martinet <[email protected]>Reviewed-by NeilBrown <[email protected]>Signed-off-by Jeff Layton <[email protected]>
Quoted 7 lines
---
I sent this a couple of weeks ago and never got a response from Christian, Al or Jan. This seems like it should be a no-brainer cleanup, and I think theDocumentation/updates will be helpful, so I'm guessing it just slipped through the cracks.A little late at this point for v6.19, so consider for v7.0 ?
Yeah, sorry for that. The patch looks good to me so feel free to add:
Honza
Quoted 817 lines
---
Changes in v3:
- fix use of excl invboxsf_dir_mkfile()
- fix tab prefixes inDocumentation/filesystems/vfs.rst
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- better describe why the argument isn't needed in the changelog
- updates doDocumentation/
- Link to v1: https://lore.kernel.org/r/[email protected]--- Documentation/filesystems/porting.rst | 12 ++++++++++++ Documentation/filesystems/vfs.rst | 13 ++++++++++--- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/affs/affs.h | 2 +- fs/affs/namei.c | 2 +- fs/afs/dir.c | 4 ++-- fs/bad_inode.c | 2 +- fs/bfs/dir.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/dir.c | 2 +- fs/coda/dir.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/efivarfs/inode.c | 2 +- fs/exfat/namei.c | 2 +- fs/ext2/namei.c | 2 +- fs/ext4/namei.c | 2 +- fs/f2fs/namei.c | 2 +- fs/fat/namei_msdos.c | 2 +- fs/fat/namei_vfat.c | 2 +- fs/fuse/dir.c | 2 +- fs/gfs2/inode.c | 5 ++--- fs/hfs/dir.c | 2 +- fs/hfsplus/dir.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/namei.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/dir.c | 4 ++-- fs/jfs/namei.c | 2 +- fs/minix/namei.c | 2 +- fs/namei.c | 4 ++-- fs/nfs/dir.c | 4 ++-- fs/nfs/internal.h | 2 +- fs/nilfs2/namei.c | 2 +- fs/ntfs3/namei.c | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 3 +-- fs/ocfs2/namei.c | 3 +-- fs/omfs/dir.c | 2 +- fs/orangefs/namei.c | 3 +-- fs/overlayfs/dir.c | 2 +- fs/ramfs/inode.c | 2 +- fs/smb/client/cifsfs.h | 2 +- fs/smb/client/dir.c | 2 +- fs/ubifs/dir.c | 2 +- fs/udf/namei.c | 2 +- fs/ufs/namei.c | 3 +-- fs/vboxsf/dir.c | 4 ++-- fs/xfs/xfs_iops.c | 3 +-- include/linux/fs.h | 4 ++-- ipc/mqueue.c | 2 +- mm/shmem.c | 2 +- 51 files changed, 78 insertions(+), 65 deletions(-)Documentation/filesystems/porting.rst +12
-0@@ -1322,3 +1322,15 @@ When vfs_mkdir() returns an error, and so both dputs() the original dentry and doesn't provide a replacement, it also unlocks the parent. Consequently the return value from vfs_mkdir() can be passed to end_creating() and the parent will be unlocked precisely when necessary. + +--- + +**mandatory** + +The ->create() operation has dropped the bool "excl" argument. This operation +should now always provide O_EXCL semantics (i.e. fail with -EEXIST if the file +exists). If the filesystem needs to handle the case where another entity could +create the file on the backing store after a negative lookup or revalidate +(e.g. it's a network filesystem and another client could create the file after +a negative lookup), then it will require ->atomic_open() in addition to +->create().Documentation/filesystems/vfs.rst +10
-3@@ -467,7 +467,7 @@ As of kernel 2.6.22, the following members are defined: .. code-block:: c struct inode_operations { - int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t, bool); + int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t); struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *);@@ -505,7 +505,10 @@ otherwise noted. if you want to support regular files. The dentry you get should not have an inode (i.e. it should be a negative dentry). Here you will probably call d_instantiate() with the dentry and the - newly created inode + newly created inode. This operation should always provide O_EXCL + semantics (i.e. it should fail with -EEXIST if the file exists). + If the filesystem needs to mediate non-exclusive creation, + then the filesystem must also provide an ->atomic_open() operation. ``lookup`` called when the VFS needs to look up an inode in a parent@@ -654,7 +657,11 @@ otherwise noted. handled by f_op->open(). If the file was created, FMODE_CREATED flag should be set in file->f_mode. In case of O_EXCL the method must only succeed if the file didn't exist and hence - FMODE_CREATED shall always be set on success. + FMODE_CREATED shall always be set on success. This method is + usually needed on filesystems where the dentry to be created could + unexpectedly become positive after the kernel has looked it up or + revalidated it. (e.g. another host racing in and creating the file + on an NFS server). ``tmpfile`` called in the end of O_TMPFILE open(). Optional, equivalent tofs/9p/vfs_inode.c +1
-1@@ -643,7 +643,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,static int v9fs_vfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct v9fs_session_info *v9ses =v9fs_inode2v9ses (dir);u32 perm =unixmode2p9mode (v9ses, mode);fs/9p/vfs_inode_dotl.c +1
-1@@ -218,7 +218,7 @@ int v9fs_open_to_dotl_flags(int flags)*/ static int v9fs_vfs_create_dotl (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t omode,bool excl) +struct dentry *dentry,umode_t omode) {return v9fs_vfs_mknod_dotl (idmap, dir, dentry, omode,0 ); }fs/affs/affs.h +1
-1@@ -167,7 +167,7 @@ extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int lextern struct dentry *affs_lookup (struct inode *dir,struct dentry *dentry,unsigned int );extern int affs_unlink (struct inode *dir,struct dentry *dentry);extern int affs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool ); +struct dentry *dentry,umode_t mode);extern struct dentry *affs_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode);extern int affs_rmdir (struct inode *dir,struct dentry *dentry);fs/affs/namei.c +1
-1@@ -243,7 +243,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)int affs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;fs/afs/dir.c +2
-2@@ -32,7 +32,7 @@ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *name, instatic bool afs_lookup_filldir (struct dir_context *ctx,const char *name,int nlen,loff_t fpos,u64 ino,unsigned dtype);static int afs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl); +struct dentry *dentry,umode_t mode);static struct dentry *afs_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode);static int afs_rmdir (struct inode *dir,struct dentry *dentry);@@ -1637,7 +1637,7 @@ static const struct afs_operation_ops afs_create_operation = {* create a regular file on an AFS filesystem */ static int afs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct afs_operation *op;struct afs_vnode *dvnode =AFS_FS_I (dir);fs/bad_inode.c +1
-1@@ -29,7 +29,7 @@ static const struct file_operations bad_file_ops =static int bad_inode_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +umode_t mode) {return -EIO ; }fs/bfs/dir.c +1
-1@@ -76,7 +76,7 @@ const struct file_operations bfs_dir_operations = { };static int bfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {int err;struct inode *inode;fs/btrfs/inode.c +1
-1@@ -6825,7 +6825,7 @@ static int btrfs_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int btrfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;fs/ceph/dir.c +1
-1@@ -976,7 +976,7 @@ static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int ceph_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ceph_mknod (idmap, dir, dentry, mode,0 ); }fs/coda/dir.c +1
-1@@ -134,7 +134,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)/* creation routines: create, mknod, mkdir, link, symlink */ static int coda_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *de,umode_t mode,bool excl) +struct dentry *de,umode_t mode) {int error;const char *name=de->d_name.name;fs/ecryptfs/inode.c +1
-1@@ -268,7 +268,7 @@ int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,static int ecryptfs_create (struct mnt_idmap *idmap,struct inode *directory_inode,struct dentry *ecryptfs_dentry, -umode_t mode,bool excl) +umode_t mode) {struct inode *ecryptfs_inode;int rc;fs/efivarfs/inode.c +1
-1@@ -75,7 +75,7 @@ static bool efivarfs_valid_name(const char *str, int len) }static int efivarfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode =NULL ;struct efivar_entry *var;fs/exfat/namei.c +1
-1@@ -543,7 +543,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, }static int exfat_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;fs/ext2/namei.c +1
-1@@ -101,7 +101,7 @@ struct dentry *ext2_get_parent(struct dentry *child)*/ static int ext2_create (struct mnt_idmap * idmap,struct inode * dir,struct dentry * dentry, -umode_t mode,bool excl) +umode_t mode) {struct inode *inode;int err;fs/ext4/namei.c +1
-1@@ -2806,7 +2806,7 @@ static int ext4_add_nondir(handle_t *handle,* with d_instantiate(). */ static int ext4_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {handle_t *handle;struct inode *inode;fs/f2fs/namei.c +1
-1@@ -351,7 +351,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, }static int f2fs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct inode *inode;fs/fat/namei_msdos.c +1
-1@@ -262,7 +262,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,/***** Create a file */ static int msdos_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode =NULL ;fs/fat/namei_vfat.c +1
-1@@ -754,7 +754,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, }static int vfat_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;fs/fuse/dir.c +1
-1@@ -889,7 +889,7 @@ static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int fuse_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *entry,umode_t mode,bool excl) +struct dentry *entry,umode_t mode) {return fuse_mknod (idmap, dir, entry, mode,0 ); }fs/gfs2/inode.c +2
-3@@ -942,15 +942,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,* @dir: The directory in which to create the file * @dentry: The dentry of the new file * @mode: The mode of the new file -* @excl: Force fail if inode exists * * Returns: errno */ static int gfs2_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) { -return gfs2_create_inode (dir, dentry,NULL ,S_IFREG | mode,0 ,NULL ,0 , excl); +return gfs2_create_inode (dir, dentry,NULL ,S_IFREG | mode,0 ,NULL ,0 ,1 ); }/** fs/hfs/dir.c +1
-1@@ -190,7 +190,7 @@ static int hfs_dir_release(struct inode *inode, struct file *file)* the directory and the name (and its length) of the new file. */ static int hfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;int res;fs/hfsplus/dir.c +1
-1@@ -518,7 +518,7 @@ static int hfsplus_mknod(struct mnt_idmap *idmap, struct inode *dir, }static int hfsplus_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return hfsplus_mknod (&nop_mnt_idmap, dir, dentry, mode,0 ); }fs/hostfs/hostfs_kern.c +1
-1@@ -593,7 +593,7 @@ static struct inode *hostfs_iget(struct super_block *sb, char *name) }static int hostfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;char *name;fs/hpfs/namei.c +1
-1@@ -129,7 +129,7 @@ static struct dentry *hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int hpfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {const unsigned char *name = dentry->d_name.name;unsigned len = dentry->d_name.len;fs/hugetlbfs/inode.c +1
-1@@ -992,7 +992,7 @@ static struct dentry *hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dirstatic int hugetlbfs_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +umode_t mode) {return hugetlbfs_mknod (idmap, dir, dentry, mode |S_IFREG ,0 ); }fs/jffs2/dir.c +2
-2@@ -25,7 +25,7 @@static int jffs2_readdir (struct file *,struct dir_context *);static int jffs2_create (struct mnt_idmap *,struct inode *, -struct dentry *,umode_t ,bool ); +struct dentry *,umode_t );static struct dentry *jffs2_lookup (struct inode *,struct dentry *,unsigned int );static int jffs2_link (struct dentry *,struct inode *,struct dentry *);@@ -161,7 +161,7 @@ static int jffs2_readdir(struct file *file, struct dir_context *ctx)static int jffs2_create (struct mnt_idmap *idmap,struct inode *dir_i, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct jffs2_raw_inode *ri;struct jffs2_inode_info *f, *dir_f;fs/jfs/namei.c +1
-1@@ -60,7 +60,7 @@ static inline void free_ea_wmap(struct inode *inode)* */ static int jfs_create (struct mnt_idmap *idmap,struct inode *dip, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {int rc =0 ;tid_t tid;/* transaction id */ fs/minix/namei.c +1
-1@@ -64,7 +64,7 @@ static int minix_tmpfile(struct mnt_idmap *idmap, struct inode *dir, }static int minix_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return minix_mknod (&nop_mnt_idmap, dir, dentry, mode,0 ); }fs/namei.c +2
-2@@ -4129,7 +4129,7 @@ int vfs_create(struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode, error =try_break_deleg (dir, di);if (error)return error; - error = dir->i_op->create (idmap, dir, dentry, mode, true); + error = dir->i_op->create (idmap, dir, dentry, mode);if (!error)fsnotify_create (dir, dentry);return error;@@ -4438,7 +4438,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, } error = dir_inode->i_op->create (idmap, dir_inode, dentry, - mode, open_flag &O_EXCL ); + mode);if (error) goto out_dput; }fs/nfs/dir.c +2
-2@@ -2378,9 +2378,9 @@ static int nfs_do_create(struct inode *dir, struct dentry *dentry, }int nfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) { -return nfs_do_create (dir, dentry, mode, excl ?O_EXCL :0 ); +return nfs_do_create (dir, dentry, mode,O_EXCL ); }EXPORT_SYMBOL_GPL (nfs_create);fs/nfs/internal.h +1
-1@@ -398,7 +398,7 @@ extern unsigned long nfs_access_cache_scan(struct shrinker *shrink,struct dentry *nfs_lookup (struct inode *,struct dentry *,unsigned int );void nfs_d_prune_case_insensitive_aliases (struct inode *inode);int nfs_create (struct mnt_idmap *,struct inode *,struct dentry *, -umode_t ,bool ); +umode_t );struct dentry *nfs_mkdir (struct mnt_idmap *,struct inode *,struct dentry *,umode_t );int nfs_rmdir (struct inode *,struct dentry *);fs/nilfs2/namei.c +1
-1@@ -86,7 +86,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)* with d_instantiate(). */ static int nilfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;struct nilfs_transaction_info ti;fs/ntfs3/namei.c +1
-1@@ -105,7 +105,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,* ntfs_create - inode_operations::create */ static int ntfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ntfs_create_inode (idmap, dir, dentry,NULL ,S_IFREG | mode,0 ,NULL ,0 ,NULL );fs/ocfs2/dlmfs/dlmfs.c +1
-2@@ -454,8 +454,7 @@ static struct dentry *dlmfs_mkdir(struct mnt_idmap * idmap,static int dlmfs_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode, -bool excl) +umode_t mode) {int status =0 ;struct inode *inode;fs/ocfs2/namei.c +1
-2@@ -666,8 +666,7 @@ static struct dentry *ocfs2_mkdir(struct mnt_idmap *idmap,static int ocfs2_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode, -bool excl) +umode_t mode) {int ret;fs/omfs/dir.c +1
-1@@ -286,7 +286,7 @@ static struct dentry *omfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int omfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return omfs_add_node (dir, dentry, mode |S_IFREG ); }fs/orangefs/namei.c +1
-2@@ -18,8 +18,7 @@static int orangefs_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry, -umode_t mode, -bool exclusive) +umode_t mode) {struct orangefs_inode_s *parent =ORANGEFS_I (dir);struct orangefs_kernel_op_s *new_op;fs/overlayfs/dir.c +1
-1@@ -713,7 +713,7 @@ static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev, }static int ovl_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ovl_create_object (dentry, (mode &07777 ) |S_IFREG ,0 ,NULL ); }fs/ramfs/inode.c +1
-1@@ -129,7 +129,7 @@ static struct dentry *ramfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int ramfs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return ramfs_mknod (&nop_mnt_idmap, dir, dentry, mode |S_IFREG ,0 ); }fs/smb/client/cifsfs.h +1
-1@@ -50,7 +50,7 @@ extern void cifs_sb_deactive(struct super_block *sb);extern const struct inode_operations cifs_dir_inode_ops;extern struct inode *cifs_root_iget (struct super_block *);extern int cifs_create (struct mnt_idmap *,struct inode *, -struct dentry *,umode_t ,bool excl); +struct dentry *,umode_t );extern int cifs_atomic_open (struct inode *,struct dentry *,struct file *,unsigned ,umode_t ); extern struct dentry *cifs_lookup(struct inode *, struct dentry *,fs/smb/client/dir.c +1
-1@@ -566,7 +566,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, }int cifs_create (struct mnt_idmap *idmap,struct inode *inode, -struct dentry *direntry,umode_t mode,bool excl) +struct dentry *direntry,umode_t mode) {int rc;unsigned int xid =get_xid ();fs/ubifs/dir.c +1
-1@@ -303,7 +303,7 @@ static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry, }static int ubifs_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info;fs/udf/namei.c +1
-1@@ -371,7 +371,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode) }static int udf_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {struct inode *inode =udf_new_inode (dir, mode);fs/ufs/namei.c +1
-2@@ -70,8 +70,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, unsi* with d_instantiate(). */ static int ufs_create (struct mnt_idmap * idmap, -struct inode * dir,struct dentry * dentry,umode_t mode, -bool excl) +struct inode * dir,struct dentry * dentry,umode_t mode) {struct inode *inode;fs/vboxsf/dir.c +2
-2@@ -298,9 +298,9 @@ static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,static int vboxsf_dir_mkfile (struct mnt_idmap *idmap,struct inode *parent,struct dentry *dentry, -umode_t mode,bool excl) +umode_t mode) { -return vboxsf_dir_create (parent, dentry, mode, false, excl,NULL ); +return vboxsf_dir_create (parent, dentry, mode, false, true,NULL ); } static struct dentry *vboxsf_dir_mkdir(struct mnt_idmap *idmap,fs/xfs/xfs_iops.c +1
-2@@ -293,8 +293,7 @@ xfs_vn_create(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, - umode_t mode, - bool flags) + umode_t mode) { return xfs_generic_create(idmap, dir, dentry, mode, 0, NULL); }include/linux/fs.h +2
-2@@ -1991,8 +1991,8 @@ struct inode_operations {int (*readlink) (struct dentry *,char __user *,int ); -int (*create) (struct mnt_idmap *,struct inode *,struct dentry *, -umode_t ,bool ); +int (*create) (struct mnt_idmap *,struct inode *,struct dentry *, +umode_t );int (*link) (struct dentry *,struct inode *,struct dentry *);int (*unlink) (struct inode *,struct dentry *); int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,ipc/mqueue.c +1
-1@@ -610,7 +610,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg) }static int mqueue_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return mqueue_create_attr (dentry, mode,NULL ); }mm/shmem.c +1
-2@@ -3914,7 +3914,7 @@ static struct dentry *shmem_mkdir(struct mnt_idmap *idmap, struct inode *dir, }static int shmem_create (struct mnt_idmap *idmap,struct inode *dir, -struct dentry *dentry,umode_t mode,bool excl) +struct dentry *dentry,umode_t mode) {return shmem_mknod (idmap, dir, dentry, mode |S_IFREG ,0 ); } ---base-commit:
d6ea5537c1a66a54d34f50d51ad201b1a2319ccf
change-id: 20251105-create-excl-2b366d9bf3bbBest regards,
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 11 lines · Jeff Layton
With three exceptions, ->create() methods provided by filesystems ignore the "excl" flag. Those exception are NFS, GFS2 and vboxsf which all also provide ->atomic_open.
Since
ce8644fcadc5("lookup_open(): expand the call ofvfs_create()"), the "excl" argument to the ->create()inode_operationis always set to true invfs_create(). The ->create() call inlookup_open()sets it according to theO_EXCLopen flag, but is never called if the filesystem provides ->atomic_open().[...]
Applied to the vfs-6.20.mkdir branch of the vfs/vfs.git tree. Patches in the vfs-6.20.mkdir branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-6.20.mkdir
[1/1] vfs: remove the excl argument from the ->create() inode_operation
https://git.kernel.org/vfs/vfs/c/7d91315b4335