diff options
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfsctl.c | 12 | ||||
-rw-r--r-- | fs/nfsd/nfssvc.c | 14 |
2 files changed, 23 insertions, 3 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 72699885ac48..c55298ed5772 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -661,6 +661,7 @@ static ssize_t __write_ports_addfd(char *buf) | |||
661 | { | 661 | { |
662 | char *mesg = buf; | 662 | char *mesg = buf; |
663 | int fd, err; | 663 | int fd, err; |
664 | struct net *net = &init_net; | ||
664 | 665 | ||
665 | err = get_int(&mesg, &fd); | 666 | err = get_int(&mesg, &fd); |
666 | if (err != 0 || fd < 0) | 667 | if (err != 0 || fd < 0) |
@@ -672,6 +673,8 @@ static ssize_t __write_ports_addfd(char *buf) | |||
672 | 673 | ||
673 | err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); | 674 | err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); |
674 | if (err < 0) { | 675 | if (err < 0) { |
676 | if (nfsd_serv->sv_nrthreads == 1) | ||
677 | svc_shutdown_net(nfsd_serv, net); | ||
675 | svc_destroy(nfsd_serv); | 678 | svc_destroy(nfsd_serv); |
676 | return err; | 679 | return err; |
677 | } | 680 | } |
@@ -709,6 +712,7 @@ static ssize_t __write_ports_addxprt(char *buf) | |||
709 | char transport[16]; | 712 | char transport[16]; |
710 | struct svc_xprt *xprt; | 713 | struct svc_xprt *xprt; |
711 | int port, err; | 714 | int port, err; |
715 | struct net *net = &init_net; | ||
712 | 716 | ||
713 | if (sscanf(buf, "%15s %4u", transport, &port) != 2) | 717 | if (sscanf(buf, "%15s %4u", transport, &port) != 2) |
714 | return -EINVAL; | 718 | return -EINVAL; |
@@ -720,12 +724,12 @@ static ssize_t __write_ports_addxprt(char *buf) | |||
720 | if (err != 0) | 724 | if (err != 0) |
721 | return err; | 725 | return err; |
722 | 726 | ||
723 | err = svc_create_xprt(nfsd_serv, transport, &init_net, | 727 | err = svc_create_xprt(nfsd_serv, transport, net, |
724 | PF_INET, port, SVC_SOCK_ANONYMOUS); | 728 | PF_INET, port, SVC_SOCK_ANONYMOUS); |
725 | if (err < 0) | 729 | if (err < 0) |
726 | goto out_err; | 730 | goto out_err; |
727 | 731 | ||
728 | err = svc_create_xprt(nfsd_serv, transport, &init_net, | 732 | err = svc_create_xprt(nfsd_serv, transport, net, |
729 | PF_INET6, port, SVC_SOCK_ANONYMOUS); | 733 | PF_INET6, port, SVC_SOCK_ANONYMOUS); |
730 | if (err < 0 && err != -EAFNOSUPPORT) | 734 | if (err < 0 && err != -EAFNOSUPPORT) |
731 | goto out_close; | 735 | goto out_close; |
@@ -734,12 +738,14 @@ static ssize_t __write_ports_addxprt(char *buf) | |||
734 | nfsd_serv->sv_nrthreads--; | 738 | nfsd_serv->sv_nrthreads--; |
735 | return 0; | 739 | return 0; |
736 | out_close: | 740 | out_close: |
737 | xprt = svc_find_xprt(nfsd_serv, transport, &init_net, PF_INET, port); | 741 | xprt = svc_find_xprt(nfsd_serv, transport, net, PF_INET, port); |
738 | if (xprt != NULL) { | 742 | if (xprt != NULL) { |
739 | svc_close_xprt(xprt); | 743 | svc_close_xprt(xprt); |
740 | svc_xprt_put(xprt); | 744 | svc_xprt_put(xprt); |
741 | } | 745 | } |
742 | out_err: | 746 | out_err: |
747 | if (nfsd_serv->sv_nrthreads == 1) | ||
748 | svc_shutdown_net(nfsd_serv, net); | ||
743 | svc_destroy(nfsd_serv); | 749 | svc_destroy(nfsd_serv); |
744 | return err; | 750 | return err; |
745 | } | 751 | } |
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 0762f3c9e0fb..ee709fc8f58b 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -382,6 +382,7 @@ int nfsd_set_nrthreads(int n, int *nthreads) | |||
382 | int i = 0; | 382 | int i = 0; |
383 | int tot = 0; | 383 | int tot = 0; |
384 | int err = 0; | 384 | int err = 0; |
385 | struct net *net = &init_net; | ||
385 | 386 | ||
386 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); | 387 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); |
387 | 388 | ||
@@ -426,6 +427,9 @@ int nfsd_set_nrthreads(int n, int *nthreads) | |||
426 | if (err) | 427 | if (err) |
427 | break; | 428 | break; |
428 | } | 429 | } |
430 | |||
431 | if (nfsd_serv->sv_nrthreads == 1) | ||
432 | svc_shutdown_net(nfsd_serv, net); | ||
429 | svc_destroy(nfsd_serv); | 433 | svc_destroy(nfsd_serv); |
430 | 434 | ||
431 | return err; | 435 | return err; |
@@ -441,6 +445,7 @@ nfsd_svc(unsigned short port, int nrservs) | |||
441 | { | 445 | { |
442 | int error; | 446 | int error; |
443 | bool nfsd_up_before; | 447 | bool nfsd_up_before; |
448 | struct net *net = &init_net; | ||
444 | 449 | ||
445 | mutex_lock(&nfsd_mutex); | 450 | mutex_lock(&nfsd_mutex); |
446 | dprintk("nfsd: creating service\n"); | 451 | dprintk("nfsd: creating service\n"); |
@@ -473,6 +478,8 @@ out_shutdown: | |||
473 | if (error < 0 && !nfsd_up_before) | 478 | if (error < 0 && !nfsd_up_before) |
474 | nfsd_shutdown(); | 479 | nfsd_shutdown(); |
475 | out_destroy: | 480 | out_destroy: |
481 | if (nfsd_serv->sv_nrthreads == 1) | ||
482 | svc_shutdown_net(nfsd_serv, net); | ||
476 | svc_destroy(nfsd_serv); /* Release server */ | 483 | svc_destroy(nfsd_serv); /* Release server */ |
477 | out: | 484 | out: |
478 | mutex_unlock(&nfsd_mutex); | 485 | mutex_unlock(&nfsd_mutex); |
@@ -556,6 +563,9 @@ nfsd(void *vrqstp) | |||
556 | nfsdstats.th_cnt --; | 563 | nfsdstats.th_cnt --; |
557 | 564 | ||
558 | out: | 565 | out: |
566 | if (rqstp->rq_server->sv_nrthreads == 1) | ||
567 | svc_shutdown_net(rqstp->rq_server, &init_net); | ||
568 | |||
559 | /* Release the thread */ | 569 | /* Release the thread */ |
560 | svc_exit_thread(rqstp); | 570 | svc_exit_thread(rqstp); |
561 | 571 | ||
@@ -668,8 +678,12 @@ int nfsd_pool_stats_open(struct inode *inode, struct file *file) | |||
668 | int nfsd_pool_stats_release(struct inode *inode, struct file *file) | 678 | int nfsd_pool_stats_release(struct inode *inode, struct file *file) |
669 | { | 679 | { |
670 | int ret = seq_release(inode, file); | 680 | int ret = seq_release(inode, file); |
681 | struct net *net = &init_net; | ||
682 | |||
671 | mutex_lock(&nfsd_mutex); | 683 | mutex_lock(&nfsd_mutex); |
672 | /* this function really, really should have been called svc_put() */ | 684 | /* this function really, really should have been called svc_put() */ |
685 | if (nfsd_serv->sv_nrthreads == 1) | ||
686 | svc_shutdown_net(nfsd_serv, net); | ||
673 | svc_destroy(nfsd_serv); | 687 | svc_destroy(nfsd_serv); |
674 | mutex_unlock(&nfsd_mutex); | 688 | mutex_unlock(&nfsd_mutex); |
675 | return ret; | 689 | return ret; |