aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2025-09-15 00:22:36 +0000
committerAlan Somers <asomers@FreeBSD.org>2025-09-15 00:30:30 +0000
commitd1eaa52d10f9b85e5f6358e1a280899b9d55dd07 (patch)
tree61b7f11c589a1cc497c5097b864a282ec518aa28
parente779891327b1d9b9ab10ba482e59f498790505a7 (diff)
fusefs: fix the last_local_modify LLM/LastLocalModify.lookup/3 test
The LastLocalModify tests were originally written to simulate a race condition between VOP_SETATTR and VOP_LOOKUP. They were later extended to cover some other VOPs that can affect file size, including VOP_WRITE. However, the test never correctly simulated the race with VOP_WRITE. So that test only ever passed by accident. Fix it by always opening the file with O_DIRECT. PR: 289237 Reported by: Siva Mahadevan <me@svmhdvn.name> MFC after: 1 week
-rw-r--r--tests/sys/fs/fusefs/last_local_modify.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/sys/fs/fusefs/last_local_modify.cc b/tests/sys/fs/fusefs/last_local_modify.cc
index 5fcd3c36c892..6b8c19f1efc7 100644
--- a/tests/sys/fs/fusefs/last_local_modify.cc
+++ b/tests/sys/fs/fusefs/last_local_modify.cc
@@ -174,7 +174,15 @@ static void* write_th(void* arg) {
if (sem)
sem_wait(sem);
- fd = open("mountpoint/some_file.txt", O_RDWR);
+ /*
+ * Open the file in direct mode.
+ * The race condition affects both direct and non-direct writes, and
+ * they have separate code paths. However, in the non-direct case, the
+ * kernel updates last_local_modify _before_ sending FUSE_WRITE to the
+ * server. So the technique that this test program uses to invoke the
+ * race cannot work. Therefore, test with O_DIRECT only.
+ */
+ fd = open("mountpoint/some_file.txt", O_RDWR | O_DIRECT);
if (fd < 0)
return (void*)(intptr_t)errno;
@@ -332,7 +340,7 @@ TEST_P(LastLocalModify, lookup)
/* Wait for FUSE_SETATTR to be sent */
sem_wait(&sem);
- /* Lookup again, which will race with setattr */
+ /* Lookup again, which will race with the mutator */
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
ASSERT_EQ((off_t)newsize, sb.st_size);