diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-11-26 07:22:18 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-11-28 10:13:53 -0500 |
commit | f252bc6806a9428f2e3a429e4cdffbd012de9839 (patch) | |
tree | b2beb8aa4ccd300f5b3ed70431d167b46fbcd9e4 /fs | |
parent | d85ed443052570b25ea4b5f5fa70c57e0129fbc4 (diff) |
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: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4state.c | 30 | ||||
-rw-r--r-- | fs/nfsd/nfsd.h | 4 | ||||
-rw-r--r-- | fs/nfsd/nfssvc.c | 15 |
3 files changed, 29 insertions, 20 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 6f5798623eb..fb98f291aac 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -4861,12 +4861,22 @@ nfs4_state_destroy_net(struct net *net) | |||
4861 | put_net(net); | 4861 | put_net(net); |
4862 | } | 4862 | } |
4863 | 4863 | ||
4864 | static int | 4864 | int |
4865 | nfs4_state_start_net(struct net *net) | 4865 | nfs4_state_start_net(struct net *net) |
4866 | { | 4866 | { |
4867 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | 4867 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
4868 | int ret; | 4868 | int ret; |
4869 | 4869 | ||
4870 | /* | ||
4871 | * FIXME: For now, we hang most of the pernet global stuff off of | ||
4872 | * init_net until nfsd is fully containerized. Eventually, we'll | ||
4873 | * need to pass a net pointer into this function, take a reference | ||
4874 | * to that instead and then do most of the rest of this on a per-net | ||
4875 | * basis. | ||
4876 | */ | ||
4877 | if (net != &init_net) | ||
4878 | return -EINVAL; | ||
4879 | |||
4870 | ret = nfs4_state_create_net(net); | 4880 | ret = nfs4_state_create_net(net); |
4871 | if (ret) | 4881 | if (ret) |
4872 | return ret; | 4882 | return ret; |
@@ -4901,21 +4911,8 @@ nfs4_state_start(void) | |||
4901 | 4911 | ||
4902 | set_max_delegations(); | 4912 | set_max_delegations(); |
4903 | 4913 | ||
4904 | /* | ||
4905 | * FIXME: For now, we hang most of the pernet global stuff off of | ||
4906 | * init_net until nfsd is fully containerized. Eventually, we'll | ||
4907 | * need to pass a net pointer into this function, take a reference | ||
4908 | * to that instead and then do most of the rest of this on a per-net | ||
4909 | * basis. | ||
4910 | */ | ||
4911 | ret = nfs4_state_start_net(&init_net); | ||
4912 | if (ret) | ||
4913 | goto out_free_callback; | ||
4914 | |||
4915 | return 0; | 4914 | return 0; |
4916 | 4915 | ||
4917 | out_free_callback: | ||
4918 | nfsd4_destroy_callback_queue(); | ||
4919 | out_free_laundry: | 4916 | out_free_laundry: |
4920 | destroy_workqueue(laundry_wq); | 4917 | destroy_workqueue(laundry_wq); |
4921 | out_recovery: | 4918 | out_recovery: |
@@ -4923,7 +4920,7 @@ out_recovery: | |||
4923 | } | 4920 | } |
4924 | 4921 | ||
4925 | /* should be called with the state lock held */ | 4922 | /* should be called with the state lock held */ |
4926 | static void | 4923 | void |
4927 | nfs4_state_shutdown_net(struct net *net) | 4924 | nfs4_state_shutdown_net(struct net *net) |
4928 | { | 4925 | { |
4929 | struct nfs4_delegation *dp = NULL; | 4926 | struct nfs4_delegation *dp = NULL; |
@@ -4954,9 +4951,6 @@ nfs4_state_shutdown_net(struct net *net) | |||
4954 | void | 4951 | void |
4955 | nfs4_state_shutdown(void) | 4952 | nfs4_state_shutdown(void) |
4956 | { | 4953 | { |
4957 | struct net *net = &init_net; | ||
4958 | |||
4959 | nfs4_state_shutdown_net(net); | ||
4960 | destroy_workqueue(laundry_wq); | 4954 | destroy_workqueue(laundry_wq); |
4961 | nfsd4_destroy_callback_queue(); | 4955 | nfsd4_destroy_callback_queue(); |
4962 | } | 4956 | } |
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 80d5ce40aad..d7b210b735e 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h | |||
@@ -121,7 +121,9 @@ void nfs4_state_init(void); | |||
121 | int nfsd4_init_slabs(void); | 121 | int nfsd4_init_slabs(void); |
122 | void nfsd4_free_slabs(void); | 122 | void nfsd4_free_slabs(void); |
123 | int nfs4_state_start(void); | 123 | int nfs4_state_start(void); |
124 | int nfs4_state_start_net(struct net *net); | ||
124 | void nfs4_state_shutdown(void); | 125 | void nfs4_state_shutdown(void); |
126 | void nfs4_state_shutdown_net(struct net *net); | ||
125 | void nfs4_reset_lease(time_t leasetime); | 127 | void nfs4_reset_lease(time_t leasetime); |
126 | int nfs4_reset_recoverydir(char *recdir); | 128 | int nfs4_reset_recoverydir(char *recdir); |
127 | char * nfs4_recoverydir(void); | 129 | char * nfs4_recoverydir(void); |
@@ -130,7 +132,9 @@ static inline void nfs4_state_init(void) { } | |||
130 | static inline int nfsd4_init_slabs(void) { return 0; } | 132 | static inline int nfsd4_init_slabs(void) { return 0; } |
131 | static inline void nfsd4_free_slabs(void) { } | 133 | static inline void nfsd4_free_slabs(void) { } |
132 | static inline int nfs4_state_start(void) { return 0; } | 134 | static inline int nfs4_state_start(void) { return 0; } |
135 | static inline int nfs4_state_start_net(struct net *net) { return 0; } | ||
133 | static inline void nfs4_state_shutdown(void) { } | 136 | static inline void nfs4_state_shutdown(void) { } |
137 | static inline void nfs4_state_shutdown_net(struct net *net) { } | ||
134 | static inline void nfs4_reset_lease(time_t leasetime) { } | 138 | static inline void nfs4_reset_lease(time_t leasetime) { } |
135 | static inline int nfs4_reset_recoverydir(char *recdir) { return 0; } | 139 | static inline int nfs4_reset_recoverydir(char *recdir) { return 0; } |
136 | static inline char * nfs4_recoverydir(void) {return NULL; } | 140 | static inline char * nfs4_recoverydir(void) {return NULL; } |
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 30d3784d028..b34a67d8ec4 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -207,6 +207,7 @@ static bool nfsd_up = false; | |||
207 | static int nfsd_startup(int nrservs) | 207 | static int nfsd_startup(int nrservs) |
208 | { | 208 | { |
209 | int ret; | 209 | int ret; |
210 | struct net *net = &init_net; | ||
210 | 211 | ||
211 | if (nfsd_up) | 212 | if (nfsd_up) |
212 | return 0; | 213 | return 0; |
@@ -221,14 +222,21 @@ static int nfsd_startup(int nrservs) | |||
221 | ret = nfsd_init_socks(); | 222 | ret = nfsd_init_socks(); |
222 | if (ret) | 223 | if (ret) |
223 | goto out_racache; | 224 | goto out_racache; |
224 | ret = lockd_up(&init_net); | 225 | ret = lockd_up(net); |
225 | if (ret) | 226 | if (ret) |
226 | goto out_racache; | 227 | goto out_racache; |
227 | ret = nfs4_state_start(); | 228 | ret = nfs4_state_start(); |
228 | if (ret) | 229 | if (ret) |
229 | goto out_lockd; | 230 | goto out_lockd; |
231 | |||
232 | ret = nfs4_state_start_net(net); | ||
233 | if (ret) | ||
234 | goto out_net_state; | ||
235 | |||
230 | nfsd_up = true; | 236 | nfsd_up = true; |
231 | return 0; | 237 | return 0; |
238 | out_net_state: | ||
239 | nfs4_state_shutdown(); | ||
232 | out_lockd: | 240 | out_lockd: |
233 | lockd_down(&init_net); | 241 | lockd_down(&init_net); |
234 | out_racache: | 242 | out_racache: |
@@ -238,6 +246,8 @@ out_racache: | |||
238 | 246 | ||
239 | static void nfsd_shutdown(void) | 247 | static void nfsd_shutdown(void) |
240 | { | 248 | { |
249 | struct net *net = &init_net; | ||
250 | |||
241 | /* | 251 | /* |
242 | * write_ports can create the server without actually starting | 252 | * write_ports can create the server without actually starting |
243 | * any threads--if we get shut down before any threads are | 253 | * any threads--if we get shut down before any threads are |
@@ -246,8 +256,9 @@ static void nfsd_shutdown(void) | |||
246 | */ | 256 | */ |
247 | if (!nfsd_up) | 257 | if (!nfsd_up) |
248 | return; | 258 | return; |
259 | nfs4_state_shutdown_net(net); | ||
249 | nfs4_state_shutdown(); | 260 | nfs4_state_shutdown(); |
250 | lockd_down(&init_net); | 261 | lockd_down(net); |
251 | nfsd_racache_shutdown(); | 262 | nfsd_racache_shutdown(); |
252 | nfsd_up = false; | 263 | nfsd_up = false; |
253 | } | 264 | } |