From 704a8cfef1d0a61c8935a5c6047fba148a766dab Mon Sep 17 00:00:00 2001 From: Minwoo Im Date: Wed, 10 Jul 2024 07:50:14 +0900 Subject: [PATCH] io_u: Ensure fsync only after write(s) When using `--rw=write --fsync=N`, the FLUSH command is correctly issued after N WRITE commands. However, if READ commands are mixed in with --rw, fsync occurs after READ commands as well. This patch ensures that fsync is only triggered after the specified number of WRITE commands, regardless of READ commands. Signed-off-by: Minwoo Im --- io_u.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_u.c b/io_u.c index b5c03db74..f8ce8618c 100644 --- a/io_u.c +++ b/io_u.c @@ -755,7 +755,7 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td) * See if it's time to fsync/fdatasync/sync_file_range first, * and if not then move on to check regular I/Os. */ - if (should_fsync(td)) { + if (should_fsync(td) && td->last_ddir_issued == DDIR_WRITE) { if (td->o.fsync_blocks && td->io_issues[DDIR_WRITE] && !(td->io_issues[DDIR_WRITE] % td->o.fsync_blocks)) return DDIR_SYNC;