mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 14:04:27 -04:00
fs/namei.c: update stale comments in lookup_open()
Commitddb6e6c72a("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:ddb6e6c72a("VFS: move mnt_want_write() and locking into lookup_open()") Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
20
fs/namei.c
20
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 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user