From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neil@brown.name>
Cc: Chuck Lever <chuck.lever@oracle.com>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH v2 06/14] nfsd: in nfsd4_create_file() let VFS report if file was created.
Date: Tue, 07 Jul 2026 07:13:44 -0400 [thread overview]
Message-ID: <817fa5902f35305b2c4f38b11379dbf6eade49c6.camel@kernel.org> (raw)
In-Reply-To: <178338050586.27465.16700298229223579148@noble.neil.brown.name>
On Tue, 2026-07-07 at 09:28 +1000, NeilBrown wrote:
> On Tue, 07 Jul 2026, Jeff Layton wrote:
> > On Mon, 2026-07-06 at 08:19 +1000, NeilBrown wrote:
> > > From: NeilBrown <neil@brown.name>
> > >
> > > nfsd4_create_file() currently assumes that if a lookup failed but then a
> > > create succeeds, then the "create" operation actually created the file.
> > > With atomic_open this may not be the case - some other actor might have
> > > created the file between the lookup and the create.
> > >
> > > So we move the call to nfsd4_vfs_create() earlier and set ->op_created
> > > based on the FMODE_CREATED flag that it set. Then use "! ->op_created"
> > > to trigger nfserr_exist handling.
> > >
> > > The switch statement is split up into two if() statements.
> > > First we check for the possibility of a successful exclusive
> > > create and set ->op_create to true if appropriate.
> > > Then we check for NFS4_CREATE_UNCHECKED to decide if a
> > > pre-existing file means an error or success.
> > >
> > > This allows us to combine the two fh_compose() calls to one place.
> > >
> > > A subtle difference here is that we now must only pass O_EXCL to
> > > dentry_create() for NFS4_CREATE_GUARDED. For the EXCLUSIVE create modes
> > > we want a successful open even if the file already exists. We then
> > > check the verifier after the open succeeded to see if it was exclusive.
> > >
> >
> > Do we really want a successful open in the EXCLUSIVE cases?
> >
> > Opens have side effects (notably, that they can cause delegation
> > recalls). If you have two racing clients creating a file, the first
> > gets an open and write delegation and then the second ends up
> > immediately causing a delegrecall for the first, even though it may
> > never touch the file again after the OPEN fails.
> >
> > I think we may want to reconsider that logic, if possible: Maybe we
> > should keep using O_EXCL in those cases and just re-drive the open
> > without it if it fails and the verifier looks right? That's a bit
> > uglier, but that may cause fewer delegation recalls.
>
> Thanks for raising this. My thinking was that next EXCLUSIVE creates
> was weird.
> If the server is re-exporting NFS, then think about what happens to the
> verifier stored on the backend server.
> First the verifier from the intermediate server is stored,
> then the nfs client on the intermediate server sends a SETATTR to remove it,
> then the intermediate server sets the verifier from the originating
> client.
> then the originating client removes it.
>
> So 4 setattrs altogether.
>
> Also if the intermediate server ever gets a retransmit of the OPEN
> request, it will send an EXCLUSIVE open to the backend server which will
> fail even if the verifier is still correct.
>
> I agree that recalling a delegation needlessly is not good, but will it
> happen often? If the app checks for then name before trying the O_EXCL
> open, then the delegation would not get recalled because the OPEN
> wouldn't be tried. I wonder how often that happens....
>
> I think setting O_EXCL in the NFS4_CREATE_GUARDED case is important.
> I'm open to discussion around the issues with O_EXCL and the
> NFS4_CREATE_EXCLUSIVE case.
>
> Maybe doing a lookup first when the exported fs is NFS would be an OK
> compromise.
>
I guess it shouldn't happen often, since we do check
d_really_is_negative() prior to calling nfsd4_vfs_create(). Given that,
let's go with the scheme you've got here. We can always revisit it if
this turns out to be more of an issue.
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2026-07-07 11:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-05 22:19 [PATCH v2 00/14] nfsd: refactor nfs4_create_file() NeilBrown
2026-07-05 22:19 ` [PATCH v2 01/14] nfsd: honour client-provided attributes for NFS4_CREATE_EXCLUSIVE4_1 NeilBrown
2026-07-06 16:14 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 02/14] nfsd: replace fh_fill_both_attrs() with fh_fill_post_noop() NeilBrown
2026-07-06 16:15 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 03/14] nfsd: move fh_want_write() after preamble in nfsd4_create_file() NeilBrown
2026-07-06 16:15 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 04/14] nfsd: move more nfs-specific code into preamble of nfsd4_create_file() NeilBrown
2026-07-06 16:16 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 05/14] nfsd: remove subtlety from nfsd4_create_file() NeilBrown
2026-07-06 16:16 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 06/14] nfsd: in nfsd4_create_file() let VFS report if file was created NeilBrown
2026-07-06 15:52 ` Jeff Layton
2026-07-06 23:28 ` NeilBrown
2026-07-07 11:13 ` Jeff Layton [this message]
2026-07-05 22:19 ` [PATCH v2 07/14] nfsd: nfsd4_create_file(): Move NFSD_MAY_CREATE check earlier NeilBrown
2026-07-06 16:19 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 08/14] nfsd: always open file in nfsd4_create_file() NeilBrown
2026-07-05 22:19 ` [PATCH v2 09/14] nfsd: reduce range of directory lock " NeilBrown
2026-07-06 16:21 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 10/14] nfsd: open-code nfsd4_vfs_create() into nfsd4_create_file() NeilBrown
2026-07-06 16:21 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 11/14] nfsd: move some code out of the d_really_is_negative() branch in nfsd4_create_file() NeilBrown
2026-07-06 16:23 ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 12/14] nfsd: reduce want-write range " NeilBrown
2026-07-05 22:19 ` [PATCH v2 13/14] nfsd: separate out VFS-specific from from nfsd4_create_file() NeilBrown
2026-07-06 16:00 ` Jeff Layton
2026-07-06 23:29 ` NeilBrown
2026-07-05 22:19 ` [PATCH v2 14/14] nfsd: use do_lookup_open() for non-creating open requests too NeilBrown
2026-07-06 14:36 ` 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=817fa5902f35305b2c4f38b11379dbf6eade49c6.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/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