nfsd_shutdown_net() leaves NFSD_NET_UP set across nfsd_shutdown_generic(), so during that window the bit claims the host-wide file cache and NFSv4 tables are up when the last namespace may already have torn them down. Nothing observes it today only because one global mutex covers both.
Fold the test and clear into test_and_clear_bit() so the invariant "NFSD_NET_UP implies the generic resources are up" holds on its own. No functional change. Assisted-by: LLM Signed-off-by: Jeff Layton <[email protected]> --- fs/nfsd/nfssvc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index cbc989238710..d75fe1523436 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -433,9 +433,13 @@ static void nfsd_shutdown_net(struct net *net) percpu_ref_exit(&nn->nfsd_net_ref); - if (test_bit(NFSD_NET_UP, &nn->flags)) + /* + * Clear NFSD_NET_UP before dropping this namespace's reference on + * the generic (host-wide) resources, so that the bit never claims + * they are available once they may already be gone. + */ + if (test_and_clear_bit(NFSD_NET_UP, &nn->flags)) nfsd_shutdown_generic(); - clear_bit(NFSD_NET_UP, &nn->flags); } static DEFINE_SPINLOCK(nfsd_notifier_lock); -- 2.55.0

