linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 1/1] mount.nfs: Fix mounting on tmpfs
@ 2021-04-22 19:18 Petr Vorel
  2021-04-22 20:23 ` J . Bruce Fields
  0 siblings, 1 reply; 33+ messages in thread
From: Petr Vorel @ 2021-04-22 19:18 UTC (permalink / raw)
  To: linux-nfs
  Cc: Petr Vorel, Steve Dickson, NeilBrown, Chuck Lever,
	J . Bruce Fields, Alexey Kodanev

LTP NFS tests (which use netns) fails on tmpfs since d4066486:

mount -t nfs -o proto=tcp,vers=4.2 10.0.0.2:/tmp/ltp.nfs01.nfs-4.2/LTP_nfs01.UF6gRZCy3O/4.2/tcp /tmp/ltp.nfs01.nfs-4.2/LTP_nfs01.UF6gRZCy3O/4.2/0
mount.nfs: mounting 10.0.0.2:/tmp/ltp.nfs01.nfs-4.2/LTP_nfs01.UF6gRZCy3O/4.2/tcp failed, reason given by server: No such file or directory

Fixes: d4066486 ("mount.nfs: improve version negotiation when vers=4 is specified.")

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,

not sure, if this is a correct fix thus RFC (I'm not from @umn.edu :)).
I suppose tmpfs is still meant to be supported, but maybe I'm wrong.

I did testing with LTP [1]:

$ for i in 3 4 4.1 4.2; do echo "* version: $i"; PATH="/opt/ltp/testcases/bin:$PATH" nfs01 -v $i -t tcp; done

Core of the tests is nfs_lib.sh [2], which sets network namespace (with
help of tst_net.sh [3]) and setup nfs with exportfs (use fsid to be
working properly on tmpfs) and run various tests with these NFS
versions: 3, 4, 4.1, 4.2.

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp
[2] https://github.com/linux-test-project/ltp/blob/master/testcases/network/nfs/nfs_stress/nfs_lib.sh
[3] https://github.com/linux-test-project/ltp/blob/master/testcases/lib/tst_net.sh

 utils/mount/Makefile.am |  3 ++-
 utils/mount/stropts.c   | 29 ++++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am
index ad0be93b..d3905bec 100644
--- a/utils/mount/Makefile.am
+++ b/utils/mount/Makefile.am
@@ -28,7 +28,8 @@ endif
 mount_nfs_LDADD = ../../support/nfs/libnfs.la \
 		  ../../support/export/libexport.a \
 		  ../../support/misc/libmisc.a \
-		  $(LIBTIRPC)
+		  $(LIBTIRPC) \
+		  $(LIBPTHREAD)
 
 mount_nfs_SOURCES = $(mount_common)
 
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 174a05f6..3961b8ce 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -31,6 +31,7 @@
 #include <time.h>
 
 #include <sys/socket.h>
+#include <sys/statfs.h>
 #include <sys/mount.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -50,6 +51,7 @@
 #include "parse_dev.h"
 #include "conffile.h"
 #include "misc.h"
+#include "nfsd_path.h"
 
 #ifndef NFS_PROGRAM
 #define NFS_PROGRAM	(100003)
@@ -104,6 +106,21 @@ struct nfsmount_info {
 				child;		/* forked bg child? */
 };
 
+/*
+ * Returns TRUE if mounting on tmpfs, otherwise FALSE.
+ */
+static int is_tmpfs(struct nfsmount_info *mi)
+{
+	struct statfs64 st;
+
+	if (nfsd_path_statfs64(mi->node, &st)) {
+		nfs_error(_("%s: Failed to statfs64 on path %s: %s"),
+			  progname, mi->node, strerror(errno));
+		return 0;
+	}
+
+	return st.f_type == 0x01021994;
+}
 
 static void nfs_default_version(struct nfsmount_info *mi)
 {
@@ -873,6 +890,9 @@ static int nfs_try_mount_v4(struct nfsmount_info *mi)
 		case EACCES:
 			continue;
 		default:
+			if (is_tmpfs(mi))
+				return 1;
+
 			goto out;
 		}
 	}
@@ -951,9 +971,12 @@ check_result:
 	}
 
 fall_back:
-	if (mi->version.v_mode == V_GENERAL)
-		/* v2,3 fallback not allowed */
-		return result;
+	if (mi->version.v_mode == V_GENERAL) {
+
+		/* v2,3 fallback not allowed unless tmpfs */
+		if (!is_tmpfs(mi))
+			return result;
+	}
 
 	/*
 	 * Save the original errno in case the v3 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2021-05-23 18:28 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 19:18 [RFC PATCH 1/1] mount.nfs: Fix mounting on tmpfs Petr Vorel
2021-04-22 20:23 ` J . Bruce Fields
2021-04-23  2:17   ` Petr Vorel
2021-04-23 14:23     ` J . Bruce Fields
2021-04-23 17:04       ` Petr Vorel
2021-04-23 18:13         ` J . Bruce Fields
2021-04-23 20:37           ` Petr Vorel
2021-05-03  2:21           ` NeilBrown
2021-05-03  8:10             ` Petr Vorel
2021-05-03 14:15             ` J . Bruce Fields
2021-04-23 13:50   ` Petr Vorel
2021-05-07  1:48     ` [PATCH/RFC nfs-utils] Fix NFSv4 export of tmpfs filesystems NeilBrown
2021-05-07 10:06       ` Petr Vorel
2021-05-13  4:07         ` NeilBrown
2021-05-13 18:38           ` Petr Vorel
2021-05-13 18:51             ` Petr Vorel
2021-05-17  3:08               ` NeilBrown
2021-05-17 14:27                 ` Petr Vorel
2021-05-07 13:55       ` Chuck Lever III
2021-05-07 23:13         ` NeilBrown
2021-05-17  4:45       ` [PATCH/RFC v2 " NeilBrown
2021-05-17 15:00         ` Petr Vorel
2021-05-18 17:54         ` Petr Vorel
2021-05-20 17:37         ` Steve Dickson
2021-05-20 20:39           ` Petr Vorel
2021-05-21  1:38           ` NeilBrown
2021-05-21  1:40             ` [PATCH nfs-utils 1/2] Remove 'force' arg from cache_flush() NeilBrown
2021-05-21  1:41               ` [PATCH nfs-utils 2/2] Move declaration of etab and rmtab into libraries NeilBrown
2021-05-21 13:57                 ` Petr Vorel
2021-05-23 18:31                 ` Steve Dickson
2021-05-21 13:52               ` [PATCH nfs-utils 1/2] Remove 'force' arg from cache_flush() Petr Vorel
2021-05-23 18:30               ` Steve Dickson
2021-05-23 18:29         ` [PATCH/RFC v2 nfs-utils] Fix NFSv4 export of tmpfs filesystems Steve Dickson

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).