Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jul 2022 01:49:43 GMT
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 02915e5ff91f - stable/13 - mount_nfs: Warn that intr, soft are not safe for NFSv4
Message-ID:  <202207150149.26F1nhRv034837@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=02915e5ff91f45bf7454c35a24a54bcda83d47ac

commit 02915e5ff91f45bf7454c35a24a54bcda83d47ac
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-07-01 21:43:17 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-07-15 01:45:43 +0000

    mount_nfs: Warn that intr, soft are not safe for NFSv4
    
    If the "intr" and/or "soft" mount options are used for
    NFSv4 mounts, the protocol can be broken when the
    operation returns without waiting for the RPC reply.
    The likelyhood of failure increases for NFSv4.1/4.2
    mounts, since the session slot will be broken when
    an RPC reply is not processed.
    
    This is mentioned in the BUGS section of "man mount_nfs",
    but more needs to be done.  This patch adds code that
    generates a warning message when the mount is done.
    
    PR: 260011
    (cherry picked from commit c0d14b0220ae22d25462cef191f20e9f04c5e87e)
---
 sbin/mount_nfs/mount_nfs.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 6ea861193df8..284b34323885 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
 #include <errno.h>
 #include <fcntl.h>
 #include <netdb.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -160,7 +161,9 @@ main(int argc, char *argv[])
 	char mntpath[MAXPATHLEN], errmsg[255];
 	char hostname[MAXHOSTNAMELEN + 1], gssn[MAXHOSTNAMELEN + 50];
 	const char *gssname, *nmount_errstr;
+	bool softintr;
 
+	softintr = false;
 	iov = NULL;
 	iovlen = 0;
 	memset(errmsg, 0, sizeof(errmsg));
@@ -210,6 +213,7 @@ main(int argc, char *argv[])
 		case 'i':
 			printf("-i deprecated, use -o intr\n");
 			build_iovec(&iov, &iovlen, "intr", NULL, 0);
+			softintr = true;
 			break;
 		case 'L':
 			printf("-L deprecated, use -o nolockd\n");
@@ -366,6 +370,10 @@ main(int argc, char *argv[])
 						    "value -- %s", val);
 					}
 					pass_flag_to_nmount=0;
+				} else if (strcmp(opt, "soft") == 0) {
+					softintr = true;
+				} else if (strcmp(opt, "intr") == 0) {
+					softintr = true;
 				}
 				if (pass_flag_to_nmount) {
 					build_iovec(&iov, &iovlen, opt,
@@ -395,6 +403,7 @@ main(int argc, char *argv[])
 		case 's':
 			printf("-s deprecated, use -o soft\n");
 			build_iovec(&iov, &iovlen, "soft", NULL, 0);
+			softintr = true;
 			break;
 		case 'T':
 			nfsproto = IPPROTO_TCP;
@@ -433,6 +442,11 @@ main(int argc, char *argv[])
 		/* NOTREACHED */
 	}
 
+	/* Warn that NFSv4 mounts only work correctly as hard mounts. */
+	if (mountmode == V4 && softintr)
+		warnx("Warning, options soft and/or intr cannot be safely used"
+		    " for NFSv4. See the BUGS section of mount_nfs(8)");
+
 	spec = *argv++;
 	mntname = *argv;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207150149.26F1nhRv034837>