Commit 19f7e2ca authored by Stanislav Kinsbursky's avatar Stanislav Kinsbursky Committed by J. Bruce Fields

NFSd: introduce nfsd_destroy() helper

Signed-off-by: default avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent a007c4c3
...@@ -673,9 +673,7 @@ static ssize_t __write_ports_addfd(char *buf) ...@@ -673,9 +673,7 @@ static ssize_t __write_ports_addfd(char *buf)
err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
if (err < 0) { if (err < 0) {
if (nfsd_serv->sv_nrthreads == 1) nfsd_destroy(net);
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_serv);
return err; return err;
} }
...@@ -744,9 +742,7 @@ static ssize_t __write_ports_addxprt(char *buf) ...@@ -744,9 +742,7 @@ static ssize_t __write_ports_addxprt(char *buf)
svc_xprt_put(xprt); svc_xprt_put(xprt);
} }
out_err: out_err:
if (nfsd_serv->sv_nrthreads == 1) nfsd_destroy(net);
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_serv);
return err; return err;
} }
......
...@@ -75,6 +75,15 @@ int nfsd_set_nrthreads(int n, int *); ...@@ -75,6 +75,15 @@ int nfsd_set_nrthreads(int n, int *);
int nfsd_pool_stats_open(struct inode *, struct file *); int nfsd_pool_stats_open(struct inode *, struct file *);
int nfsd_pool_stats_release(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) #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
#ifdef CONFIG_NFSD_V2_ACL #ifdef CONFIG_NFSD_V2_ACL
extern struct svc_version nfsd_acl_version2; extern struct svc_version nfsd_acl_version2;
......
...@@ -427,11 +427,7 @@ int nfsd_set_nrthreads(int n, int *nthreads) ...@@ -427,11 +427,7 @@ int nfsd_set_nrthreads(int n, int *nthreads)
if (err) if (err)
break; break;
} }
nfsd_destroy(net);
if (nfsd_serv->sv_nrthreads == 1)
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_serv);
return err; return err;
} }
...@@ -478,9 +474,7 @@ nfsd_svc(unsigned short port, int nrservs) ...@@ -478,9 +474,7 @@ nfsd_svc(unsigned short port, int nrservs)
if (error < 0 && !nfsd_up_before) if (error < 0 && !nfsd_up_before)
nfsd_shutdown(); nfsd_shutdown();
out_destroy: out_destroy:
if (nfsd_serv->sv_nrthreads == 1) nfsd_destroy(net); /* Release server */
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_serv); /* Release server */
out: out:
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return error; return error;
...@@ -682,9 +676,7 @@ int nfsd_pool_stats_release(struct inode *inode, struct file *file) ...@@ -682,9 +676,7 @@ int nfsd_pool_stats_release(struct inode *inode, struct file *file)
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
/* this function really, really should have been called svc_put() */ /* this function really, really should have been called svc_put() */
if (nfsd_serv->sv_nrthreads == 1) nfsd_destroy(net);
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_serv);
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment