aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-07-03 08:46:41 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-07-25 09:21:30 -0400
commit19f7e2ca44dfc3c1b3f499fc46801f98d403500f (patch)
tree765d6e60ace4a723f5e0b8e393728b1a92bcd863 /fs/nfsd
parenta007c4c3e943ecc054a806c259d95420a188754b (diff)
NFSd: introduce nfsd_destroy() helper
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfsctl.c8
-rw-r--r--fs/nfsd/nfsd.h9
-rw-r--r--fs/nfsd/nfssvc.c14
3 files changed, 14 insertions, 17 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index c55298ed5772..fa49cff5ee65 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -673,9 +673,7 @@ static ssize_t __write_ports_addfd(char *buf)
673 673
674 err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); 674 err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
675 if (err < 0) { 675 if (err < 0) {
676 if (nfsd_serv->sv_nrthreads == 1) 676 nfsd_destroy(net);
677 svc_shutdown_net(nfsd_serv, net);
678 svc_destroy(nfsd_serv);
679 return err; 677 return err;
680 } 678 }
681 679
@@ -744,9 +742,7 @@ out_close:
744 svc_xprt_put(xprt); 742 svc_xprt_put(xprt);
745 } 743 }
746out_err: 744out_err:
747 if (nfsd_serv->sv_nrthreads == 1) 745 nfsd_destroy(net);
748 svc_shutdown_net(nfsd_serv, net);
749 svc_destroy(nfsd_serv);
750 return err; 746 return err;
751} 747}
752 748
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 6d425c2f9fcd..7b248a24d5c5 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -75,6 +75,15 @@ int nfsd_set_nrthreads(int n, int *);
75int nfsd_pool_stats_open(struct inode *, struct file *); 75int nfsd_pool_stats_open(struct inode *, struct file *);
76int nfsd_pool_stats_release(struct inode *, struct file *); 76int nfsd_pool_stats_release(struct inode *, struct file *);
77 77
78static inline void nfsd_destroy(struct net *net)
79{
80 int destroy = (nfsd_serv->sv_nrthreads == 1);
81
82 if (destroy)
83 svc_shutdown_net(nfsd_serv, net);
84 svc_destroy(nfsd_serv);
85}
86
78#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) 87#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
79#ifdef CONFIG_NFSD_V2_ACL 88#ifdef CONFIG_NFSD_V2_ACL
80extern struct svc_version nfsd_acl_version2; 89extern struct svc_version nfsd_acl_version2;
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index ee709fc8f58b..8621e36ce8dd 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -427,11 +427,7 @@ int nfsd_set_nrthreads(int n, int *nthreads)
427 if (err) 427 if (err)
428 break; 428 break;
429 } 429 }
430 430 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; 431 return err;
436} 432}
437 433
@@ -478,9 +474,7 @@ out_shutdown:
478 if (error < 0 && !nfsd_up_before) 474 if (error < 0 && !nfsd_up_before)
479 nfsd_shutdown(); 475 nfsd_shutdown();
480out_destroy: 476out_destroy:
481 if (nfsd_serv->sv_nrthreads == 1) 477 nfsd_destroy(net); /* Release server */
482 svc_shutdown_net(nfsd_serv, net);
483 svc_destroy(nfsd_serv); /* Release server */
484out: 478out:
485 mutex_unlock(&nfsd_mutex); 479 mutex_unlock(&nfsd_mutex);
486 return error; 480 return error;
@@ -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}