Commit ac77efbe2b4d2a1e571a4f1e5b6e47de72a7d737

Authored by Jeff Layton
Committed by J. Bruce Fields
1 parent 628b368728

nfsd: just keep single lockd reference for nfsd

Right now, nfsd keeps a lockd reference for each socket that it has
open. This is unnecessary and complicates the error handling on
startup and shutdown. Change it to just do a lockd_up when starting
the first nfsd thread just do a single lockd_down when taking down the
last nfsd thread. Because of the strange way the sv_count is handled
this requires an extra flag to tell whether the nfsd_serv holds a
reference for lockd or not.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

Showing 2 changed files with 14 additions and 21 deletions Side-by-side Diff

... ... @@ -949,15 +949,8 @@
949 949 if (err != 0)
950 950 return err;
951 951  
952   - err = lockd_up();
953   - if (err != 0) {
954   - svc_destroy(nfsd_serv);
955   - return err;
956   - }
957   -
958 952 err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
959 953 if (err < 0) {
960   - lockd_down();
961 954 svc_destroy(nfsd_serv);
962 955 return err;
963 956 }
... ... @@ -982,9 +975,6 @@
982 975 if (nfsd_serv != NULL)
983 976 len = svc_sock_names(nfsd_serv, buf,
984 977 SIMPLE_TRANSACTION_LIMIT, toclose);
985   - if (len >= 0)
986   - lockd_down();
987   -
988 978 kfree(toclose);
989 979 return len;
990 980 }
... ... @@ -186,8 +186,16 @@
186 186 {
187 187 int ret;
188 188  
  189 + ret = lockd_up();
  190 + if (ret)
  191 + return ret;
189 192 ret = nfs4_state_start();
  193 + if (ret)
  194 + goto out_lockd;
190 195 nfsd_up = true;
  196 + return 0;
  197 +out_lockd:
  198 + lockd_down();
191 199 return ret;
192 200 }
193 201  
... ... @@ -201,6 +209,7 @@
201 209 */
202 210 if (!nfsd_up)
203 211 return;
  212 + lockd_down();
204 213 nfs4_state_shutdown();
205 214 nfsd_up = false;
206 215 }
... ... @@ -208,9 +217,6 @@
208 217 static void nfsd_last_thread(struct svc_serv *serv)
209 218 {
210 219 /* When last nfsd thread exits we need to do some clean-up */
211   - struct svc_xprt *xprt;
212   - list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list)
213   - lockd_down();
214 220 nfsd_serv = NULL;
215 221 nfsd_racache_shutdown();
216 222 nfsd_shutdown();
217 223  
... ... @@ -310,19 +316,11 @@
310 316 if (error < 0)
311 317 return error;
312 318  
313   - error = lockd_up();
314   - if (error < 0)
315   - return error;
316   -
317 319 error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port,
318 320 SVC_SOCK_DEFAULTS);
319 321 if (error < 0)
320 322 return error;
321 323  
322   - error = lockd_up();
323   - if (error < 0)
324   - return error;
325   -
326 324 return 0;
327 325 }
328 326  
... ... @@ -400,6 +398,11 @@
400 398 return err;
401 399 }
402 400  
  401 +/*
  402 + * Adjust the number of threads and return the new number of threads.
  403 + * This is also the function that starts the server if necessary, if
  404 + * this is the first time nrservs is nonzero.
  405 + */
403 406 int
404 407 nfsd_svc(unsigned short port, int nrservs)
405 408 {