The branch main has been updated by asomers:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d1eaa52d10f9b85e5f6358e1a280899b9d55dd07

commit d1eaa52d10f9b85e5f6358e1a280899b9d55dd07
Author:     Alan Somers <asom...@freebsd.org>
AuthorDate: 2025-09-15 00:22:36 +0000
Commit:     Alan Somers <asom...@freebsd.org>
CommitDate: 2025-09-15 00:30:30 +0000

    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 <m...@svmhdvn.name>
    MFC after:      1 week
---
 tests/sys/fs/fusefs/last_local_modify.cc | 12 ++++++++++--
 1 file 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);
 

Reply via email to