aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfscache.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2013-03-15 09:16:29 -0400
committerJ. Bruce Fields <bfields@redhat.com>2013-03-18 17:21:30 -0400
commitac534ff2d5508bdff1358a55d88053da729ff46b (patch)
treedb11b9341feb5b90305fa3594549a86e0ea89448 /fs/nfsd/nfscache.c
parenta517b608fa3d9b65930ef53ffe4a2f9800e10f7d (diff)
nfsd: fix startup order in nfsd_reply_cache_init
If we end up doing "goto out_nomem" in this function, we'll call nfsd_reply_cache_shutdown. That will attempt to walk the LRU list and free entries, but that list may not be initialized yet if the server is starting up for the first time. It's also possible for the shrinker to kick in before we've initialized the LRU list. Rearrange the initialization so that the LRU list_head and cache size are initialized before doing any of the allocations that might fail. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfscache.c')
-rw-r--r--fs/nfsd/nfscache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 18509bd6f587..ca05f6dc3544 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -119,6 +119,10 @@ nfsd_reply_cache_free(struct svc_cacherep *rp)
119 119
120int nfsd_reply_cache_init(void) 120int nfsd_reply_cache_init(void)
121{ 121{
122 INIT_LIST_HEAD(&lru_head);
123 max_drc_entries = nfsd_cache_size_limit();
124 num_drc_entries = 0;
125
122 register_shrinker(&nfsd_reply_cache_shrinker); 126 register_shrinker(&nfsd_reply_cache_shrinker);
123 drc_slab = kmem_cache_create("nfsd_drc", sizeof(struct svc_cacherep), 127 drc_slab = kmem_cache_create("nfsd_drc", sizeof(struct svc_cacherep),
124 0, 0, NULL); 128 0, 0, NULL);
@@ -129,10 +133,6 @@ int nfsd_reply_cache_init(void)
129 if (!cache_hash) 133 if (!cache_hash)
130 goto out_nomem; 134 goto out_nomem;
131 135
132 INIT_LIST_HEAD(&lru_head);
133 max_drc_entries = nfsd_cache_size_limit();
134 num_drc_entries = 0;
135
136 return 0; 136 return 0;
137out_nomem: 137out_nomem:
138 printk(KERN_ERR "nfsd: failed to allocate reply cache\n"); 138 printk(KERN_ERR "nfsd: failed to allocate reply cache\n");