aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
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
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')
-rw-r--r--fs/nfsd/nfsctl.c10
-rw-r--r--fs/nfsd/nfssvc.c25
2 files changed, 14 insertions, 21 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 9e8645a07fca..b1c5be85bea5 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -949,15 +949,8 @@ static ssize_t __write_ports_addfd(char *buf)
949 if (err != 0) 949 if (err != 0)
950 return err; 950 return err;
951 951
952 err = lockd_up();
953 if (err != 0) {
954 svc_destroy(nfsd_serv);
955 return err;
956 }
957
958 err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); 952 err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
959 if (err < 0) { 953 if (err < 0) {
960 lockd_down();
961 svc_destroy(nfsd_serv); 954 svc_destroy(nfsd_serv);
962 return err; 955 return err;
963 } 956 }
@@ -982,9 +975,6 @@ static ssize_t __write_ports_delfd(char *buf)
982 if (nfsd_serv != NULL) 975 if (nfsd_serv != NULL)
983 len = svc_sock_names(nfsd_serv, buf, 976 len = svc_sock_names(nfsd_serv, buf,
984 SIMPLE_TRANSACTION_LIMIT, toclose); 977 SIMPLE_TRANSACTION_LIMIT, toclose);
985 if (len >= 0)
986 lockd_down();
987
988 kfree(toclose); 978 kfree(toclose);
989 return len; 979 return len;
990} 980}
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{