Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Mar 2019 02:01:34 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345565 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs
Message-ID:  <201903270201.x2R21Yad021095@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Mar 27 02:01:34 2019
New Revision: 345565
URL: https://svnweb.freebsd.org/changeset/base/345565

Log:
  FUSEFS: during FUSE_READDIR, set the read size correctly.
  
  The old formula was unnecessarily restrictive.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/fuse2/sys/fs/fuse/fuse_internal.c
  projects/fuse2/tests/sys/fs/fusefs/readdir.cc

Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c
==============================================================================
--- projects/fuse2/sys/fs/fuse/fuse_internal.c	Wed Mar 27 01:49:35 2019	(r345564)
+++ projects/fuse2/sys/fs/fuse/fuse_internal.c	Wed Mar 27 02:01:34 2019	(r345565)
@@ -353,12 +353,8 @@ fuse_internal_readdir(struct vnode *vp,
 		fri = fdi.indata;
 		fri->fh = fufh->fh_id;
 		fri->offset = uio_offset(uio);
-		/*
-		 * XXX AWS Try removing the min(...,4096).  I'm pretty sure
-		 * there's no reason for it to be there.
-		 */
-		fri->size = min(uio_resid(uio), 4096);
-		/* mp->max_read */
+		fri->size = MIN(uio->uio_resid,
+		    fuse_get_mpdata(vp->v_mount)->max_read);
 
 		    if ((err = fdisp_wait_answ(&fdi))) {
 			break;

Modified: projects/fuse2/tests/sys/fs/fusefs/readdir.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fusefs/readdir.cc	Wed Mar 27 01:49:35 2019	(r345564)
+++ projects/fuse2/tests/sys/fs/fusefs/readdir.cc	Wed Mar 27 02:01:34 2019	(r345565)
@@ -187,6 +187,40 @@ TEST_F(Readdir, eio)
 	/* Deliberately leak dir.  RELEASEDIR will be tested separately */
 }
 
+/* getdirentries(2) can use a larger buffer size than readdir(3) */
+TEST_F(Readdir, getdirentries)
+{
+	const char FULLPATH[] = "mountpoint/some_dir";
+	const char RELPATH[] = "some_dir";
+	uint64_t ino = 42;
+	int fd;
+	char buf[8192];
+	ssize_t r;
+
+	expect_lookup(RELPATH, ino);
+	expect_opendir(ino);
+
+	EXPECT_CALL(*m_mock, process(
+		ResultOf([=](auto in) {
+			return (in->header.opcode == FUSE_READDIR &&
+				in->header.nodeid == ino &&
+				in->body.readdir.size == 8192);
+		}, Eq(true)),
+		_)
+	).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
+		out->header.error = 0;
+		out->header.len = sizeof(out->header);
+	})));
+
+	errno = 0;
+	fd = open(FULLPATH, O_DIRECTORY);
+	ASSERT_LE(0, fd) << strerror(errno);
+	r = getdirentries(fd, buf, sizeof(buf), 0);
+	ASSERT_EQ(0, r);
+
+	/* Deliberately leak dir.  RELEASEDIR will be tested separately */
+}
+
 /*
  * FUSE_READDIR returns nothing, not even "." and "..".  This is legal, though
  * the filesystem obviously won't be fully functional.



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