From patchwork Fri Aug 10 20:44:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 10563139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E93413BB for ; Fri, 10 Aug 2018 20:44:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10CFC2B317 for ; Fri, 10 Aug 2018 20:44:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0533B2B333; Fri, 10 Aug 2018 20:44:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 905A72B317 for ; Fri, 10 Aug 2018 20:44:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbeHJXPs (ORCPT ); Fri, 10 Aug 2018 19:15:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33346 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727151AbeHJXPs (ORCPT ); Fri, 10 Aug 2018 19:15:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F8AB401EF2B for ; Fri, 10 Aug 2018 20:44:21 +0000 (UTC) Received: from coeurl.usersys.redhat.com (ovpn-121-151.rdu2.redhat.com [10.10.121.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63B00100F31F; Fri, 10 Aug 2018 20:44:21 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id 3E121203EF; Fri, 10 Aug 2018 16:44:21 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 1/2] nfsd: allow verson 4.0 to be enabled/disabled via nfs.conf Date: Fri, 10 Aug 2018 16:44:20 -0400 Message-Id: <20180810204421.21882-2-smayhew@redhat.com> In-Reply-To: <20180810204421.21882-1-smayhew@redhat.com> References: <20180810204421.21882-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 20:44:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 20:44:21 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'smayhew@redhat.com' RCPT:'' Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The nfs.conf file has a 'vers4.0' parameter, but nfsd doesn't currently check it. Signed-off-by: Scott Mayhew --- utils/nfsd/nfsd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c index f048631..bd86d11 100644 --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -110,11 +110,7 @@ main(int argc, char **argv) /* We assume the kernel will default all minor versions to 'on', * and allow the config file to disable some. */ - if (NFSCTL_VERISSET(versbits, 4)) { - NFSCTL_MINORSET(minorversset, 0); - NFSCTL_MINORSET(minorvers, 0); - } - for (i = 1; i <= NFS4_MAXMINOR; i++) { + for (i = NFS4_MINMINOR; i <= NFS4_MAXMINOR; i++) { char tag[20]; sprintf(tag, "vers4.%d", i); /* The default for minor version support is to let the From patchwork Fri Aug 10 20:44:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 10563141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D39990E3 for ; Fri, 10 Aug 2018 20:44:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8802B317 for ; Fri, 10 Aug 2018 20:44:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70A6C2B325; Fri, 10 Aug 2018 20:44:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04DFD2B331 for ; Fri, 10 Aug 2018 20:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727151AbeHJXPt (ORCPT ); Fri, 10 Aug 2018 19:15:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33348 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727154AbeHJXPt (ORCPT ); Fri, 10 Aug 2018 19:15:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BDE9401EF2E for ; Fri, 10 Aug 2018 20:44:21 +0000 (UTC) Received: from coeurl.usersys.redhat.com (ovpn-121-151.rdu2.redhat.com [10.10.121.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B0CF2026D6C; Fri, 10 Aug 2018 20:44:21 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id 4224F205D2; Fri, 10 Aug 2018 16:44:21 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 2/2] nfsd: track when the user explicitly requested version 4.0 Date: Fri, 10 Aug 2018 16:44:21 -0400 Message-Id: <20180810204421.21882-3-smayhew@redhat.com> In-Reply-To: <20180810204421.21882-1-smayhew@redhat.com> References: <20180810204421.21882-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 20:44:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 20:44:21 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'smayhew@redhat.com' RCPT:'' Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since both 'rpc.nfsd -V4' and 'rpc.nfsd -V4.0' alter bit 0 in 'minorversset' and 'minorvers', it's not possible to know whether the user explicitly requested version 4.0 or not. Add another variable 'force4dot0' to track when the user explicitly requested version 4.0 so that we can write '4.0' to /proc/fs/nfsd/versions on kernel versions 4.11 and higher. On earlier kernels, we'll still write '4' as in the past. Signed-off-by: Scott Mayhew --- utils/nfsd/nfsd.c | 11 ++++++++++- utils/nfsd/nfssvc.c | 14 +++++++++----- utils/nfsd/nfssvc.h | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c index bd86d11..6b57e2b 100644 --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -72,6 +72,7 @@ main(int argc, char **argv) unsigned int protobits = NFSCTL_PROTODEFAULT; int grace = -1; int lease = -1; + int force4dot0 = 0; progname = basename(argv[0]); haddr = xmalloc(sizeof(char *)); @@ -124,10 +125,14 @@ main(int argc, char **argv) if (!conf_get_bool("nfsd", tag, 1)) { NFSCTL_MINORSET(minorversset, i); NFSCTL_MINORUNSET(minorvers, i); + if (i == 0) + force4dot0 = 1; } if (conf_get_bool("nfsd", tag, 0)) { NFSCTL_MINORSET(minorversset, i); NFSCTL_MINORSET(minorvers, i); + if (i == 0) + force4dot0 = 1; } } @@ -188,6 +193,8 @@ main(int argc, char **argv) } NFSCTL_MINORSET(minorversset, i); NFSCTL_MINORUNSET(minorvers, i); + if (i == 0) + force4dot0 = 1; if (minorvers != 0) break; } else { @@ -215,6 +222,8 @@ main(int argc, char **argv) } NFSCTL_MINORSET(minorversset, i); NFSCTL_MINORSET(minorvers, i); + if (i == 0) + force4dot0 = 1; } else minorvers = minorversset = minormask; /* FALLTHRU */ @@ -331,7 +340,7 @@ main(int argc, char **argv) * Timeouts must also be set before ports are created else we get * EBUSY. */ - nfssvc_setvers(versbits, minorvers, minorversset); + nfssvc_setvers(versbits, minorvers, minorversset, force4dot0); if (grace > 0) nfssvc_set_time("grace", grace); if (lease > 0) diff --git a/utils/nfsd/nfssvc.c b/utils/nfsd/nfssvc.c index 7923f5d..1e6ffd6 100644 --- a/utils/nfsd/nfssvc.c +++ b/utils/nfsd/nfssvc.c @@ -25,6 +25,7 @@ #include "nfslib.h" #include "xlog.h" #include "nfssvc.h" +#include "../mount/version.h" #ifndef NFSD_FS_DIR #define NFSD_FS_DIR "/proc/fs/nfsd" @@ -369,16 +370,18 @@ out: static int nfssvc_print_vers(char *ptr, unsigned size, unsigned vers, unsigned minorvers, - int isset) + int isset, int force4dot0) { char sign = isset ? '+' : '-'; if (minorvers == 0) - return snprintf(ptr, size, "%c%u ", sign, vers); + if (linux_version_code() < MAKE_VERSION(4, 11, 0) || !force4dot0) + return snprintf(ptr, size, "%c%u ", sign, vers); return snprintf(ptr, size, "%c%u.%u ", sign, vers, minorvers); } void -nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorversset) +nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorversset, + int force4dot0) { int fd, n, off; @@ -389,13 +392,14 @@ nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorv for (n = NFSD_MINVERS; n <= ((NFSD_MAXVERS < 3) ? NFSD_MAXVERS : 3); n++) off += nfssvc_print_vers(&buf[off], sizeof(buf) - off, - n, 0, NFSCTL_VERISSET(ctlbits, n)); + n, 0, NFSCTL_VERISSET(ctlbits, n), 0); for (n = 0; n <= NFS4_MAXMINOR; n++) { if (!NFSCTL_MINORISSET(minorversset, n)) continue; off += nfssvc_print_vers(&buf[off], sizeof(buf) - off, - 4, n, NFSCTL_MINORISSET(minorvers, n)); + 4, n, NFSCTL_MINORISSET(minorvers, n), + (n == 0) ? force4dot0 : 0); } if (!off--) goto out; diff --git a/utils/nfsd/nfssvc.h b/utils/nfsd/nfssvc.h index 39ebf37..4d53af1 100644 --- a/utils/nfsd/nfssvc.h +++ b/utils/nfsd/nfssvc.h @@ -26,6 +26,7 @@ int nfssvc_set_sockets(const unsigned int protobits, const char *host, const char *port); void nfssvc_set_time(const char *type, const int seconds); int nfssvc_set_rdmaport(const char *port); -void nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4, unsigned int minorvers4set); +void nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4, + unsigned int minorvers4set, int force4dot0); int nfssvc_threads(int nrservs); void nfssvc_get_minormask(unsigned int *mask);