Skip to contentSkip to conversation

NFSD: Mark filecache "down" if init fails

RFC PATCH New [email protected] 1 participant 1 message Sep 21, 2024

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

RFC PATCH 1/1 NFSD: Mark filecache "down" if init fails

From: Chuck Lever <[email protected]>

NeilBrown says:

Quoted 4 lines

The handling of NFSD_FILE_CACHE_UP is strange. nfsd_file_cache_init() sets it, but doesn't clear it on failure. So if nfsd_file_cache_init() fails for some reason, nfsd_file_cache_shutdown() would still try to clean up if it was called.

Fixes c7b824c3d06c ("NFSD: Replace the "init once" mechanism")
---
 fs/nfsd/filecache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/filecache.c +3 -1
index 24e8f1fbcebb..2603183305b4 100644
@@ -723,7 +723,7 @@ nfsd_file_cache_init(void)
 
 	ret = rhltable_init(&nfsd_file_rhltable, &nfsd_file_rhash_params);
 	if (ret)
-		return ret;
+		goto out;
 
 	ret = -ENOMEM;
 	nfsd_file_slab = KMEM_CACHE(nfsd_file, 0);
@@ -775,6 +775,8 @@ nfsd_file_cache_init(void)
 
 	INIT_DELAYED_WORK(&nfsd_filecache_laundrette, nfsd_file_gc_worker);
 out:
+	if (ret)
+		clear_bit(NFSD_FILE_CACHE_UP, &nfsd_file_flags);
 	return ret;
 out_notifier:
 	lease_unregister_notifier(&nfsd_file_lease_notifier);
Signature · 1 line
2.46.0