Return-Path: linux-nfs-owner@vger.kernel.org Received: from mail-pd0-f180.google.com ([209.85.192.180]:61722 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099Ab3LaFRi (ORCPT ); Tue, 31 Dec 2013 00:17:38 -0500 Received: by mail-pd0-f180.google.com with SMTP id q10so11975439pdj.25 for ; Mon, 30 Dec 2013 21:17:37 -0800 (PST) Message-ID: <52C2536A.5070906@gmail.com> Date: Tue, 31 Dec 2013 13:17:30 +0800 From: Kinglong Mee MIME-Version: 1.0 To: Chuck Lever CC: "J.,Bruce Fields" , Gareth Williams , Linux NFS Mailing List , trond.myklebust@primarydata.com Subject: [PATCH 2/2 v2] NFSD: Don't start lockd when only NFSv4 is running References: <52B47A12.2070202@garethwilliams.me.uk> <20131223173956.GA9221@fieldses.org> <52BD53CA.5050205@gmail.com> <7FD776EA-EAA8-41E0-9567-BF3924D365AC@oracle.com> <20131227184309.GA9161@fieldses.org> <01763B6D-C8CB-46B7-87AC-CE189496019A@oracle.com> <6E281EC9-49CB-4BDA-BDF3-7A6F4B703156@gmail.com> <5D65FDE6-D1AB-442C-BFD8-141AB87FF321@gmail.com> <52C1577B.9080100@gmail.com> <52C15847.9030208@gmail.com> <68E6D30F-B2D6-4919-9748-E7F1162AC3B7@oracle.com> <52C2377E.8040006@gmail.com> In-Reply-To: <52C2377E.8040006@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-nfs-owner@vger.kernel.org List-ID: When starting without nfsv2 and nfsv3, nfsd should not setup lockd, especially when rpcbind is stop. v2: move setting nfsd_version4's vs_rpcb_optnl option to new patch [1/2] Reported-by: Gareth Williams Reviewed-by: Chuck Lever Signed-off-by: Kinglong Mee --- fs/nfsd/netns.h | 1 + fs/nfsd/nfssvc.c | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 849a7c3..d32b3aa 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -95,6 +95,7 @@ struct nfsd_net { time_t nfsd4_grace; bool nfsd_net_up; + bool lockd_up; /* * Time of server startup diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 760c85a..55b5b57 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -241,6 +241,11 @@ static void nfsd_shutdown_generic(void) 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) { 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); if (ret) 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); if (ret) goto out_lockd; @@ -266,7 +276,10 @@ static int nfsd_startup_net(int nrservs, struct net *net) return 0; out_lockd: - lockd_down(net); + if (nn->lockd_up) { + lockd_down(net); + nn->lockd_up = 0; + } out_socks: nfsd_shutdown_generic(); return ret; @@ -277,7 +290,10 @@ static void nfsd_shutdown_net(struct net *net) struct nfsd_net *nn = net_generic(net, nfsd_net_id); nfs4_state_shutdown_net(net); - lockd_down(net); + if (nn->lockd_up) { + lockd_down(net); + nn->lockd_up = 0; + } nn->nfsd_net_up = false; nfsd_shutdown_generic(); } -- 1.8.4.2