diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-07-31 10:36:05 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-07-31 10:37:40 +0200 |
| commit | aa00a8fd9d4cbd863b9a85a464849b279a7674b1 (patch) | |
| tree | 1875c672ebd6a40f08517fad122800bd2f607519 | |
| parent | b2f1e6301efa4a80becdb0715416c3cbc693fbb4 (diff) | |
| download | linux-stable-aa00a8fd9d4cbd863b9a85a464849b279a7674b1.tar.gz linux-stable-aa00a8fd9d4cbd863b9a85a464849b279a7674b1.zip | |
fs/namei.c: update stale comments in lookup_open()
Commit ddb6e6c72a0a ("VFS: move mnt_want_write() and locking into
lookup_open()") moved the parent inode locking into lookup_open(), but
left the comment claiming the caller has to take it. A caller following
that comment now deadlocks, and the series added a second caller.
Describe what the function actually does. While at it drop the claim
that it returns 0 on success and updates @path, wrong ever since
lookup_open() started returning a dentry in v5.7, and fix the reference
to lookup_open() in a comment that now sits inside lookup_open() itself.
Link: https://patch.msgid.link/20260731-work-lookup-fixes-v1-1-2412b85cf65c@kernel.org
Fixes: ddb6e6c72a0a ("VFS: move mnt_want_write() and locking into lookup_open()")
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
| -rw-r--r-- | fs/namei.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/namei.c b/fs/namei.c index 6db5b7e8547b..226abf613983 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4417,17 +4417,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 +4451,7 @@ retry: 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) |
