From: Benjamin Coddington <bcodding@hammerspace.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Chuck Lever <chuck.lever@oracle.com>,
Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Trond Myklebust <trondmy@kernel.org>,
Mike Snitzer <snitzer@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nfs@vger.kernel.org
Subject: [PATCH v3 0/3] Allow knfsd to use atomic_open()
Date: Wed, 26 Nov 2025 09:31:33 -0500 [thread overview]
Message-ID: <cover.1764167204.git.bcodding@hammerspace.com> (raw)
We have workloads that will benefit from allowing knfsd to use atomic_open()
in the open/create path. There are two benefits; the first is the original
matter of correctness: when knfsd must perform both vfs_create() and
vfs_open() in series there can be races or error results that cause the
caller to receive unexpected results. The second benefit is that for some
network filesystems, we can reduce the number of remote round-trip
operations by using a single atomic_open() path which provides a performance
benefit.
I've implemented this with the simplest possible change - by modifying
dentry_create() which has a single user: knfsd. The changes cause us to
insert ourselves part-way into the previously closed/static atomic_open()
path, so I expect VFS folks to have some good ideas about potentially
superior approaches.
Previous work on commit fb70bf124b05 ("NFSD: Instantiate a struct file when
creating a regular NFSv4 file") addressed most of the atomicity issues, but
there are still a few gaps on network filesystems.
The problem was noticed on a test that did open O_CREAT with mode 0 which
will succeed in creating the file but will return -EACCES from vfs_open() -
this specific test is mentioned in 3/3 description.
Also, Trond notes that independently of the permissions issues, atomic_open
also solves races in open(O_CREAT|O_TRUNC). The NFS client now uses it for
both NFSv4 and NFSv3 for that reason. See commit 7c6c5249f061 "NFS: add
atomic_open for NFSv3 to handle O_TRUNC correctly."
Changes on v3:
- rebased onto v6.18-rc7
- R-b on 3/3 thanks to Chuck Lever
Changes on v2:
- R-b thanks to Jeff Layton
- improvements to patch descriptions thanks to Chuck Lever, Neil
Brown, and Trond Myklebust
- improvements to dentry_create()'s doc comment to clarify dentry
handling thanks to Mike Snitzer
Thanks for any additional comment and critique.
Benjamin Coddington (3):
VFS: move dentry_create() from fs/open.c to fs/namei.c
VFS: Prepare atomic_open() for dentry_create()
VFS/knfsd: Teach dentry_create() to use atomic_open()
fs/namei.c | 86 ++++++++++++++++++++++++++++++++++++++++++----
fs/nfsd/nfs4proc.c | 8 +++--
fs/open.c | 41 ----------------------
include/linux/fs.h | 2 +-
4 files changed, 85 insertions(+), 52 deletions(-)
--
2.50.1
next reply other threads:[~2025-11-26 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 14:31 Benjamin Coddington [this message]
2025-11-26 14:31 ` [PATCH v3 1/3] VFS: move dentry_create() from fs/open.c to fs/namei.c Benjamin Coddington
2025-11-26 14:31 ` [PATCH v3 2/3] VFS: Prepare atomic_open() for dentry_create() Benjamin Coddington
2025-11-26 14:31 ` [PATCH v3 3/3] VFS/knfsd: Teach dentry_create() to use atomic_open() Benjamin Coddington
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=cover.1764167204.git.bcodding@hammerspace.com \
--to=bcodding@hammerspace.com \
--cc=Dai.Ngo@oracle.com \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=snitzer@kernel.org \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).