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

nfsd: call state init and shutdown twice

Split NFSv4 state init and shutdown into two different calls: per-net one and
generic one.
Per-net cwinit/shutdown pair have to be called for any namespace, generic pair
- only once on NSFd kthreads start and shutdown respectively.

Refresh of diff-nfsd-call-state-init-twice
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent d85ed443
...@@ -4861,12 +4861,22 @@ nfs4_state_destroy_net(struct net *net) ...@@ -4861,12 +4861,22 @@ nfs4_state_destroy_net(struct net *net)
put_net(net); put_net(net);
} }
static int int
nfs4_state_start_net(struct net *net) nfs4_state_start_net(struct net *net)
{ {
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int ret; int ret;
/*
* FIXME: For now, we hang most of the pernet global stuff off of
* init_net until nfsd is fully containerized. Eventually, we'll
* need to pass a net pointer into this function, take a reference
* to that instead and then do most of the rest of this on a per-net
* basis.
*/
if (net != &init_net)
return -EINVAL;
ret = nfs4_state_create_net(net); ret = nfs4_state_create_net(net);
if (ret) if (ret)
return ret; return ret;
...@@ -4901,21 +4911,8 @@ nfs4_state_start(void) ...@@ -4901,21 +4911,8 @@ nfs4_state_start(void)
set_max_delegations(); set_max_delegations();
/*
* FIXME: For now, we hang most of the pernet global stuff off of
* init_net until nfsd is fully containerized. Eventually, we'll
* need to pass a net pointer into this function, take a reference
* to that instead and then do most of the rest of this on a per-net
* basis.
*/
ret = nfs4_state_start_net(&init_net);
if (ret)
goto out_free_callback;
return 0; return 0;
out_free_callback:
nfsd4_destroy_callback_queue();
out_free_laundry: out_free_laundry:
destroy_workqueue(laundry_wq); destroy_workqueue(laundry_wq);
out_recovery: out_recovery:
...@@ -4923,7 +4920,7 @@ nfs4_state_start(void) ...@@ -4923,7 +4920,7 @@ nfs4_state_start(void)
} }
/* should be called with the state lock held */ /* should be called with the state lock held */
static void void
nfs4_state_shutdown_net(struct net *net) nfs4_state_shutdown_net(struct net *net)
{ {
struct nfs4_delegation *dp = NULL; struct nfs4_delegation *dp = NULL;
...@@ -4954,9 +4951,6 @@ nfs4_state_shutdown_net(struct net *net) ...@@ -4954,9 +4951,6 @@ nfs4_state_shutdown_net(struct net *net)
void void
nfs4_state_shutdown(void) nfs4_state_shutdown(void)
{ {
struct net *net = &init_net;
nfs4_state_shutdown_net(net);
destroy_workqueue(laundry_wq); destroy_workqueue(laundry_wq);
nfsd4_destroy_callback_queue(); nfsd4_destroy_callback_queue();
} }
......
...@@ -121,7 +121,9 @@ void nfs4_state_init(void); ...@@ -121,7 +121,9 @@ void nfs4_state_init(void);
int nfsd4_init_slabs(void); int nfsd4_init_slabs(void);
void nfsd4_free_slabs(void); void nfsd4_free_slabs(void);
int nfs4_state_start(void); int nfs4_state_start(void);
int nfs4_state_start_net(struct net *net);
void nfs4_state_shutdown(void); void nfs4_state_shutdown(void);
void nfs4_state_shutdown_net(struct net *net);
void nfs4_reset_lease(time_t leasetime); void nfs4_reset_lease(time_t leasetime);
int nfs4_reset_recoverydir(char *recdir); int nfs4_reset_recoverydir(char *recdir);
char * nfs4_recoverydir(void); char * nfs4_recoverydir(void);
...@@ -130,7 +132,9 @@ static inline void nfs4_state_init(void) { } ...@@ -130,7 +132,9 @@ static inline void nfs4_state_init(void) { }
static inline int nfsd4_init_slabs(void) { return 0; } static inline int nfsd4_init_slabs(void) { return 0; }
static inline void nfsd4_free_slabs(void) { } static inline void nfsd4_free_slabs(void) { }
static inline int nfs4_state_start(void) { return 0; } static inline int nfs4_state_start(void) { return 0; }
static inline int nfs4_state_start_net(struct net *net) { return 0; }
static inline void nfs4_state_shutdown(void) { } static inline void nfs4_state_shutdown(void) { }
static inline void nfs4_state_shutdown_net(struct net *net) { }
static inline void nfs4_reset_lease(time_t leasetime) { } static inline void nfs4_reset_lease(time_t leasetime) { }
static inline int nfs4_reset_recoverydir(char *recdir) { return 0; } static inline int nfs4_reset_recoverydir(char *recdir) { return 0; }
static inline char * nfs4_recoverydir(void) {return NULL; } static inline char * nfs4_recoverydir(void) {return NULL; }
......
...@@ -207,6 +207,7 @@ static bool nfsd_up = false; ...@@ -207,6 +207,7 @@ static bool nfsd_up = false;
static int nfsd_startup(int nrservs) static int nfsd_startup(int nrservs)
{ {
int ret; int ret;
struct net *net = &init_net;
if (nfsd_up) if (nfsd_up)
return 0; return 0;
...@@ -221,14 +222,21 @@ static int nfsd_startup(int nrservs) ...@@ -221,14 +222,21 @@ static int nfsd_startup(int nrservs)
ret = nfsd_init_socks(); ret = nfsd_init_socks();
if (ret) if (ret)
goto out_racache; goto out_racache;
ret = lockd_up(&init_net); ret = lockd_up(net);
if (ret) if (ret)
goto out_racache; goto out_racache;
ret = nfs4_state_start(); ret = nfs4_state_start();
if (ret) if (ret)
goto out_lockd; goto out_lockd;
ret = nfs4_state_start_net(net);
if (ret)
goto out_net_state;
nfsd_up = true; nfsd_up = true;
return 0; return 0;
out_net_state:
nfs4_state_shutdown();
out_lockd: out_lockd:
lockd_down(&init_net); lockd_down(&init_net);
out_racache: out_racache:
...@@ -238,6 +246,8 @@ static int nfsd_startup(int nrservs) ...@@ -238,6 +246,8 @@ static int nfsd_startup(int nrservs)
static void nfsd_shutdown(void) static void nfsd_shutdown(void)
{ {
struct net *net = &init_net;
/* /*
* write_ports can create the server without actually starting * write_ports can create the server without actually starting
* any threads--if we get shut down before any threads are * any threads--if we get shut down before any threads are
...@@ -246,8 +256,9 @@ static void nfsd_shutdown(void) ...@@ -246,8 +256,9 @@ static void nfsd_shutdown(void)
*/ */
if (!nfsd_up) if (!nfsd_up)
return; return;
nfs4_state_shutdown_net(net);
nfs4_state_shutdown(); nfs4_state_shutdown();
lockd_down(&init_net); lockd_down(net);
nfsd_racache_shutdown(); 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