mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
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>
This commit is contained in:
parent
24f3a09163
commit
4d315e54aa
|
|
@ -4513,6 +4513,11 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user