Merge patch series "fs/namei.c: comment and coding style fixups"

Christian Brauner <brauner@kernel.org> says:

Three comment and coding style fixups for your lookup_open() rework and
Jori's audit series as they sit in vfs-7.3.lookup. No functional changes.

* Update the comments above lookup_open(). It takes the parent inode lock
  itself now but the comment still tells the caller to take it. A caller
  following it deadlocks and the series added a second caller. The claim
  that it returns 0 and updates @path goes as well, that one has been
  wrong since v5.7.

* Give the return description of atomic_open() the colon that kernel-doc
  needs. Without it the description is dropped and W=1 warns about it.
  The summary line has to stand on its own line too, so the "from a
  negative dentry" part moves into the body.

* Fix a space indented continuation line, three declarations without a
  following blank line and a trailing */ on the last line of a block
  comment.

* patches from https://patch.msgid.link/20260731-work-lookup-fixes-v1-0-2412b85cf65c@kernel.org:
  fs/namei.c: fix coding style in atomic_open() and lookup_open()
  fs/namei.c: fix kerneldoc of atomic_open() and vfs_lookup_open()
  fs/namei.c: update stale comments in lookup_open()

Link: https://patch.msgid.link/20260731-work-lookup-fixes-v1-0-2412b85cf65c@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
Christian Brauner
2026-07-31 10:37:40 +02:00

View File

@@ -4337,8 +4337,7 @@ static int may_o_create(struct mnt_idmap *idmap,
}
/**
* atomic_open() - attempt to atomically look up, create and open a file
* from a negative dentry.
* atomic_open() - atomically look up, create and open a file
* @path: parent directory path
* @dentry: child to ->atomic_open()
* @file: file to attach child to
@@ -4346,6 +4345,9 @@ static int may_o_create(struct mnt_idmap *idmap,
* @mode: create mode
* @create_error: return value from may_o_create()
*
* Attempt to look up, create and open @dentry, which must be negative, in a
* single call into the filesystem.
*
* If a non-error dentry is returned then: when FMODE_OPENED is set,
* the file will have been attached to @file by the filesystem calling
* finish_open(). If FMODE_OPENED isn't set, the filesystem instead called
@@ -4354,8 +4356,8 @@ static int may_o_create(struct mnt_idmap *idmap,
* FMODE_CREATED is set when the call to ->atomic_open() actually created
* the file.
*
* Returns the opened/looked-up dentry on success or ERR_PTR(-E) on failure.
* On error, atomic_open() consumes @dentry.
* Returns: the opened or looked-up dentry, or ERR_PTR() on failure. The
* reference to @dentry is consumed in either case.
*/
static struct dentry *atomic_open(const struct path *path, struct dentry *dentry,
struct file *file,
@@ -4375,6 +4377,7 @@ static struct dentry *atomic_open(const struct path *path, struct dentry *dentry
if (file->f_mode & FMODE_OPENED) {
/* finish_open() called */
struct dentry *opened = file->f_path.dentry;
if (unlikely(opened != dentry)) {
dput(dentry);
dentry = dget(opened);
@@ -4382,6 +4385,7 @@ static struct dentry *atomic_open(const struct path *path, struct dentry *dentry
} else if (likely(file->f_path.dentry != DENTRY_NOT_SET)) {
/* finish_no_open() called */
struct dentry *replaced = file->f_path.dentry;
if (replaced) {
dput(dentry);
dentry = replaced;
@@ -4390,8 +4394,9 @@ static struct dentry *atomic_open(const struct path *path, struct dentry *dentry
error = -ENOENT;
} else {
const char *fsname = dentry->d_sb->s_type->name;
WARN(1, "%s: ->atomic_open() left file->f_path.dentry unset!\n",
fsname);
fsname);
error = -EIO;
}
}
@@ -4417,17 +4422,16 @@ static struct dentry *atomic_open(const struct path *path, struct dentry *dentry
/*
* Look up and maybe create and open the last component.
*
* Must be called with parent locked (exclusive in O_CREAT case).
* Takes the parent inode lock itself, exclusive if O_CREAT was requested and
* shared otherwise, and drops it again before returning. The caller must not
* hold it.
*
* Returns 0 on success, that is, if
* the file was successfully atomically created (if necessary) and opened, or
* the file was not completely opened at this time, though lookups and
* creations were performed.
* These case are distinguished by presence of FMODE_OPENED on file->f_mode.
* In the latter case dentry returned in @path might be negative if O_CREAT
* hadn't been specified.
* On success returns the dentry of the last component. If FMODE_OPENED is set
* on file->f_mode the file was also opened and attached to @file; otherwise
* only lookup and creation were performed and the caller has to open it. In
* the latter case the dentry may be negative if O_CREAT hadn't been specified.
*
* An error code is returned on failure.
* Returns ERR_PTR() on failure.
*/
static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
const struct open_flags *op)
@@ -4452,8 +4456,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
got_write = !mnt_want_write(nd->path.mnt);
/*
* do _not_ fail yet - we might not need that or fail with
* a different error; let lookup_open() decide; we'll be
* dropping this one anyway.
* a different error; we'll be dropping this one anyway.
*/
}
if (open_flag & O_CREAT)
@@ -4540,8 +4543,10 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
}
}
if (dentry->d_inode || !(op->open_flag & O_CREAT)) {
/* No need to create a file. If lookup returned a positive
* dentry, the file will be opened in do_open(). */
/*
* No need to create a file. If lookup returned a positive
* dentry, the file will be opened in do_open().
*/
goto out;
}
@@ -4607,7 +4612,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
* @mode: initial permissions for file
*
* Open a file after lookup and/or create. This provides similar
* functionality open_last_lookups() for non-VFS users, particularly
* functionality to open_last_lookups() for non-VFS users, particularly
* nfsd.
* It uses ->atomic_open or ->lookup / ->create / ->open as appropriate.
*