td: Replace last_was_sync with last_ddir_issued
authorMinwoo Im <minwoo.im.dev@gmail.com>
Tue, 9 Jul 2024 22:48:56 +0000 (07:48 +0900)
committerMinwoo Im <minwoo.im@samsung.com>
Thu, 11 Jul 2024 07:58:36 +0000 (16:58 +0900)
`last_was_sync` has represented that the last command had DDIR_SYNC.
This can be replaced with `ddir_sync(last_ddir_issued)` and it's much
more flexible to represent the last issued command's data direction.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
fio.h
ioengines.c
libfio.c

diff --git a/fio.h b/fio.h
index c5b4df2106c2a43fe96eb2341af4116e44ae98ec..4bb6cfa7f39e0b1152cd62bbadd03d3e4744f62c 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -258,8 +258,9 @@ struct thread_data {
        size_t orig_buffer_size;
        volatile int runstate;
        volatile bool terminate;
-       bool last_was_sync;
+
        enum fio_ddir last_ddir_completed;
+       enum fio_ddir last_ddir_issued;
 
        int mmapfd;
 
@@ -629,7 +630,7 @@ static inline bool multi_range_trim(struct thread_data *td, struct io_u *io_u)
 
 static inline bool should_fsync(struct thread_data *td)
 {
-       if (td->last_was_sync)
+       if (ddir_sync(td->last_ddir_issued))
                return false;
        if (td_write(td) || td->o.override_sync)
                return true;
index 6b81dc772ad3284683eb1c668e24d899f758d0ec..dcd4164d4e8f00ec9b4de514cac9b8b6d844e1e7 100644 (file)
@@ -437,7 +437,7 @@ enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u)
                        td->ts.total_io_u[io_u->ddir]++;
                }
 
-               td->last_was_sync = ddir_sync(io_u->ddir);
+               td->last_ddir_issued = ddir;
        } else if (ret == FIO_Q_QUEUED) {
                td->io_u_queued++;
 
@@ -448,7 +448,7 @@ enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u)
                if (td->io_u_queued >= td->o.iodepth_batch)
                        td_io_commit(td);
 
-               td->last_was_sync = ddir_sync(io_u->ddir);
+               td->last_ddir_issued = ddir;
        }
 
        if (!td_ioengine_flagged(td, FIO_SYNCIO) &&
index d0c6bf8f5667ba69bb42f54a5e4ea4a0d5fe211a..2596ae5a98900d5a5b8e7507b9025cddb3cbdd16 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -101,7 +101,6 @@ static void reset_io_counters(struct thread_data *td, int all)
 
        td->zone_bytes = 0;
 
-       td->last_was_sync = false;
        td->rwmix_issues = 0;
 
        /*