NFSd: introduce nfsd_destroy() helper
authorStanislav Kinsbursky <skinsbursky@parallels.com>
Tue, 3 Jul 2012 12:46:41 +0000 (16:46 +0400)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 25 Jul 2012 13:21:30 +0000 (09:21 -0400)
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfsctl.c
fs/nfsd/nfsd.h
fs/nfsd/nfssvc.c

index c55298ed5772577e5afe3bd613c3e5a0df3b69dd..fa49cff5ee651b9aa0b16f9cb43804f616aedc4e 100644 (file)
@@ -673,9 +673,7 @@ static ssize_t __write_ports_addfd(char *buf)
 
        err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
        if (err < 0) {
-               if (nfsd_serv->sv_nrthreads == 1)
-                       svc_shutdown_net(nfsd_serv, net);
-               svc_destroy(nfsd_serv);
+               nfsd_destroy(net);
                return err;
        }
 
@@ -744,9 +742,7 @@ out_close:
                svc_xprt_put(xprt);
        }
 out_err:
-       if (nfsd_serv->sv_nrthreads == 1)
-               svc_shutdown_net(nfsd_serv, net);
-       svc_destroy(nfsd_serv);
+       nfsd_destroy(net);
        return err;
 }
 
index 6d425c2f9fcd004876400c41ada93275afd091ef..7b248a24d5c5271a5a022c8b07314ed6e7bcc105 100644 (file)
@@ -75,6 +75,15 @@ int          nfsd_set_nrthreads(int n, int *);
 int            nfsd_pool_stats_open(struct inode *, struct file *);
 int            nfsd_pool_stats_release(struct inode *, struct file *);
 
+static inline void nfsd_destroy(struct net *net)
+{
+       int destroy = (nfsd_serv->sv_nrthreads == 1);
+
+       if (destroy)
+               svc_shutdown_net(nfsd_serv, net);
+       svc_destroy(nfsd_serv);
+}
+
 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
 #ifdef CONFIG_NFSD_V2_ACL
 extern struct svc_version nfsd_acl_version2;
index ee709fc8f58bc0b62a3f7ca64104630fe803b6d0..8621e36ce8dd125e26958fe84a6df91a3d2db97b 100644 (file)
@@ -427,11 +427,7 @@ int nfsd_set_nrthreads(int n, int *nthreads)
                if (err)
                        break;
        }
-
-       if (nfsd_serv->sv_nrthreads == 1)
-               svc_shutdown_net(nfsd_serv, net);
-       svc_destroy(nfsd_serv);
-
+       nfsd_destroy(net);
        return err;
 }
 
@@ -478,9 +474,7 @@ out_shutdown:
        if (error < 0 && !nfsd_up_before)
                nfsd_shutdown();
 out_destroy:
-       if (nfsd_serv->sv_nrthreads == 1)
-               svc_shutdown_net(nfsd_serv, net);
-       svc_destroy(nfsd_serv);         /* Release server */
+       nfsd_destroy(net);              /* Release server */
 out:
        mutex_unlock(&nfsd_mutex);
        return error;
@@ -682,9 +676,7 @@ int nfsd_pool_stats_release(struct inode *inode, struct file *file)
 
        mutex_lock(&nfsd_mutex);
        /* this function really, really should have been called svc_put() */
-       if (nfsd_serv->sv_nrthreads == 1)
-               svc_shutdown_net(nfsd_serv, net);
-       svc_destroy(nfsd_serv);
+       nfsd_destroy(net);
        mutex_unlock(&nfsd_mutex);
        return ret;
 }