diff mbox series

[22/28] fsync-tester.c: use syncfs() rather than sync()

Message ID 20250417031208.1852171-23-david@fromorbit.com (mailing list archive)
State New
Headers show
Series check-parallel: Running tests without check | expand

Commit Message

Dave Chinner April 17, 2025, 3:01 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

generic/311 runs each fsync-tester unit test 4 times, and there are
20 separate tests. At least 9 of those unit tests run sync() to
flush dirty data periodically.

When running check-parallel, sync() can take a -long- time to
run as there can be dozens of filesystems that need to be synced,
not to mention sync getting hung up behind all the mount and
unmounts that are also being run. This results in:

Ten slowest tests - runtime in seconds:
generic/311 419

This test running for a really long time.

Convert the sync() calls to syncfs() so that they only try to sync
the filesystem under test and not the entire system. This avoids
interactions and delays with other tests and mount/unmount
operations, hence allowing both the test and the overall
check-parallel operation to run faster:

generic/311        166s

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 src/fsync-tester.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/fsync-tester.c b/src/fsync-tester.c
index 417187491..048cb4853 100644
--- a/src/fsync-tester.c
+++ b/src/fsync-tester.c
@@ -131,7 +131,7 @@  static int test_three(int *max_blocks, int prealloc, int rand_fsync,
 		/* Force a transaction commit in between just for fun */
 		if (blocks == sync_block && (do_sync || drop_caches)) {
 			if (do_sync)
-				sync();
+				syncfs(test_fd);
 			else
 				sync_file_range(test_fd, 0, 0,
 						SYNC_FILE_RANGE_WRITE|