linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alice J Mitchell <ajmitchell@redhat.com>
To: Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: [PATCH nfs-utils] Simplify vers string generation to fix issues with 4.0 handling
Date: Tue, 22 Oct 2019 17:29:21 +0100	[thread overview]
Message-ID: <1571761761.9226.3.camel@redhat.com> (raw)

The existing handling does not correctly cope the case of disabling
v4.0 and then later not disabling it, the default strings omit the 4.0
flags and it thus does not get re-enabled. this simplified version
correctly handles this and other similar cases.

Signed-off-by: Alice J Mitchell <ajmitchell@redhat.com>
---
 utils/nfsd/nfsd.c   | 11 +----------
 utils/nfsd/nfssvc.c | 21 ++++++++++-----------
 utils/nfsd/nfssvc.h |  2 +-
 3 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
index a412a02..0c1f6cb 100644
--- a/utils/nfsd/nfsd.c
+++ b/utils/nfsd/nfsd.c
@@ -72,7 +72,6 @@ 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 *));
@@ -141,14 +140,10 @@ 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;
 		}
 	}
 
@@ -209,8 +204,6 @@ main(int argc, char **argv)
 					}
 					NFSCTL_MINORSET(minorversset, i);
 					NFSCTL_MINORUNSET(minorvers, i);
-					if (i == 0)
-						force4dot0 = 1;
 					if (minorvers != 0)
 						break;
 				} else {
@@ -238,8 +231,6 @@ main(int argc, char **argv)
 					}
 					NFSCTL_MINORSET(minorversset, i);
 					NFSCTL_MINORSET(minorvers, i);
-					if (i == 0)
-						force4dot0 = 1;
 				} else
 					minorvers = minorversset = minormask;
 				/* FALLTHRU */
@@ -356,7 +347,7 @@ main(int argc, char **argv)
 	 * Timeouts must also be set before ports are created else we get
 	 * EBUSY.
 	 */
-	nfssvc_setvers(versbits, minorvers, minorversset, force4dot0);
+	nfssvc_setvers(versbits, minorvers, minorversset);
 	if (grace > 0)
 		nfssvc_set_time("grace", grace);
 	if (lease  > 0)
diff --git a/utils/nfsd/nfssvc.c b/utils/nfsd/nfssvc.c
index 720bdd9..1770ac2 100644
--- a/utils/nfsd/nfssvc.c
+++ b/utils/nfsd/nfssvc.c
@@ -368,19 +368,17 @@ out:
 }
 
 static int
-nfssvc_print_vers(char *ptr, unsigned size, unsigned vers, unsigned minorvers,
-		int isset, int force4dot0)
+nfssvc_print_vers(char *ptr, unsigned size, unsigned vers, int minorvers,
+		int isset)
 {
 	char sign = isset ? '+' : '-';
-	if (minorvers == 0)
-		if (linux_version_code() < MAKE_VERSION(4, 11, 0) || !force4dot0)
-			return snprintf(ptr, size, "%c%u ", sign, vers);
+	if (minorvers < 0)
+		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,
-	       int force4dot0)
+nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorversset)
 {
 	int fd, n, off;
 
@@ -389,16 +387,17 @@ nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorv
 	if (fd < 0)
 		return;
 
-	for (n = NFSD_MINVERS; n <= ((NFSD_MAXVERS < 3) ? NFSD_MAXVERS : 3); n++)
+	for (n = NFSD_MINVERS; n <= ((NFSD_MAXVERS < 4) ? NFSD_MAXVERS : 4); n++)
 		off += nfssvc_print_vers(&buf[off], sizeof(buf) - off,
-				n, 0, NFSCTL_VERISSET(ctlbits, n), 0);
+				n, -1, NFSCTL_VERISSET(ctlbits, n));
 
 	for (n = 0; n <= NFS4_MAXMINOR; n++) {
 		if (!NFSCTL_MINORISSET(minorversset, n))
 			continue;
+		if (n == 0 && linux_version_code() < MAKE_VERSION(4, 11, 0))
+			continue;
 		off += nfssvc_print_vers(&buf[off], sizeof(buf) - off,
-				4, n, NFSCTL_MINORISSET(minorvers, n),
-				(n == 0) ? force4dot0 : 0);
+				4, n, NFSCTL_MINORISSET(minorvers, n));
 	}
 	if (!off--)
 		goto out;
diff --git a/utils/nfsd/nfssvc.h b/utils/nfsd/nfssvc.h
index 4d53af1..bf747b7 100644
--- a/utils/nfsd/nfssvc.h
+++ b/utils/nfsd/nfssvc.h
@@ -27,6 +27,6 @@ int	nfssvc_set_sockets(const unsigned int protobits,
 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, int force4dot0);
+		       unsigned int minorvers4set);
 int	nfssvc_threads(int nrservs);
 void	nfssvc_get_minormask(unsigned int *mask);
-- 
1.8.3.1


                 reply	other threads:[~2019-10-22 16:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1571761761.9226.3.camel@redhat.com \
    --to=ajmitchell@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).