From: NeilBrown <neilb@ownmail.net>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: [PATCH 2/7] vfs: O_NONBLOCK|O_CREAT open shouldn't wait for directory delegation
Date: Thu, 10 Sep 2026 10:20:48 +1000 [thread overview]
Message-ID: <20260910002934.192979-3-neilb@ownmail.net> (raw)
In-Reply-To: <20260910002934.192979-1-neilb@ownmail.net>
From: NeilBrown <neil@brown.name>
An open() of a regular file can block if there is an active lease on that
file, but this can be prevented by opening with O_NONBLOCK.
An open(O_CREAT) of a non-existent file can block if there is an active
delegation on the parent directory but this CANNOT be prevented with
O_NONBLOCK.
If nfsd is to use common VFS code for open/create it needs to be able to
prevent this blocking. It is conceivable that a user-space application
might need this too.
So extend O_NONBLOCK protection to not block on a directory delegation
when creating a file.
Fixes: 134796f43a5e ("vfs: break parent dir delegations in open(..., O_CREAT) codepath")
Signed-off-by: NeilBrown <neil@brown.name>
---
fs/namei.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/namei.c b/fs/namei.c
index c9ac703110f8..c4be59213352 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4554,7 +4554,12 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
goto out_dput;
}
- error = try_break_deleg(dir_inode, LEASE_BREAK_DIR_CREATE, &delegated_inode);
+ if (op->open_flag & O_NONBLOCK)
+ error = try_break_deleg(dir_inode, LEASE_BREAK_DIR_CREATE,
+ NULL);
+ else
+ error = try_break_deleg(dir_inode, LEASE_BREAK_DIR_CREATE,
+ &delegated_inode);
if (error)
goto out_dput;
--
2.50.0.107.gf914562f5916.dirty
next prev parent reply other threads:[~2026-09-10 0:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 0:20 [PATCH 0/7 RFC] fixes for vfs_lookup_open, and integration with nfsd NeilBrown
2026-09-10 0:20 ` [PATCH 1/7] vfs: add some allowed open flags to vfs_lookup_open() NeilBrown
2026-09-10 0:20 ` NeilBrown [this message]
2026-09-10 0:20 ` [PATCH 3/7] vfs: vfs_lookup_open() should only return -EFTYPE for non-regular files NeilBrown
2026-09-10 0:20 ` [PATCH 4/7] vfs: change vfs_lookup_open() to return found dentry in path.dentry NeilBrown
2026-09-10 0:39 ` NeilBrown
2026-09-10 15:13 ` Chuck Lever
2026-09-12 2:59 ` NeilBrown
2026-09-13 15:15 ` Mateusz Guzik
2026-09-13 21:09 ` NeilBrown
2026-09-10 0:20 ` [PATCH 5/7] nfsd: switch NFS4 OPEN to use vfs_lookup_open() NeilBrown
2026-09-10 15:41 ` Chuck Lever
2026-09-12 3:22 ` NeilBrown
2026-09-10 0:20 ` [PATCH 6/7] nfsd: nfsd_check_obj_isreg() to use nfs error codes NeilBrown
2026-09-10 0:20 ` [PATCH 7/7] nfsd: use vfs_lookup_open() for non-creating open requests too NeilBrown
2026-09-10 15:47 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260910002934.192979-3-neilb@ownmail.net \
--to=neilb@ownmail.net \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox