Skip to content

Commit 3641155

Browse files
Benjamin Coddingtonbrauner
authored andcommitted
VFS: Prepare atomic_open() for dentry_create()
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>
1 parent 977de00 commit 3641155

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

fs/namei.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,19 +4279,16 @@ static int may_o_create(struct mnt_idmap *idmap,
42794279
*
42804280
* Returns an error code otherwise.
42814281
*/
4282-
static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry,
4282+
static struct dentry *atomic_open(const struct path *path, struct dentry *dentry,
42834283
struct file *file,
42844284
int open_flag, umode_t mode)
42854285
{
42864286
struct dentry *const DENTRY_NOT_SET = (void *) -1UL;
4287-
struct inode *dir = nd->path.dentry->d_inode;
4287+
struct inode *dir = path->dentry->d_inode;
42884288
int error;
42894289

4290-
if (nd->flags & LOOKUP_DIRECTORY)
4291-
open_flag |= O_DIRECTORY;
4292-
42934290
file->__f_path.dentry = DENTRY_NOT_SET;
4294-
file->__f_path.mnt = nd->path.mnt;
4291+
file->__f_path.mnt = path->mnt;
42954292
error = dir->i_op->atomic_open(dir, dentry, file,
42964293
open_to_namei_flags(open_flag), mode);
42974294
d_lookup_done(dentry);
@@ -4403,7 +4400,9 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
44034400
if (create_error)
44044401
open_flag &= ~O_CREAT;
44054402
if (dir_inode->i_op->atomic_open) {
4406-
dentry = atomic_open(nd, dentry, file, open_flag, mode);
4403+
if (nd->flags & LOOKUP_DIRECTORY)
4404+
open_flag |= O_DIRECTORY;
4405+
dentry = atomic_open(&nd->path, dentry, file, open_flag, mode);
44074406
if (unlikely(create_error) && dentry == ERR_PTR(-ENOENT))
44084407
dentry = ERR_PTR(create_error);
44094408
return dentry;

0 commit comments

Comments
 (0)