Ver código fonte

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>
Kinglong Mee 11 anos atrás
pai
commit
8ef667140c
2 arquivos alterados com 22 adições e 5 exclusões
  1. 1 0
      fs/nfsd/netns.h
  2. 21 5
      fs/nfsd/nfssvc.c

+ 1 - 0
fs/nfsd/netns.h

@@ -95,6 +95,7 @@ struct nfsd_net {
 	time_t nfsd4_grace;
 	time_t nfsd4_grace;
 
 
 	bool nfsd_net_up;
 	bool nfsd_net_up;
+	bool lockd_up;
 
 
 	/*
 	/*
 	 * Time of server startup
 	 * Time of server startup

+ 21 - 5
fs/nfsd/nfssvc.c

@@ -241,6 +241,11 @@ static void nfsd_shutdown_generic(void)
 	nfsd_racache_shutdown();
 	nfsd_racache_shutdown();
 }
 }
 
 
+static bool nfsd_needs_lockd(void)
+{
+	return (nfsd_versions[2] != NULL) || (nfsd_versions[3] != NULL);
+}
+
 static int nfsd_startup_net(int nrservs, struct net *net)
 static int nfsd_startup_net(int nrservs, struct net *net)
 {
 {
 	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
@@ -255,9 +260,14 @@ static int nfsd_startup_net(int nrservs, struct net *net)
 	ret = nfsd_init_socks(net);
 	ret = nfsd_init_socks(net);
 	if (ret)
 	if (ret)
 		goto out_socks;
 		goto out_socks;
-	ret = lockd_up(net);
-	if (ret)
-		goto out_socks;
+
+	if (nfsd_needs_lockd() && !nn->lockd_up) {
+		ret = lockd_up(net);
+		if (ret)
+			goto out_socks;
+		nn->lockd_up = 1;
+	}
+
 	ret = nfs4_state_start_net(net);
 	ret = nfs4_state_start_net(net);
 	if (ret)
 	if (ret)
 		goto out_lockd;
 		goto out_lockd;
@@ -266,7 +276,10 @@ static int nfsd_startup_net(int nrservs, struct net *net)
 	return 0;
 	return 0;
 
 
 out_lockd:
 out_lockd:
-	lockd_down(net);
+	if (nn->lockd_up) {
+		lockd_down(net);
+		nn->lockd_up = 0;
+	}
 out_socks:
 out_socks:
 	nfsd_shutdown_generic();
 	nfsd_shutdown_generic();
 	return ret;
 	return ret;
@@ -277,7 +290,10 @@ static void nfsd_shutdown_net(struct net *net)
 	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 
 
 	nfs4_state_shutdown_net(net);
 	nfs4_state_shutdown_net(net);
-	lockd_down(net);
+	if (nn->lockd_up) {
+		lockd_down(net);
+		nn->lockd_up = 0;
+	}
 	nn->nfsd_net_up = false;
 	nn->nfsd_net_up = false;
 	nfsd_shutdown_generic();
 	nfsd_shutdown_generic();
 }
 }