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

Alan Somers asomers at FreeBSD.org
Wed Jun 26 00:03:38 UTC 2019


Author: asomers
Date: Wed Jun 26 00:03:37 2019
New Revision: 349397
URL: https://svnweb.freebsd.org/changeset/base/349397

Log:
  fusefs: set ctime during FUSE_SETATTR following a write
  
  As of r349396 the kernel will internally update the mtime and ctime of files
  on write.  It will also flush the mtime should a SETATTR happen before the
  data cache gets flushed.  Now it will flush the ctime too, if the server is
  using protocol 7.23 or higher.
  
  This is the only case in which the kernel will explicitly set a file's
  ctime, since neither utimensat(2) nor any other user interfaces allow it.
  
  Sponsored by:	The FreeBSD Foundation

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

Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c
==============================================================================
--- projects/fuse2/sys/fs/fuse/fuse_internal.c	Tue Jun 25 23:40:18 2019	(r349396)
+++ projects/fuse2/sys/fs/fuse/fuse_internal.c	Wed Jun 26 00:03:37 2019	(r349397)
@@ -1074,6 +1074,11 @@ int fuse_internal_setattr(struct vnode *vp, struct vat
 		fsai->mtimensec = fvdat->cached_attrs.va_mtime.tv_nsec;
 		fsai->valid |= FATTR_MTIME;
 	}
+	if (fuse_libabi_geq(data, 7, 23) && fvdat->flag & FN_CTIMECHANGE) {
+		fsai->ctime = fvdat->cached_attrs.va_ctime.tv_sec;
+		fsai->ctimensec = fvdat->cached_attrs.va_ctime.tv_nsec;
+		fsai->valid |= FATTR_CTIME;
+	}
 	if (vap->va_mode != (mode_t)VNOVAL) {
 		fsai->mode = vap->va_mode & ALLPERMS;
 		fsai->valid |= FATTR_MODE;

Modified: projects/fuse2/tests/sys/fs/fusefs/write.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fusefs/write.cc	Tue Jun 25 23:40:18 2019	(r349396)
+++ projects/fuse2/tests/sys/fs/fusefs/write.cc	Wed Jun 26 00:03:37 2019	(r349397)
@@ -1117,8 +1117,7 @@ TEST_F(WriteBackAsync, timestamps_during_setattr)
 	expect_open(ino, 0, 1);
 	EXPECT_CALL(*m_mock, process(
 		ResultOf([=](auto in) {
-			/* In protocol 7.23, ctime will be changed too */
-			uint32_t valid = FATTR_MODE | FATTR_MTIME;
+			uint32_t valid = FATTR_MODE | FATTR_MTIME | FATTR_CTIME;
 			return (in.header.opcode == FUSE_SETATTR &&
 				in.header.nodeid == ino &&
 				in.body.setattr.valid == valid);


More information about the svn-src-projects mailing list