Commit 903d9bf0edebc9d9f06df125ab2bd57b4aa4e78e

Authored by Stanislav Kinsbursky
Committed by J. Bruce Fields
1 parent bda9cac1db

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>

Showing 1 changed file with 15 additions and 29 deletions Side-by-side Diff

... ... @@ -235,9 +235,10 @@
235 235 {
236 236 nfs4_state_shutdown();
237 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 243 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
243 244 int ret;
244 245  
245 246  
246 247  
247 248  
... ... @@ -245,39 +246,26 @@
245 246 if (nn->nfsd_net_up)
246 247 return 0;
247 248  
248   - ret = nfsd_init_socks(net);
  249 + ret = nfsd_startup_generic(nrservs);
249 250 if (ret)
250 251 return ret;
  252 + ret = nfsd_init_socks(net);
  253 + if (ret)
  254 + goto out_socks;
251 255 ret = lockd_up(net);
252 256 if (ret)
253   - return ret;
  257 + goto out_socks;
254 258 ret = nfs4_state_start_net(net);
255 259 if (ret)
256 260 goto out_lockd;
257 261  
258 262 nn->nfsd_net_up = true;
  263 + nfsd_up = true;
259 264 return 0;
260 265  
261 266 out_lockd:
262 267 lockd_down(net);
263   - return ret;
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:
  268 +out_socks:
281 269 nfsd_shutdown_generic();
282 270 return ret;
283 271 }
284 272  
285 273  
286 274  
287 275  
... ... @@ -286,27 +274,25 @@
286 274 {
287 275 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
288 276  
289   - if (!nn->nfsd_net_up)
290   - return;
291   -
292 277 nfs4_state_shutdown_net(net);
293 278 lockd_down(net);
294 279 nn->nfsd_net_up = false;
  280 + nfsd_shutdown_generic();
295 281 }
296 282  
297 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 288 * write_ports can create the server without actually starting
301 289 * any threads--if we get shut down before any threads are
302 290 * started, then nfsd_last_thread will be run before any of this
303 291 * other initialization has been done.
304 292 */
305   - if (!nfsd_up)
  293 + if (!nn->nfsd_net_up)
306 294 return;
307 295 nfsd_shutdown_net(net);
308   - nfsd_shutdown_generic();
309   - nfsd_up = false;
310 296 }
311 297  
312 298 static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
313 299  
... ... @@ -528,9 +514,9 @@
528 514 if (error)
529 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 520 if (error)
535 521 goto out_destroy;
536 522 error = svc_set_num_threads(nn->nfsd_serv, NULL, nrservs);