diff options
| author | Jori Koolstra <jkoolstra@xs4all.nl> | 2026-07-10 18:42:31 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-07-30 12:16:55 +0200 |
| commit | 4d315e54aa898ea491ce2fe72ee482f74b7ba84a (patch) | |
| tree | b166aa79edd59e2baa857941be450b60f7c16e35 | |
| parent | 24f3a09163caad1dde3f801f1bafc69f1991a357 (diff) | |
vfs: move create error && negative dentry case in lookup_open() up
O_CREAT is stripped when create_error is set in lookup_open(), so when
lookup does not return an inode, the case
if (!dentry->d_inode && (open_flag & O_CREAT))
is always skipped. We can get rid of this cognitive step by handling the
error case first.
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Link: https://patch.msgid.link/20260710164233.827744-2-jkoolstra@xs4all.nl
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
| -rw-r--r-- | fs/namei.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c index 3ca34388eda3..62f1b8600ec1 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4513,6 +4513,11 @@ retry: } } + if (unlikely(create_error) && !dentry->d_inode) { + error = create_error; + goto out_dput; + } + /* Negative dentry, just create the file */ if (!dentry->d_inode && (open_flag & O_CREAT)) { /* but break the directory lease first! */ @@ -4532,10 +4537,6 @@ retry: if (error) goto out_dput; } - if (unlikely(create_error) && !dentry->d_inode) { - error = create_error; - goto out_dput; - } out: if (!IS_ERR(dentry)) { if (file->f_mode & FMODE_CREATED) |
