mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neil@brown.name>
Cc: Chuck Lever <cel@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	 Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	Shuah Khan <shuah@kernel.org>,
		linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
		linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 5/8] nfsd: give the open file cache its own mutex
Date: Tue, 22 Sep 2026 06:18:29 -0400	[thread overview]
Message-ID: <40519389abdabce49e87ce1082d5fa3df6cc064d.camel@kernel.org> (raw)
In-Reply-To: <179005907144.37859.15558964767750002575@noble.neil.brown.name>

On Tue, 2026-09-22 at 16:37 +1000, NeilBrown wrote:
> On Tue, 22 Sep 2026, Jeff Layton wrote:
> > nfsd_global_mutex still serializes file cache flushes against server
> > start/stop in unrelated namespaces. nfsd_file_cache_purge() is reached from
> > expkey_flush() on every "exportfs -f", which makes it the only frequent
> > taker of the global lock -- and it has nothing to do with nfsd_users or the
> > NFSv4 global tables it would be waiting on.
> > 
> > Move NFSD_FILE_CACHE_UP and the objects it covers (rhltable, LRU, slabs,
> > shrinker, fsnotify groups) onto a nfsd_file_cache_mutex private to
> > filecache.c. nfsd_file_cache_init() and nfsd_file_cache_shutdown() take it
> > themselves rather than asserting the caller holds the global one, so
> > nfssvc.c no longer needs to know how the cache locks itself.
> > 
> > nfsd_global_mutex is left holding only nfsd_users, the notifier count and
> > user_recovery_dirname, all of which are touched solely on server
> > start/stop.
> > 
> > Ordering is nn->nfsd_mutex outside nfsd_global_mutex outside
> > nfsd_file_cache_mutex. The cache mutex is reached three ways, all
> > consistent with that: from nfsd_startup_generic()/nfsd_shutdown_generic()
> > under the global mutex, from nfsd_shutdown_net() under nn->nfsd_mutex, and
> > bare from expkey_flush() and the filecache stats file. Nothing called with
> > the cache mutex held takes either of the others.
> > 
> > Assisted-by: LLM
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  fs/nfsd/filecache.c | 39 ++++++++++++++++++++++++++++-----------
> >  fs/nfsd/nfssvc.c    |  9 +++++----
> >  2 files changed, 33 insertions(+), 15 deletions(-)
> > 
> > diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
> > index 501772bc8f8d..179362e5394b 100644
> > --- a/fs/nfsd/filecache.c
> > +++ b/fs/nfsd/filecache.c
> > @@ -67,6 +67,17 @@
> >   */
> >  static DEFINE_SPINLOCK(nfsd_gc_lock);
> >  
> > +/*
> > + * Guards NFSD_FILE_CACHE_UP and the host-wide objects it covers: the
> > + * rhltable, the LRU, the slabs, the shrinker and the fsnotify groups.
> > + * Held across cache bring-up and teardown, and by readers and walkers
> > + * that need the cache to stay up for the duration (->cache_purge, the
> > + * stats file).
> > + *
> > + * Nests inside nfsd_global_mutex and inside nn->nfsd_mutex.
> > + */
> > +static DEFINE_MUTEX(nfsd_file_cache_mutex);
> > +
> >  static DEFINE_PER_CPU(unsigned long, nfsd_file_cache_hits);
> >  static DEFINE_PER_CPU(unsigned long, nfsd_file_acquisitions);
> >  static DEFINE_PER_CPU(unsigned long, nfsd_file_allocations);
> > @@ -869,9 +880,11 @@ nfsd_file_cache_init(void)
> >  {
> >  	int ret;
> >  
> > -	lockdep_assert_held(&nfsd_global_mutex);
> > -	if (test_and_set_bit(NFSD_FILE_CACHE_UP, &nfsd_file_flags) == 1)
> > +	mutex_lock(&nfsd_file_cache_mutex);
> 
> What would you think of making this
> 
>    guard(mutex)(&nfsd_file_cache_mutex);
> 
> so you don't need to make other changes in this function??
> 
> 

Sounds good. I'll do that.

Thanks!
-- 
Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2026-09-22 10:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 16:31 [PATCH 0/8] nfsd: reduce the scope of the nfsd_mutex Jeff Layton
2026-09-21 16:31 ` [PATCH 1/8] nfsd: clear NFSD_NET_UP before dropping the generic resource reference Jeff Layton
2026-09-21 16:31 ` [PATCH 2/8] nfsd: make max_blksize a per-namespace setting Jeff Layton
2026-09-21 16:31 ` [PATCH 3/8] nfsd: move the control plane to a per-namespace mutex Jeff Layton
2026-09-21 16:31 ` [PATCH 4/8] nfsd: rename nfsd_mutex to nfsd_global_mutex Jeff Layton
2026-09-21 16:31 ` [PATCH 5/8] nfsd: give the open file cache its own mutex Jeff Layton
2026-09-22  6:37   ` NeilBrown
2026-09-22 10:18     ` Jeff Layton [this message]
2026-09-21 16:31 ` [PATCH 6/8] selftests/nfsd: factor the netlink plumbing into a shared header Jeff Layton
2026-09-21 16:31 ` [PATCH 7/8] selftests/nfsd: add cross-namespace isolation tests Jeff Layton
2026-09-21 16:31 ` [PATCH 8/8] selftests/nfsd: add a cross-namespace control-plane soak Jeff Layton
2026-09-21 18:20   ` Chuck Lever
2026-09-21 19:09     ` Jeff Layton
2026-09-22  6:39 ` [PATCH 0/8] nfsd: reduce the scope of the nfsd_mutex NeilBrown

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=40519389abdabce49e87ce1082d5fa3df6cc064d.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=cel@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=shuah@kernel.org \
    --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

all inboxes | Powered by JetHome®