Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Mar 2019 00:35:59 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345720 - projects/fuse2/tests/sys/fs/fusefs
Message-ID:  <201903300035.x2U0ZxOk077634@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Sat Mar 30 00:35:59 2019
New Revision: 345720
URL: https://svnweb.freebsd.org/changeset/base/345720

Log:
  fusefs: fix tests when data caching is disabled
  
  VOP_GETPAGES is disabled when vfs.fusefs.data_cache_mode=0, causing mmap to
  return success but accessing the mapped memory will subsequently segfault.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/fuse2/tests/sys/fs/fusefs/read.cc

Modified: projects/fuse2/tests/sys/fs/fusefs/read.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fusefs/read.cc	Sat Mar 30 00:35:32 2019	(r345719)
+++ projects/fuse2/tests/sys/fs/fusefs/read.cc	Sat Mar 30 00:35:59 2019	(r345720)
@@ -78,6 +78,23 @@ class AsyncRead: public AioRead {
 	}
 };
 
+class ReadMmap: public Read {
+public:
+virtual void SetUp() {
+	const char *node = "vfs.fusefs.data_cache_mode";
+	int val = 0;
+	size_t size = sizeof(val);
+
+	FuseTest::SetUp();
+
+	ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
+		<< strerror(errno);
+	if (val == 0)
+		GTEST_SKIP() <<
+			"fusefs data caching must be enabled for this test";
+}
+};
+
 class ReadAhead: public Read, public WithParamInterface<uint32_t> {
 	virtual void SetUp() {
 		m_maxreadahead = GetParam();
@@ -450,7 +467,7 @@ TEST_F(Read, keep_cache_disabled)
 	/* Deliberately leak fd0 and fd1. */
 }
 
-TEST_F(Read, mmap)
+TEST_F(ReadMmap, mmap)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";
@@ -621,7 +638,7 @@ TEST_F(Read, default_readahead)
 }
 
 /* Reading with sendfile should work (though it obviously won't be 0-copy) */
-TEST_F(Read, sendfile)
+TEST_F(ReadMmap, sendfile)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";
@@ -668,7 +685,7 @@ TEST_F(Read, sendfile)
 
 /* sendfile should fail gracefully if fuse declines the read */
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236466 */
-TEST_F(Read, DISABLED_sendfile_eio)
+TEST_F(ReadMmap, DISABLED_sendfile_eio)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";



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