Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Aug 2026 15:10:23 +0000
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1fcd8291b9ef - stable/14 - fusefs: fix a race in the pre-init tests
Message-ID:  <6a73525f.45e96.6db9f9f1@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by asomers:

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

commit 1fcd8291b9efc99e1d80e8e130f45c66e54d777e
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2026-06-23 17:12:04 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2026-08-05 15:08:50 +0000

    fusefs: fix a race in the pre-init tests
    
    These tests allow the user to customize the INIT response.  But it's
    necessary to block the daemon's service loop from running until those
    expectations have been set.  This race has never caused failures before
    simply due to luck.  But now it's failing on slower platforms.
    
    PR:             296236
    Reported by:    siva
    Sponsored by:   ConnectWise
    Reviewed by:    siva
    Differential Revision: https://reviews.freebsd.org/D57781
    
    (cherry picked from commit 2c1482e305368af182a7bde0e53d0d180b319326)
---
 tests/sys/fs/fusefs/mockfs.cc   | 11 ++++++++---
 tests/sys/fs/fusefs/mockfs.hh   |  3 +++
 tests/sys/fs/fusefs/pre-init.cc |  6 ++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc
index ba4c3381eff2..fb1a29e85496 100644
--- a/tests/sys/fs/fusefs/mockfs.cc
+++ b/tests/sys/fs/fusefs/mockfs.cc
@@ -540,9 +540,8 @@ MockFS::MockFS(int max_read, int max_readahead, bool allow_other,
 	if (0 != sigaction(SIGUSR1, &sa, NULL))
 		throw(std::system_error(errno, std::system_category(),
 			"Couldn't handle SIGUSR1"));
-	if (pthread_create(&m_daemon_id, NULL, service, (void*)this))
-		throw(std::system_error(errno, std::system_category(),
-			"Couldn't Couldn't start fuse thread"));
+	if (!no_auto_init)
+		start_service();
 }
 
 MockFS::~MockFS() {
@@ -998,6 +997,12 @@ void MockFS::read_request(mockfs_buf_in &in, ssize_t &res) {
 	ASSERT_TRUE(res == static_cast<ssize_t>(in.header.len) || m_quit);
 }
 
+void MockFS::start_service() {
+	if (pthread_create(&m_daemon_id, NULL, service, (void*)this))
+		throw(std::system_error(errno, std::system_category(),
+			"Couldn't Couldn't start fuse thread"));
+}
+
 void MockFS::write_response(const mockfs_buf_out &out) {
 	fd_set writefds;
 	pollfd fds[1];
diff --git a/tests/sys/fs/fusefs/mockfs.hh b/tests/sys/fs/fusefs/mockfs.hh
index f98a5337c9d1..3090701c815e 100644
--- a/tests/sys/fs/fusefs/mockfs.hh
+++ b/tests/sys/fs/fusefs/mockfs.hh
@@ -383,6 +383,9 @@ class MockFS {
 	/* Process FUSE requests endlessly */
 	void loop();
 
+	/* Begin processing requests from the kernel */
+	void start_service();
+
 	/*
 	 * Send an asynchronous notification to invalidate a directory entry.
 	 * Similar to libfuse's fuse_lowlevel_notify_inval_entry
diff --git a/tests/sys/fs/fusefs/pre-init.cc b/tests/sys/fs/fusefs/pre-init.cc
index 2d3257500304..70d7ddcdb0f4 100644
--- a/tests/sys/fs/fusefs/pre-init.cc
+++ b/tests/sys/fs/fusefs/pre-init.cc
@@ -102,6 +102,8 @@ TEST_F(PreInit, unmount_before_init)
 	})));
 	expect_destroy(0);
 
+	m_mock->start_service();
+
 	ASSERT_EQ(0, pthread_create(&th1, NULL, unmount1, NULL));
 	nap();	/* Wait for th1 to block in unmount() */
 	sem_post(&sem0);
@@ -147,6 +149,8 @@ TEST_F(PreInit, signal_during_unmount_before_init)
 		sem_wait(&sem0);
 	})));
 
+	m_mock->start_service();
+
 	if ((child = ::fork()) == 0) {
 		/*
 		 * In child.  This will block waiting for FUSE_INIT to complete
@@ -219,6 +223,8 @@ TEST_P(PreInitP, getattr_before_init)
 		out.body.attr.attr_valid = UINT64_MAX;
 	})));
 
+	m_mock->start_service();
+
 	EXPECT_EQ(0, stat("mountpoint", &sb));
 	EXPECT_EQ(nlink, sb.st_nlink);
 }


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a73525f.45e96.6db9f9f1>