]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nfsd: destroy percpu stats counters after reply cache shutdown
authorJulian Schroeder <jumaco@amazon.com>
Mon, 23 May 2022 18:52:26 +0000 (18:52 +0000)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 23 May 2022 19:22:17 +0000 (15:22 -0400)
Upon nfsd shutdown any pending DRC cache is freed. DRC cache use is
tracked via a percpu counter. In the current code the percpu counter
is destroyed before. If any pending cache is still present,
percpu_counter_add is called with a percpu counter==NULL. This causes
a kernel crash.
The solution is to destroy the percpu counter after the cache is freed.

Fixes: c55e591aad4c9 (“nfsd: protect concurrent access to nfsd stats counters”)
Signed-off-by: Julian Schroeder <jumaco@amazon.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfscache.c

index 0b3f12aa37ff55488cc8c68424c12966a71a4972..7da88bdc0d6c36bdd5da24f69a3870718dd4ee44 100644 (file)
@@ -206,7 +206,6 @@ void nfsd_reply_cache_shutdown(struct nfsd_net *nn)
        struct svc_cacherep     *rp;
        unsigned int i;
 
-       nfsd_reply_cache_stats_destroy(nn);
        unregister_shrinker(&nn->nfsd_reply_cache_shrinker);
 
        for (i = 0; i < nn->drc_hashsize; i++) {
@@ -217,6 +216,7 @@ void nfsd_reply_cache_shutdown(struct nfsd_net *nn)
                                                                        rp, nn);
                }
        }
+       nfsd_reply_cache_stats_destroy(nn);
 
        kvfree(nn->drc_hashtbl);
        nn->drc_hashtbl = NULL;