svn commit: r345390 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs

Alan Somers asomers at FreeBSD.org
Thu Mar 21 21:53:57 UTC 2019


Author: asomers
Date: Thu Mar 21 21:53:55 2019
New Revision: 345390
URL: https://svnweb.freebsd.org/changeset/base/345390

Log:
  fusefs: VOP_FSYNC should be synchronous
  
  returning asynchronously pretty much defeats the point of fsync
  
  PR:		236474
  Sponsored by:	The FreeBSD Foundation

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

Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c
==============================================================================
--- projects/fuse2/sys/fs/fuse/fuse_internal.c	Thu Mar 21 21:45:18 2019	(r345389)
+++ projects/fuse2/sys/fs/fuse/fuse_internal.c	Thu Mar 21 21:53:55 2019	(r345390)
@@ -287,6 +287,7 @@ fuse_internal_fsync(struct vnode *vp,
 	int op = FUSE_FSYNC;
 	struct fuse_fsync_in *ffsi;
 	struct fuse_dispatcher fdi;
+	int err;
 
 	if (vnode_isdir(vp)) {
 		op = FUSE_FSYNCDIR;
@@ -298,13 +299,10 @@ fuse_internal_fsync(struct vnode *vp,
 
 	ffsi->fsync_flags = 1;		/* datasync */
 
-	fuse_insert_callback(fdi.tick, fuse_internal_fsync_callback);
-	fuse_insert_message(fdi.tick);
-
+	err = fdisp_wait_answ(&fdi);
 	fdisp_destroy(&fdi);
 
-	return 0;
-
+	return err;
 }
 
 /* readdir */

Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c
==============================================================================
--- projects/fuse2/sys/fs/fuse/fuse_vnops.c	Thu Mar 21 21:45:18 2019	(r345389)
+++ projects/fuse2/sys/fs/fuse/fuse_vnops.c	Thu Mar 21 21:53:55 2019	(r345390)
@@ -454,12 +454,12 @@ fuse_vnop_fsync(struct vop_fsync_args *ap)
 	for (type = 0; type < FUFH_MAXTYPE; type++) {
 		fufh = &(fvdat->fufh[type]);
 		if (FUFH_IS_VALID(fufh)) {
-			fuse_internal_fsync(vp, td, NULL, fufh);
+			err = fuse_internal_fsync(vp, td, NULL, fufh);
 		}
 	}
 
 out:
-	return 0;
+	return err;
 }
 
 /*

Modified: projects/fuse2/tests/sys/fs/fusefs/fsync.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fusefs/fsync.cc	Thu Mar 21 21:45:18 2019	(r345389)
+++ projects/fuse2/tests/sys/fs/fusefs/fsync.cc	Thu Mar 21 21:53:55 2019	(r345390)
@@ -77,7 +77,6 @@ void expect_write(uint64_t ino, uint64_t size, const v
 
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */
-/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
 TEST_F(Fsync, DISABLED_aio_fsync)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
@@ -149,8 +148,7 @@ TEST_F(Fsync, close)
 	close(fd);
 }
 
-/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
-TEST_F(Fsync, DISABLED_eio)
+TEST_F(Fsync, eio)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";
@@ -179,7 +177,6 @@ TEST_F(Fsync, DISABLED_eio)
  * subsequent calls to VOP_FSYNC will succeed automatically without being sent
  * to the filesystem daemon
  */
-/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236557 */
 TEST_F(Fsync, DISABLED_enosys)
 {
@@ -207,8 +204,7 @@ TEST_F(Fsync, DISABLED_enosys)
 }
 
 
-/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
-TEST_F(Fsync, DISABLED_fdatasync)
+TEST_F(Fsync, fdatasync)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";
@@ -232,7 +228,6 @@ TEST_F(Fsync, DISABLED_fdatasync)
 }
 
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */
-/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
 TEST_F(Fsync, DISABLED_fsync)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
@@ -258,7 +253,6 @@ TEST_F(Fsync, DISABLED_fsync)
 
 /* Fsync should sync a file with dirty metadata but clean data */
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */
-/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
 TEST_F(Fsync, DISABLED_fsync_metadata_only)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
@@ -289,25 +283,3 @@ TEST_F(Fsync, DISABLED_fsync_metadata_only)
 	ASSERT_EQ(0, fsync(fd)) << strerror(errno);
 	/* Deliberately leak fd.  close(2) will be tested in release.cc */
 }
-
-// fsync()ing a file that isn't dirty should be a no-op
-TEST_F(Fsync, nop)
-{
-	const char FULLPATH[] = "mountpoint/some_file.txt";
-	const char RELPATH[] = "some_file.txt";
-	uint64_t ino = 42;
-	int fd;
-
-	expect_lookup(RELPATH, ino);
-	expect_open(ino, 0, 1);
-	expect_getattr(ino, 0);
-
-	fd = open(FULLPATH, O_WRONLY);
-	ASSERT_LE(0, fd) << strerror(errno);
-
-	ASSERT_EQ(0, fsync(fd)) << strerror(errno);
-
-	/* Deliberately leak fd.  close(2) will be tested in release.cc */
-}
-
-// TODO: ENOSYS test


More information about the svn-src-projects mailing list