aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfssvc.c
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-12-06 06:23:29 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-12-10 16:25:39 -0500
commitbda9cac1db8ab044e9edbfe5730283016b67d451 (patch)
tree1b126e8bdbcc7938290879e7d899d839d5d3130f /fs/nfsd/nfssvc.c
parent9dd9845f084cda07ce00cca32a5ba8fbcbbfbcaf (diff)
nfsd: introduce helpers for generic resources init and shutdown
NFSd have per-net resources and resources, used globally. Let's move generic resources init and shutdown to separated functions since they are going to be allocated on first NFSd service start and destroyed after last NFSd service shutdown. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r--fs/nfsd/nfssvc.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 0e8622a4341c..f9d147f6dfd4 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -206,6 +206,37 @@ static int nfsd_init_socks(struct net *net)
206 206
207static bool nfsd_up = false; 207static bool nfsd_up = false;
208 208
209static int nfsd_startup_generic(int nrservs)
210{
211 int ret;
212
213 if (nfsd_up)
214 return 0;
215
216 /*
217 * Readahead param cache - will no-op if it already exists.
218 * (Note therefore results will be suboptimal if number of
219 * threads is modified after nfsd start.)
220 */
221 ret = nfsd_racache_init(2*nrservs);
222 if (ret)
223 return ret;
224 ret = nfs4_state_start();
225 if (ret)
226 goto out_racache;
227 return 0;
228
229out_racache:
230 nfsd_racache_shutdown();
231 return ret;
232}
233
234static void nfsd_shutdown_generic(void)
235{
236 nfs4_state_shutdown();
237 nfsd_racache_shutdown();
238}
239
209static int nfsd_startup_net(struct net *net) 240static int nfsd_startup_net(struct net *net)
210{ 241{
211 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 242 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
@@ -236,19 +267,9 @@ static int nfsd_startup(int nrservs, struct net *net)
236{ 267{
237 int ret; 268 int ret;
238 269
239 if (nfsd_up) 270 ret = nfsd_startup_generic(nrservs);
240 return 0;
241 /*
242 * Readahead param cache - will no-op if it already exists.
243 * (Note therefore results will be suboptimal if number of
244 * threads is modified after nfsd start.)
245 */
246 ret = nfsd_racache_init(2*nrservs);
247 if (ret) 271 if (ret)
248 return ret; 272 return ret;
249 ret = nfs4_state_start();
250 if (ret)
251 goto out_racache;
252 ret = nfsd_startup_net(net); 273 ret = nfsd_startup_net(net);
253 if (ret) 274 if (ret)
254 goto out_net; 275 goto out_net;
@@ -257,9 +278,7 @@ static int nfsd_startup(int nrservs, struct net *net)
257 return 0; 278 return 0;
258 279
259out_net: 280out_net:
260 nfs4_state_shutdown(); 281 nfsd_shutdown_generic();
261out_racache:
262 nfsd_racache_shutdown();
263 return ret; 282 return ret;
264} 283}
265 284
@@ -286,8 +305,7 @@ static void nfsd_shutdown(struct net *net)
286 if (!nfsd_up) 305 if (!nfsd_up)
287 return; 306 return;
288 nfsd_shutdown_net(net); 307 nfsd_shutdown_net(net);
289 nfs4_state_shutdown(); 308 nfsd_shutdown_generic();
290 nfsd_racache_shutdown();
291 nfsd_up = false; 309 nfsd_up = false;
292} 310}
293 311