]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
VFS: Prepare atomic_open() for dentry_create()
authorBenjamin Coddington <bcodding@hammerspace.com>
Thu, 27 Nov 2025 16:02:04 +0000 (11:02 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 15 Dec 2025 13:12:45 +0000 (14:12 +0100)
The next patch allows dentry_create() to call atomic_open(), but it does
not have fabricated nameidata.  Let atomic_open() take a path instead.

Since atomic_open() currently takes a nameidata of which it only uses the
path and the flags, and flags are only used to update open_flags, then the
flag update can happen before calling atomic_open(). Then, only the path
needs be passed to atomic_open() rather than the whole nameidata.  This
makes it easier for dentry_create() To call atomic_open().

Signed-off-by: Benjamin Coddington <bcodding@hammerspace.com>
Link: https://patch.msgid.link/e8c1d2ca28de4a972d37e78599502108148fe17d.1764259052.git.bcodding@hammerspace.com
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namei.c

index 1f21cd85300cc885f60b8c3c10275536b4262a2a..761257e3da2cabcf7ee333dc18c1305a1caab8bb 100644 (file)
@@ -4279,19 +4279,16 @@ static int may_o_create(struct mnt_idmap *idmap,
  *
  * Returns an error code otherwise.
  */
-static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry,
+static struct dentry *atomic_open(const struct path *path, struct dentry *dentry,
                                  struct file *file,
                                  int open_flag, umode_t mode)
 {
        struct dentry *const DENTRY_NOT_SET = (void *) -1UL;
-       struct inode *dir =  nd->path.dentry->d_inode;
+       struct inode *dir =  path->dentry->d_inode;
        int error;
 
-       if (nd->flags & LOOKUP_DIRECTORY)
-               open_flag |= O_DIRECTORY;
-
        file->__f_path.dentry = DENTRY_NOT_SET;
-       file->__f_path.mnt = nd->path.mnt;
+       file->__f_path.mnt = path->mnt;
        error = dir->i_op->atomic_open(dir, dentry, file,
                                       open_to_namei_flags(open_flag), mode);
        d_lookup_done(dentry);
@@ -4403,7 +4400,9 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
        if (create_error)
                open_flag &= ~O_CREAT;
        if (dir_inode->i_op->atomic_open) {
-               dentry = atomic_open(nd, dentry, file, open_flag, mode);
+               if (nd->flags & LOOKUP_DIRECTORY)
+                       open_flag |= O_DIRECTORY;
+               dentry = atomic_open(&nd->path, dentry, file, open_flag, mode);
                if (unlikely(create_error) && dentry == ERR_PTR(-ENOENT))
                        dentry = ERR_PTR(create_error);
                return dentry;