nfsd: fix net-namespace logic in __nfsd_file_cache_purge

[ Upstream commit d3aefd2b29 ]

If the namespace doesn't match the one in "net", then we'll continue,
but that doesn't cause another rhashtable_walk_next call, so it will
loop infinitely.

Fixes: ce502f81ba ("NFSD: Convert the filecache to use rhashtable")
Reported-by: Petr Vorel <pvorel@suse.cz>
Link: https://lore.kernel.org/ltp/Y1%2FP8gDAcWC%2F+VR3@pevik/
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Jeff Layton 2022-10-31 11:49:21 -04:00 committed by Greg Kroah-Hartman
parent f17c07f8ea
commit 3ec2c9976c
1 changed files with 2 additions and 3 deletions

View File

@ -892,9 +892,8 @@ __nfsd_file_cache_purge(struct net *net)
nf = rhashtable_walk_next(&iter);
while (!IS_ERR_OR_NULL(nf)) {
if (net && nf->nf_net != net)
continue;
nfsd_file_unhash_and_dispose(nf, &dispose);
if (!net || nf->nf_net == net)
nfsd_file_unhash_and_dispose(nf, &dispose);
nf = rhashtable_walk_next(&iter);
}