Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106949951
D33159.id100796.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D33159.id100796.diff
View Options
diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -807,6 +807,8 @@
fuse_vnode_setsize(outvp, *ap->a_outoffp, false);
getnanouptime(&outfvdat->last_local_modify);
}
+ fuse_vnode_update(invp, FN_ATIMECHANGE);
+ fuse_vnode_update(outvp, FN_MTIMECHANGE | FN_CTIMECHANGE);
}
fdisp_destroy(&fdi);
diff --git a/tests/sys/fs/fusefs/copy_file_range.cc b/tests/sys/fs/fusefs/copy_file_range.cc
--- a/tests/sys/fs/fusefs/copy_file_range.cc
+++ b/tests/sys/fs/fusefs/copy_file_range.cc
@@ -129,6 +129,14 @@
}
};
+class CopyFileRangeNoAtime: public CopyFileRange {
+public:
+virtual void SetUp() {
+ m_noatime = true;
+ CopyFileRange::SetUp();
+}
+};
+
TEST_F(CopyFileRange, eio)
{
const char FULLPATH1[] = "mountpoint/src.txt";
@@ -431,6 +439,74 @@
ASSERT_EQ(len, copy_file_range(fd, &off_in, fd, &off_out, len, 0));
}
+/*
+ * copy_file_range should update the destination's mtime and ctime, and
+ * the source's atime.
+ */
+TEST_F(CopyFileRange, timestamps)
+{
+ const char FULLPATH1[] = "mountpoint/src.txt";
+ const char RELPATH1[] = "src.txt";
+ const char FULLPATH2[] = "mountpoint/dst.txt";
+ const char RELPATH2[] = "dst.txt";
+ struct stat sb1a, sb1b, sb2a, sb2b;
+ const uint64_t ino1 = 42;
+ const uint64_t ino2 = 43;
+ const uint64_t fh1 = 0xdeadbeef1a7ebabe;
+ const uint64_t fh2 = 0xdeadc0de88c0ffee;
+ off_t fsize1 = 1 << 20; /* 1 MiB */
+ off_t fsize2 = 1 << 19; /* 512 KiB */
+ off_t start1 = 1 << 18;
+ off_t start2 = 3 << 17;
+ ssize_t len = 65536;
+ int fd1, fd2;
+
+ expect_lookup(RELPATH1, ino1, S_IFREG | 0644, fsize1, 1);
+ expect_lookup(RELPATH2, ino2, S_IFREG | 0644, fsize2, 1);
+ expect_open(ino1, 0, 1, fh1);
+ expect_open(ino2, 0, 1, fh2);
+ EXPECT_CALL(*m_mock, process(
+ ResultOf([=](auto in) {
+ return (in.header.opcode == FUSE_COPY_FILE_RANGE &&
+ in.header.nodeid == ino1 &&
+ in.body.copy_file_range.fh_in == fh1 &&
+ (off_t)in.body.copy_file_range.off_in == start1 &&
+ in.body.copy_file_range.nodeid_out == ino2 &&
+ in.body.copy_file_range.fh_out == fh2 &&
+ (off_t)in.body.copy_file_range.off_out == start2 &&
+ in.body.copy_file_range.len == (size_t)len &&
+ in.body.copy_file_range.flags == 0);
+ }, Eq(true)),
+ _)
+ ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
+ SET_OUT_HEADER_LEN(out, write);
+ out.body.write.size = len;
+ })));
+
+ fd1 = open(FULLPATH1, O_RDONLY);
+ ASSERT_GE(fd1, 0);
+ fd2 = open(FULLPATH2, O_WRONLY);
+ ASSERT_GE(fd2, 0);
+ ASSERT_EQ(0, fstat(fd1, &sb1a)) << strerror(errno);
+ ASSERT_EQ(0, fstat(fd2, &sb2a)) << strerror(errno);
+
+ nap();
+
+ ASSERT_EQ(len, copy_file_range(fd1, &start1, fd2, &start2, len, 0));
+ ASSERT_EQ(0, fstat(fd1, &sb1b)) << strerror(errno);
+ ASSERT_EQ(0, fstat(fd2, &sb2b)) << strerror(errno);
+
+ EXPECT_NE(sb1a.st_atime, sb1b.st_atime);
+ EXPECT_EQ(sb1a.st_mtime, sb1b.st_mtime);
+ EXPECT_EQ(sb1a.st_ctime, sb1b.st_ctime);
+ EXPECT_EQ(sb2a.st_atime, sb2b.st_atime);
+ EXPECT_NE(sb2a.st_mtime, sb2b.st_mtime);
+ EXPECT_NE(sb2a.st_ctime, sb2b.st_ctime);
+
+ leak(fd1);
+ leak(fd2);
+}
+
/*
* copy_file_range can extend the size of a file
* */
@@ -523,4 +599,70 @@
ASSERT_EQ(len, copy_file_range(fd1, &start1, fd2, &start2, len, 0));
}
+/*
+ * With -o noatime, copy_file_range should update the destination's mtime and
+ * ctime, but not the source's atime.
+ */
+TEST_F(CopyFileRangeNoAtime, timestamps)
+{
+ const char FULLPATH1[] = "mountpoint/src.txt";
+ const char RELPATH1[] = "src.txt";
+ const char FULLPATH2[] = "mountpoint/dst.txt";
+ const char RELPATH2[] = "dst.txt";
+ struct stat sb1a, sb1b, sb2a, sb2b;
+ const uint64_t ino1 = 42;
+ const uint64_t ino2 = 43;
+ const uint64_t fh1 = 0xdeadbeef1a7ebabe;
+ const uint64_t fh2 = 0xdeadc0de88c0ffee;
+ off_t fsize1 = 1 << 20; /* 1 MiB */
+ off_t fsize2 = 1 << 19; /* 512 KiB */
+ off_t start1 = 1 << 18;
+ off_t start2 = 3 << 17;
+ ssize_t len = 65536;
+ int fd1, fd2;
+ expect_lookup(RELPATH1, ino1, S_IFREG | 0644, fsize1, 1);
+ expect_lookup(RELPATH2, ino2, S_IFREG | 0644, fsize2, 1);
+ expect_open(ino1, 0, 1, fh1);
+ expect_open(ino2, 0, 1, fh2);
+ EXPECT_CALL(*m_mock, process(
+ ResultOf([=](auto in) {
+ return (in.header.opcode == FUSE_COPY_FILE_RANGE &&
+ in.header.nodeid == ino1 &&
+ in.body.copy_file_range.fh_in == fh1 &&
+ (off_t)in.body.copy_file_range.off_in == start1 &&
+ in.body.copy_file_range.nodeid_out == ino2 &&
+ in.body.copy_file_range.fh_out == fh2 &&
+ (off_t)in.body.copy_file_range.off_out == start2 &&
+ in.body.copy_file_range.len == (size_t)len &&
+ in.body.copy_file_range.flags == 0);
+ }, Eq(true)),
+ _)
+ ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
+ SET_OUT_HEADER_LEN(out, write);
+ out.body.write.size = len;
+ })));
+
+ fd1 = open(FULLPATH1, O_RDONLY);
+ ASSERT_GE(fd1, 0);
+ fd2 = open(FULLPATH2, O_WRONLY);
+ ASSERT_GE(fd2, 0);
+ ASSERT_EQ(0, fstat(fd1, &sb1a)) << strerror(errno);
+ ASSERT_EQ(0, fstat(fd2, &sb2a)) << strerror(errno);
+
+ nap();
+
+ ASSERT_EQ(len, copy_file_range(fd1, &start1, fd2, &start2, len, 0));
+ ASSERT_EQ(0, fstat(fd1, &sb1b)) << strerror(errno);
+ ASSERT_EQ(0, fstat(fd2, &sb2b)) << strerror(errno);
+
+ EXPECT_EQ(sb1a.st_atime, sb1b.st_atime);
+ EXPECT_EQ(sb1a.st_mtime, sb1b.st_mtime);
+ EXPECT_EQ(sb1a.st_ctime, sb1b.st_ctime);
+ EXPECT_EQ(sb2a.st_atime, sb2b.st_atime);
+ EXPECT_NE(sb2a.st_mtime, sb2b.st_mtime);
+ EXPECT_NE(sb2a.st_ctime, sb2b.st_ctime);
+
+ leak(fd1);
+ leak(fd2);
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 11:01 PM (3 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15727176
Default Alt Text
D33159.id100796.diff (5 KB)
Attached To
Mode
D33159: fusefs: copy_file_range must update file timestamps
Attached
Detach File
Event Timeline
Log In to Comment