aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2010-07-21 18:29:25 -0400
committerJ. Bruce Fields <bfields@redhat.com>2010-07-23 08:51:26 -0400
commit59db4a0c102e0de226a3395dbf25ea51bf845937 (patch)
tree368532c7540cdec8df175b668cc9abef48b8bc11
parentac77efbe2b4d2a1e571a4f1e5b6e47de72a7d737 (diff)
nfsd: move more into nfsd_startup()
This is just cleanup--it's harmless to call nfsd_rachache_init, nfsd_init_socks, and nfsd_reset_versions more than once. But there's no point to it. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/nfssvc.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 8a556ff2e10d..62a6c4474d13 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -180,22 +180,54 @@ int nfsd_nrthreads(void)
180 return rv; 180 return rv;
181} 181}
182 182
183static int nfsd_init_socks(int port)
184{
185 int error;
186 if (!list_empty(&nfsd_serv->sv_permsocks))
187 return 0;
188
189 error = svc_create_xprt(nfsd_serv, "udp", PF_INET, port,
190 SVC_SOCK_DEFAULTS);
191 if (error < 0)
192 return error;
193
194 error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port,
195 SVC_SOCK_DEFAULTS);
196 if (error < 0)
197 return error;
198
199 return 0;
200}
201
183static bool nfsd_up = false; 202static bool nfsd_up = false;
184 203
185static int nfsd_startup(unsigned short port, int nrservs) 204static int nfsd_startup(unsigned short port, int nrservs)
186{ 205{
187 int ret; 206 int ret;
188 207 /*
208 * Readahead param cache - will no-op if it already exists.
209 * (Note therefore results will be suboptimal if number of
210 * threads is modified after nfsd start.)
211 */
212 ret = nfsd_racache_init(2*nrservs);
213 if (ret)
214 return ret;
215 ret = nfsd_init_socks(port);
216 if (ret)
217 goto out_racache;
189 ret = lockd_up(); 218 ret = lockd_up();
190 if (ret) 219 if (ret)
191 return ret; 220 return ret;
192 ret = nfs4_state_start(); 221 ret = nfs4_state_start();
193 if (ret) 222 if (ret)
194 goto out_lockd; 223 goto out_lockd;
224 nfsd_reset_versions();
195 nfsd_up = true; 225 nfsd_up = true;
196 return 0; 226 return 0;
197out_lockd: 227out_lockd:
198 lockd_down(); 228 lockd_down();
229out_racache:
230 nfsd_racache_shutdown();
199 return ret; 231 return ret;
200} 232}
201 233
@@ -209,8 +241,9 @@ static void nfsd_shutdown(void)
209 */ 241 */
210 if (!nfsd_up) 242 if (!nfsd_up)
211 return; 243 return;
212 lockd_down();
213 nfs4_state_shutdown(); 244 nfs4_state_shutdown();
245 lockd_down();
246 nfsd_racache_shutdown();
214 nfsd_up = false; 247 nfsd_up = false;
215} 248}
216 249
@@ -218,7 +251,6 @@ static void nfsd_last_thread(struct svc_serv *serv)
218{ 251{
219 /* When last nfsd thread exits we need to do some clean-up */ 252 /* When last nfsd thread exits we need to do some clean-up */
220 nfsd_serv = NULL; 253 nfsd_serv = NULL;
221 nfsd_racache_shutdown();
222 nfsd_shutdown(); 254 nfsd_shutdown();
223 255
224 printk(KERN_WARNING "nfsd: last server has exited, flushing export " 256 printk(KERN_WARNING "nfsd: last server has exited, flushing export "
@@ -305,25 +337,6 @@ int nfsd_create_serv(void)
305 return err; 337 return err;
306} 338}
307 339
308static int nfsd_init_socks(int port)
309{
310 int error;
311 if (!list_empty(&nfsd_serv->sv_permsocks))
312 return 0;
313
314 error = svc_create_xprt(nfsd_serv, "udp", PF_INET, port,
315 SVC_SOCK_DEFAULTS);
316 if (error < 0)
317 return error;
318
319 error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port,
320 SVC_SOCK_DEFAULTS);
321 if (error < 0)
322 return error;
323
324 return 0;
325}
326
327int nfsd_nrpools(void) 340int nfsd_nrpools(void)
328{ 341{
329 if (nfsd_serv == NULL) 342 if (nfsd_serv == NULL)
@@ -419,11 +432,6 @@ nfsd_svc(unsigned short port, int nrservs)
419 if (nrservs == 0 && nfsd_serv == NULL) 432 if (nrservs == 0 && nfsd_serv == NULL)
420 goto out; 433 goto out;
421 434
422 /* Readahead param cache - will no-op if it already exists */
423 error = nfsd_racache_init(2*nrservs);
424 if (error<0)
425 goto out;
426
427 first_thread = (nfsd_serv->sv_nrthreads == 0) && (nrservs != 0); 435 first_thread = (nfsd_serv->sv_nrthreads == 0) && (nrservs != 0);
428 436
429 if (first_thread) { 437 if (first_thread) {
@@ -431,16 +439,9 @@ nfsd_svc(unsigned short port, int nrservs)
431 if (error) 439 if (error)
432 goto out; 440 goto out;
433 } 441 }
434
435 nfsd_reset_versions();
436
437 error = nfsd_create_serv(); 442 error = nfsd_create_serv();
438 if (error) 443 if (error)
439 goto out_shutdown; 444 goto out_shutdown;
440 error = nfsd_init_socks(port);
441 if (error)
442 goto out_destroy;
443
444 error = svc_set_num_threads(nfsd_serv, NULL, nrservs); 445 error = svc_set_num_threads(nfsd_serv, NULL, nrservs);
445 if (error == 0) 446 if (error == 0)
446 /* We are holding a reference to nfsd_serv which 447 /* We are holding a reference to nfsd_serv which