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

nfsd: introduce helpers for generic resources init and shutdown

NFSd have per-net resources and resources, used globally.
Let's move generic resources init and shutdown to separated functions since
they are going to be allocated on first NFSd service start and destroyed after
last NFSd service shutdown.
Signed-off-by: default avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 9dd9845f
...@@ -206,6 +206,37 @@ static int nfsd_init_socks(struct net *net) ...@@ -206,6 +206,37 @@ static int nfsd_init_socks(struct net *net)
static bool nfsd_up = false; static bool nfsd_up = false;
static int nfsd_startup_generic(int nrservs)
{
int ret;
if (nfsd_up)
return 0;
/*
* Readahead param cache - will no-op if it already exists.
* (Note therefore results will be suboptimal if number of
* threads is modified after nfsd start.)
*/
ret = nfsd_racache_init(2*nrservs);
if (ret)
return ret;
ret = nfs4_state_start();
if (ret)
goto out_racache;
return 0;
out_racache:
nfsd_racache_shutdown();
return ret;
}
static void nfsd_shutdown_generic(void)
{
nfs4_state_shutdown();
nfsd_racache_shutdown();
}
static int nfsd_startup_net(struct net *net) static int nfsd_startup_net(struct net *net)
{ {
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
...@@ -236,19 +267,9 @@ static int nfsd_startup(int nrservs, struct net *net) ...@@ -236,19 +267,9 @@ static int nfsd_startup(int nrservs, struct net *net)
{ {
int ret; int ret;
if (nfsd_up) ret = nfsd_startup_generic(nrservs);
return 0;
/*
* Readahead param cache - will no-op if it already exists.
* (Note therefore results will be suboptimal if number of
* threads is modified after nfsd start.)
*/
ret = nfsd_racache_init(2*nrservs);
if (ret) if (ret)
return ret; return ret;
ret = nfs4_state_start();
if (ret)
goto out_racache;
ret = nfsd_startup_net(net); ret = nfsd_startup_net(net);
if (ret) if (ret)
goto out_net; goto out_net;
...@@ -257,9 +278,7 @@ static int nfsd_startup(int nrservs, struct net *net) ...@@ -257,9 +278,7 @@ static int nfsd_startup(int nrservs, struct net *net)
return 0; return 0;
out_net: out_net:
nfs4_state_shutdown(); nfsd_shutdown_generic();
out_racache:
nfsd_racache_shutdown();
return ret; return ret;
} }
...@@ -286,8 +305,7 @@ static void nfsd_shutdown(struct net *net) ...@@ -286,8 +305,7 @@ static void nfsd_shutdown(struct net *net)
if (!nfsd_up) if (!nfsd_up)
return; return;
nfsd_shutdown_net(net); nfsd_shutdown_net(net);
nfs4_state_shutdown(); nfsd_shutdown_generic();
nfsd_racache_shutdown();
nfsd_up = false; nfsd_up = false;
} }
......
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