mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "John Stoffel" <john@stoffel.org>
To: NeilBrown <neil@brown.name>
Cc: "John Stoffel" <john@stoffel.org>,
	"Trond Myklebust" <trondmy@kernel.org>,
	"Anna Schumaker" <anna@kernel.org>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Jeff Layton" <jlayton@kernel.org>, "Jan Kara" <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/9] nfs: remove d_drop()/d_alloc_parallel() from nfs_atomic_open()
Date: Thu, 1 Oct 2026 15:43:35 -0400	[thread overview]
Message-ID: <27326.47079.315579.582391@quad.stoffel.home> (raw)
In-Reply-To: <179080305245.37859.18267888595495397553@noble.neil.brown.name>

>>>>> "NeilBrown" == NeilBrown  <neilb@ownmail.net> writes:

> On Thu, 01 Oct 2026, John Stoffel wrote:
>> >>>>> "NeilBrown" == NeilBrown  <neilb@ownmail.net> writes:
>> 
>> > From: NeilBrown <neil@brown.name>
>> > It is important that two non-create NFS "open"s of a negative dentry
>> > don't race.  They both have only a shared lock on i_rwsem and so could
>> > run concurrently, but they might both try to call d_splice_alias() at
>> > the same time which is confusing at best.
>> 
>> > nfs_atomic_open() currently avoids this by discarding the negative
>> > dentry and creating a new one using d_alloc_parallel().  Only one thread
>> > can successfully get the d_in_lookup() dentry, the other will wait for
>> > the first to finish, and can use the result of that first lookup.
>> 
>> This paragraph is confusing, and I'm not sure which thread can use the
>> result of the first lookup from this description.  

> Unfortunately it isn't clear to me what it is that isn't clear to you
> :-)

Sorry!  I wasn't clear, probably because I'm not great at the VFS
stuff and was just reacting more to my parsing of the language.  It's
probably not a big deal honestly.  

> When O_CREAT is not requested, calls to ->atomic_open are protected only
> by a shared lock on the parent so if the dcache contains a negative
> dentry for a given name then two ->atomic_open calls on that name can
> happen concurrently.  That can be a problem as they both might try to
> instantiate the dentry with an inode, and the second to do that will
> trigger a BUG.

> This is fixed by discarding (d_drop()) the dentry and using
> d_alloc_parallel() to allocate a new dentry.  d_alloc_parallel()
> effects a lock.  Only one thread will get an in_lookup dentry.  The
> other will block until the dentry has been instantiated, and will then
> be given the non-in_lookup dentry.

> The current code does all this in nfs_atomic_open().  The new code does
> the d_drop and the d_alloc_parallel() in VFS code were I can manage the
> locking rules more easily.

> I thought that is what I said above - though more briefly of course.  If
> you can point me more precisely to what is not clear in the original, I
> can try to improve it.

> Thanks,
> NeilBrown


  reply	other threads:[~2026-10-01 19:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29  2:21 [PATCH v2 0/9] nfs: prepare for VFS locking changes NeilBrown
2026-09-29  2:21 ` [PATCH v2 1/9] nfs: fix open-blocking with d_fsdata NeilBrown
2026-09-29  2:21 ` [PATCH v2 2/9] nfs: fix nfs_call_unlink() NeilBrown
2026-09-29  2:21 ` [PATCH v2 3/9] nfs: remove d_drop()/d_alloc_parallel() from nfs_atomic_open() NeilBrown
2026-09-30 14:32   ` John Stoffel
2026-09-30 21:17     ` NeilBrown
2026-10-01 19:43       ` John Stoffel [this message]
2026-09-29  2:21 ` [PATCH v2 4/9] nfs: use d_splice_alias() in nfs_link() NeilBrown
2026-09-29  2:21 ` [PATCH v2 5/9] nfs: don't d_drop() before d_splice_alias() NeilBrown
2026-09-29  2:21 ` [PATCH v2 6/9] nfs: don't d_drop() before d_splice_alias() in atomic_create NeilBrown
2026-09-29  2:21 ` [PATCH v2 7/9] nfs: Use d_alloc_trylock() in nfs_prime_dcache() NeilBrown
2026-09-29  2:21 ` [PATCH v2 8/9] nfs: use d_alloc_trylock() in silly-rename NeilBrown
2026-09-29  2:21 ` [PATCH v2 9/9] nfs: use d_duplicate() NeilBrown
2026-09-29 21:24 ` [PATCH v2 0/9] nfs: prepare for VFS locking changes Anna Schumaker

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=27326.47079.315579.582391@quad.stoffel.home \
    --to=john@stoffel.org \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --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=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

all inboxes | Powered by JetHome®