aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfssvc.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-07-20 14:10:22 -0400
committerJ. Bruce Fields <bfields@redhat.com>2010-07-23 08:51:26 -0400
commitac77efbe2b4d2a1e571a4f1e5b6e47de72a7d737 (patch)
tree2ebb9f5178a3b81e357f95966f1e2eb0269e8e35 /fs/nfsd/nfssvc.c
parent628b368728e23188ac41b3f00411b02be8e697f1 (diff)
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>
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r--fs/nfsd/nfssvc.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index a631ea61f76a..8a556ff2e10d 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -186,8 +186,16 @@ static int nfsd_startup(unsigned short port, int nrservs)
186{ 186{
187 int ret; 187 int ret;
188 188
189 ret = lockd_up();
190 if (ret)
191 return ret;
189 ret = nfs4_state_start(); 192 ret = nfs4_state_start();
193 if (ret)
194 goto out_lockd;
190 nfsd_up = true; 195 nfsd_up = true;
196 return 0;
197out_lockd:
198 lockd_down();
191 return ret; 199 return ret;
192} 200}
193 201
@@ -201,6 +209,7 @@ static void nfsd_shutdown(void)
201 */ 209 */
202 if (!nfsd_up) 210 if (!nfsd_up)
203 return; 211 return;
212 lockd_down();
204 nfs4_state_shutdown(); 213 nfs4_state_shutdown();
205 nfsd_up = false; 214 nfsd_up = false;
206} 215}
@@ -208,9 +217,6 @@ static void nfsd_shutdown(void)
208static void nfsd_last_thread(struct svc_serv *serv) 217static void nfsd_last_thread(struct svc_serv *serv)
209{ 218{
210 /* When last nfsd thread exits we need to do some clean-up */ 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 nfsd_serv = NULL; 220 nfsd_serv = NULL;
215 nfsd_racache_shutdown(); 221 nfsd_racache_shutdown();
216 nfsd_shutdown(); 222 nfsd_shutdown();
@@ -310,19 +316,11 @@ static int nfsd_init_socks(int port)
310 if (error < 0) 316 if (error < 0)
311 return error; 317 return error;
312 318
313 error = lockd_up();
314 if (error < 0)
315 return error;
316
317 error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port, 319 error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port,
318 SVC_SOCK_DEFAULTS); 320 SVC_SOCK_DEFAULTS);
319 if (error < 0) 321 if (error < 0)
320 return error; 322 return error;
321 323
322 error = lockd_up();
323 if (error < 0)
324 return error;
325
326 return 0; 324 return 0;
327} 325}
328 326
@@ -400,6 +398,11 @@ int nfsd_set_nrthreads(int n, int *nthreads)
400 return err; 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 */
403int 406int
404nfsd_svc(unsigned short port, int nrservs) 407nfsd_svc(unsigned short port, int nrservs)
405{ 408{