aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfssvc.c
diff options
context:
space:
mode:
authorKinglong Mee <kinglongmee@gmail.com>2013-12-31 00:17:30 -0500
committerJ. Bruce Fields <bfields@redhat.com>2014-01-03 18:18:50 -0500
commit8ef667140c52e9b88934664954217f28559c75d6 (patch)
tree73d4f73af96dad3d92af96a9086f3b354ab79799 /fs/nfsd/nfssvc.c
parent7e55b59b2f32afc83452ae250dfd6173c9a7b515 (diff)
NFSD: Don't start lockd when only NFSv4 is running
When starting without nfsv2 and nfsv3, nfsd does not need to start lockd (and certainly doesn't need to fail because lockd failed to register with the portmapper). Reported-by: Gareth Williams <gareth@garethwilliams.me.uk> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r--fs/nfsd/nfssvc.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 760c85a6f534..55b5b57b5715 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -241,6 +241,11 @@ static void nfsd_shutdown_generic(void)
241 nfsd_racache_shutdown(); 241 nfsd_racache_shutdown();
242} 242}
243 243
244static bool nfsd_needs_lockd(void)
245{
246 return (nfsd_versions[2] != NULL) || (nfsd_versions[3] != NULL);
247}
248
244static int nfsd_startup_net(int nrservs, struct net *net) 249static int nfsd_startup_net(int nrservs, struct net *net)
245{ 250{
246 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 251 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
@@ -255,9 +260,14 @@ static int nfsd_startup_net(int nrservs, struct net *net)
255 ret = nfsd_init_socks(net); 260 ret = nfsd_init_socks(net);
256 if (ret) 261 if (ret)
257 goto out_socks; 262 goto out_socks;
258 ret = lockd_up(net); 263
259 if (ret) 264 if (nfsd_needs_lockd() && !nn->lockd_up) {
260 goto out_socks; 265 ret = lockd_up(net);
266 if (ret)
267 goto out_socks;
268 nn->lockd_up = 1;
269 }
270
261 ret = nfs4_state_start_net(net); 271 ret = nfs4_state_start_net(net);
262 if (ret) 272 if (ret)
263 goto out_lockd; 273 goto out_lockd;
@@ -266,7 +276,10 @@ static int nfsd_startup_net(int nrservs, struct net *net)
266 return 0; 276 return 0;
267 277
268out_lockd: 278out_lockd:
269 lockd_down(net); 279 if (nn->lockd_up) {
280 lockd_down(net);
281 nn->lockd_up = 0;
282 }
270out_socks: 283out_socks:
271 nfsd_shutdown_generic(); 284 nfsd_shutdown_generic();
272 return ret; 285 return ret;
@@ -277,7 +290,10 @@ static void nfsd_shutdown_net(struct net *net)
277 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 290 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
278 291
279 nfs4_state_shutdown_net(net); 292 nfs4_state_shutdown_net(net);
280 lockd_down(net); 293 if (nn->lockd_up) {
294 lockd_down(net);
295 nn->lockd_up = 0;
296 }
281 nn->nfsd_net_up = false; 297 nn->nfsd_net_up = false;
282 nfsd_shutdown_generic(); 298 nfsd_shutdown_generic();
283} 299}