[PATCH 05/10] vfs: lookup_open(): use vfs_create_no_perm()

From: Jori Koolstra

Date: Sun Jul 12 2026 - 13:56:05 EST


We can replace the code in the no create_error/negative dentry found
from lookup case in lookup_open() with the vfs_create_no_perm() helper.

It is safe here to always pass excl=true to ->create via
vfs_create_no_perm(). Local filesystems always ignore the excl flag,
and cluster filesystems implement ->atomic_open, so that the ->create
call is never reached in lookup_open().

Reviewed-by: NeilBrown <neil@xxxxxxxxxx>
Signed-off-by: Jori Koolstra <jkoolstra@xxxxxxxxx>
---
fs/namei.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index aaba03954cd5..91e01c9794af 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4525,19 +4525,12 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
goto out_dput;
}

- /* but break the directory lease first! */
- error = try_break_deleg(dir_inode, LEASE_BREAK_DIR_CREATE, delegated_inode);
- if (error)
- goto out_dput;
-
audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE);

- error = dir_inode->i_op->create(idmap, dir_inode, dentry,
- mode, open_flag & O_EXCL);
+ error = vfs_create_no_perm(idmap, dentry, mode, delegated_inode);
if (error)
goto out_dput;

- fsnotify_create(dir_inode, dentry);
file->f_mode |= FMODE_CREATED;
}
if (unlikely(create_error) && !dentry->d_inode) {
--
2.55.0