aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfssvc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r--fs/nfsd/nfssvc.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index ee709fc8f58b..240473cb708f 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -254,8 +254,6 @@ static void nfsd_shutdown(void)
254 254
255static void nfsd_last_thread(struct svc_serv *serv, struct net *net) 255static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
256{ 256{
257 /* When last nfsd thread exits we need to do some clean-up */
258 nfsd_serv = NULL;
259 nfsd_shutdown(); 257 nfsd_shutdown();
260 258
261 svc_rpcb_cleanup(serv, net); 259 svc_rpcb_cleanup(serv, net);
@@ -332,6 +330,7 @@ static int nfsd_get_default_max_blksize(void)
332int nfsd_create_serv(void) 330int nfsd_create_serv(void)
333{ 331{
334 int error; 332 int error;
333 struct net *net = current->nsproxy->net_ns;
335 334
336 WARN_ON(!mutex_is_locked(&nfsd_mutex)); 335 WARN_ON(!mutex_is_locked(&nfsd_mutex));
337 if (nfsd_serv) { 336 if (nfsd_serv) {
@@ -346,7 +345,7 @@ int nfsd_create_serv(void)
346 if (nfsd_serv == NULL) 345 if (nfsd_serv == NULL)
347 return -ENOMEM; 346 return -ENOMEM;
348 347
349 error = svc_bind(nfsd_serv, current->nsproxy->net_ns); 348 error = svc_bind(nfsd_serv, net);
350 if (error < 0) { 349 if (error < 0) {
351 svc_destroy(nfsd_serv); 350 svc_destroy(nfsd_serv);
352 return error; 351 return error;
@@ -427,11 +426,7 @@ int nfsd_set_nrthreads(int n, int *nthreads)
427 if (err) 426 if (err)
428 break; 427 break;
429 } 428 }
430 429 nfsd_destroy(net);
431 if (nfsd_serv->sv_nrthreads == 1)
432 svc_shutdown_net(nfsd_serv, net);
433 svc_destroy(nfsd_serv);
434
435 return err; 430 return err;
436} 431}
437 432
@@ -478,9 +473,7 @@ out_shutdown:
478 if (error < 0 && !nfsd_up_before) 473 if (error < 0 && !nfsd_up_before)
479 nfsd_shutdown(); 474 nfsd_shutdown();
480out_destroy: 475out_destroy:
481 if (nfsd_serv->sv_nrthreads == 1) 476 nfsd_destroy(net); /* Release server */
482 svc_shutdown_net(nfsd_serv, net);
483 svc_destroy(nfsd_serv); /* Release server */
484out: 477out:
485 mutex_unlock(&nfsd_mutex); 478 mutex_unlock(&nfsd_mutex);
486 return error; 479 return error;
@@ -563,12 +556,13 @@ nfsd(void *vrqstp)
563 nfsdstats.th_cnt --; 556 nfsdstats.th_cnt --;
564 557
565out: 558out:
566 if (rqstp->rq_server->sv_nrthreads == 1) 559 rqstp->rq_server = NULL;
567 svc_shutdown_net(rqstp->rq_server, &init_net);
568 560
569 /* Release the thread */ 561 /* Release the thread */
570 svc_exit_thread(rqstp); 562 svc_exit_thread(rqstp);
571 563
564 nfsd_destroy(&init_net);
565
572 /* Release module */ 566 /* Release module */
573 mutex_unlock(&nfsd_mutex); 567 mutex_unlock(&nfsd_mutex);
574 module_put_and_exit(0); 568 module_put_and_exit(0);
@@ -682,9 +676,7 @@ int nfsd_pool_stats_release(struct inode *inode, struct file *file)
682 676
683 mutex_lock(&nfsd_mutex); 677 mutex_lock(&nfsd_mutex);
684 /* this function really, really should have been called svc_put() */ 678 /* this function really, really should have been called svc_put() */
685 if (nfsd_serv->sv_nrthreads == 1) 679 nfsd_destroy(net);
686 svc_shutdown_net(nfsd_serv, net);
687 svc_destroy(nfsd_serv);
688 mutex_unlock(&nfsd_mutex); 680 mutex_unlock(&nfsd_mutex);
689 return ret; 681 return ret;
690} 682}