From patchwork Fri Dec 27 10:17:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 3411621 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C460E9F169 for ; Fri, 27 Dec 2013 10:18:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8104F2014A for ; Fri, 27 Dec 2013 10:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C40520144 for ; Fri, 27 Dec 2013 10:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754257Ab3L0KSC (ORCPT ); Fri, 27 Dec 2013 05:18:02 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:33139 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754437Ab3L0KRw (ORCPT ); Fri, 27 Dec 2013 05:17:52 -0500 Received: by mail-pa0-f42.google.com with SMTP id lj1so9223220pab.29 for ; Fri, 27 Dec 2013 02:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Hq4rkUfyZN9wEXV9mwKXgMiYuzzNh8flYziysKuBu7I=; b=DmzPe7i6+/E7Owc9bHtOswfEfmrRot81HuGaNhcbBYu2kzc79tTFF/T8sNeMVHI9eK qCwTvKKzySVuEBt3gBrPa/TC6E7wtDc5BARfxRHlzy6BAihr6s7kCwo25l6HjuNoBCwz qVWRUNJs6pMnjRbxQAS3pC5u7FXfIwlHW7bek19BG0+JRwwo74mzAwREkMFzDp9gsC3Z 5YXHkiICDDMNnWIYnmhUapSJkoPIKUnEP20U9ULumk09sq+fESpveiqBYYSjQ5sMYbNj 5W9fS8+ar+/+O6VxmVLnFZ13rsDhIg4KTIc/SdYEN/dQ3/JdUfjThFkQSLqVEwhdnYXW bPJA== X-Received: by 10.66.230.233 with SMTP id tb9mr49582566pac.38.1388139472078; Fri, 27 Dec 2013 02:17:52 -0800 (PST) Received: from [10.10.19.201] ([211.103.180.226]) by mx.google.com with ESMTPSA id ik1sm16371523pbb.18.2013.12.27.02.17.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Dec 2013 02:17:51 -0800 (PST) Message-ID: <52BD53CA.5050205@gmail.com> Date: Fri, 27 Dec 2013 18:17:46 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "J. Bruce Fields" , Gareth Williams CC: linux-nfs@vger.kernel.org Subject: Re: Question ref Running NFS at V4 Only References: <52B47A12.2070202@garethwilliams.me.uk> <20131223173956.GA9221@fieldses.org> In-Reply-To: <20131223173956.GA9221@fieldses.org> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 12/24/2013 01:39 AM, J. Bruce Fields wrote: > On Fri, Dec 20, 2013 at 05:10:42PM +0000, Gareth Williams wrote: >> Hi, >> >> I'm trying to run NFS with protocol version 4 only (that is, with v2 >> & v3 disabled) on a CentOS 6.5 install running as a KVM guest. >> >> The RedHat documentation (amongst others) states that rpcbind isn't >> needed with v4, but if I start nfs without rpcbind I get errors. > > I suspect the kernel code needs to be fixed to not attempt to register > with rpcbind n the v4-only case. (Or to attempt to register but ignore > any error, I'm not sure which is best.) > > And this may not be the only issue in the v4-only case. This isn't > really a priority for me right now, but I'd happily look at patches. Hi all, I make a patch for this problem, please have a check, thanks. From 64c1f96348213f39b9411ab25699a292edbef4ef Mon Sep 17 00:00:00 2001 From: Kinglong Mee Date: Fri, 27 Dec 2013 18:06:25 +0800 Subject: [PATCH] NFSD: supports nfsv4 service without rpcbind 1. set vs_hidden in nfsd_version4 to avoid register nfsv4 to rpcbind 2. don't start lockd when only supports nfsv4. Reported-by: Gareth Williams Signed-off-by: Kinglong Mee --- fs/nfsd/netns.h | 3 +++ fs/nfsd/nfs4proc.c | 1 + fs/nfsd/nfsctl.c | 3 +++ fs/nfsd/nfssvc.c | 21 ++++++++++++++++----- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 849a7c3..ae2c179 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -96,6 +96,9 @@ struct nfsd_net { bool nfsd_net_up; + bool lockd_up; + u32 nfsd_needs_lockd; + /* * Time of server startup */ diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 419572f..1496376 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1881,6 +1881,7 @@ struct svc_version nfsd_version4 = { .vs_proc = nfsd_procedures4, .vs_dispatch = nfsd_dispatch, .vs_xdrsize = NFS4_SVC_XDRSIZE, + .vs_hidden = 1, }; /* diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 7f55517..8c7b0f0 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -575,6 +575,9 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) switch(num) { case 2: case 3: + nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET); + nn->nfsd_needs_lockd = nfsd_vers(num, NFSD_TEST); + break; case 4: nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET); break; diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 760c85a..2b841d8 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -255,9 +255,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 (nn->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 +271,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 +285,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(); }