diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-12-06 06:23:34 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-12-10 16:25:40 -0500 |
commit | 903d9bf0edebc9d9f06df125ab2bd57b4aa4e78e (patch) | |
tree | 07a46c7f9216475f9bb78244fcb3e54af06dad7e | |
parent | bda9cac1db8ab044e9edbfe5730283016b67d451 (diff) |
nfsd: simplify NFSv4 state init and shutdown
This patch moves nfsd_startup_generic() and nfsd_shutdown_generic()
calls to nfsd_startup_net() and nfsd_shutdown_net() respectively, which
allows us to call nfsd_startup_net() instead of nfsd_startup() and makes
the code look clearer. It also modifies nfsd_svc() and nfsd_shutdown()
to check nn->nfsd_net_up instead of global nfsd_up. The latter is now
used only for generic resources shutdown and is currently useless. It
will replaced by NFSd users counter later in this series.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | fs/nfsd/nfssvc.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index f9d147f6dfd4..0c87b4e7d1b5 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -235,9 +235,10 @@ static void nfsd_shutdown_generic(void) | |||
235 | { | 235 | { |
236 | nfs4_state_shutdown(); | 236 | nfs4_state_shutdown(); |
237 | nfsd_racache_shutdown(); | 237 | nfsd_racache_shutdown(); |
238 | nfsd_up = false; | ||
238 | } | 239 | } |
239 | 240 | ||
240 | static int nfsd_startup_net(struct net *net) | 241 | static int nfsd_startup_net(int nrservs, struct net *net) |
241 | { | 242 | { |
242 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | 243 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
243 | int ret; | 244 | int ret; |
@@ -245,39 +246,26 @@ static int nfsd_startup_net(struct net *net) | |||
245 | if (nn->nfsd_net_up) | 246 | if (nn->nfsd_net_up) |
246 | return 0; | 247 | return 0; |
247 | 248 | ||
248 | ret = nfsd_init_socks(net); | 249 | ret = nfsd_startup_generic(nrservs); |
249 | if (ret) | 250 | if (ret) |
250 | return ret; | 251 | return ret; |
252 | ret = nfsd_init_socks(net); | ||
253 | if (ret) | ||
254 | goto out_socks; | ||
251 | ret = lockd_up(net); | 255 | ret = lockd_up(net); |
252 | if (ret) | 256 | if (ret) |
253 | return ret; | 257 | goto out_socks; |
254 | ret = nfs4_state_start_net(net); | 258 | ret = nfs4_state_start_net(net); |
255 | if (ret) | 259 | if (ret) |
256 | goto out_lockd; | 260 | goto out_lockd; |
257 | 261 | ||
258 | nn->nfsd_net_up = true; | 262 | nn->nfsd_net_up = true; |
263 | nfsd_up = true; | ||
259 | return 0; | 264 | return 0; |
260 | 265 | ||
261 | out_lockd: | 266 | out_lockd: |
262 | lockd_down(net); | 267 | lockd_down(net); |
263 | return ret; | 268 | out_socks: |
264 | } | ||
265 | |||
266 | static int nfsd_startup(int nrservs, struct net *net) | ||
267 | { | ||
268 | int ret; | ||
269 | |||
270 | ret = nfsd_startup_generic(nrservs); | ||
271 | if (ret) | ||
272 | return ret; | ||
273 | ret = nfsd_startup_net(net); | ||
274 | if (ret) | ||
275 | goto out_net; | ||
276 | |||
277 | nfsd_up = true; | ||
278 | return 0; | ||
279 | |||
280 | out_net: | ||
281 | nfsd_shutdown_generic(); | 269 | nfsd_shutdown_generic(); |
282 | return ret; | 270 | return ret; |
283 | } | 271 | } |
@@ -286,27 +274,25 @@ static void nfsd_shutdown_net(struct net *net) | |||
286 | { | 274 | { |
287 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | 275 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
288 | 276 | ||
289 | if (!nn->nfsd_net_up) | ||
290 | return; | ||
291 | |||
292 | nfs4_state_shutdown_net(net); | 277 | nfs4_state_shutdown_net(net); |
293 | lockd_down(net); | 278 | lockd_down(net); |
294 | nn->nfsd_net_up = false; | 279 | nn->nfsd_net_up = false; |
280 | nfsd_shutdown_generic(); | ||
295 | } | 281 | } |
296 | 282 | ||
297 | static void nfsd_shutdown(struct net *net) | 283 | static void nfsd_shutdown(struct net *net) |
298 | { | 284 | { |
285 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
286 | |||
299 | /* | 287 | /* |
300 | * write_ports can create the server without actually starting | 288 | * write_ports can create the server without actually starting |
301 | * any threads--if we get shut down before any threads are | 289 | * any threads--if we get shut down before any threads are |
302 | * started, then nfsd_last_thread will be run before any of this | 290 | * started, then nfsd_last_thread will be run before any of this |
303 | * other initialization has been done. | 291 | * other initialization has been done. |
304 | */ | 292 | */ |
305 | if (!nfsd_up) | 293 | if (!nn->nfsd_net_up) |
306 | return; | 294 | return; |
307 | nfsd_shutdown_net(net); | 295 | nfsd_shutdown_net(net); |
308 | nfsd_shutdown_generic(); | ||
309 | nfsd_up = false; | ||
310 | } | 296 | } |
311 | 297 | ||
312 | static void nfsd_last_thread(struct svc_serv *serv, struct net *net) | 298 | static void nfsd_last_thread(struct svc_serv *serv, struct net *net) |
@@ -528,9 +514,9 @@ nfsd_svc(int nrservs, struct net *net) | |||
528 | if (error) | 514 | if (error) |
529 | goto out; | 515 | goto out; |
530 | 516 | ||
531 | nfsd_up_before = nfsd_up; | 517 | nfsd_up_before = nn->nfsd_net_up; |
532 | 518 | ||
533 | error = nfsd_startup(nrservs, net); | 519 | error = nfsd_startup_net(nrservs, net); |
534 | if (error) | 520 | if (error) |
535 | goto out_destroy; | 521 | goto out_destroy; |
536 | error = svc_set_num_threads(nn->nfsd_serv, NULL, nrservs); | 522 | error = svc_set_num_threads(nn->nfsd_serv, NULL, nrservs); |