Async ioengines support trim commands but trims are synchronous operations. We need to provide special handling when measuring latency for these commands. Create a helper function to help us identify when an async ioengine is issuing a sync trim command. This makes the code more readable. Signed-off-by: Vincent Fu <vincent.fu@xxxxxxxxxxx> --- ioengines.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ioengines.c b/ioengines.c index 68f307e5..280da3c8 100644 --- a/ioengines.c +++ b/ioengines.c @@ -24,6 +24,13 @@ static FLIST_HEAD(engine_list); +static inline bool async_ioengine_sync_trim(struct thread_data *td, + struct io_u *io_u) +{ + return td_ioengine_flagged(td, FIO_ASYNCIO_SYNC_TRIM) && + io_u->ddir == DDIR_TRIM; +} + static bool check_engine_ops(struct thread_data *td, struct ioengine_ops *ops) { if (ops->version != FIO_IOOPS_VERSION) { @@ -350,8 +357,7 @@ enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u) io_u->resid = 0; if (td_ioengine_flagged(td, FIO_SYNCIO) || - (td_ioengine_flagged(td, FIO_ASYNCIO_SYNC_TRIM) && - io_u->ddir == DDIR_TRIM)) { + async_ioengine_sync_trim(td, io_u)) { if (fio_fill_issue_time(td)) fio_gettime(&io_u->issue_time, NULL); @@ -435,8 +441,7 @@ enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u) } if (!td_ioengine_flagged(td, FIO_SYNCIO) && - (!td_ioengine_flagged(td, FIO_ASYNCIO_SYNC_TRIM) || - io_u->ddir != DDIR_TRIM)) { + !async_ioengine_sync_trim(td, io_u)) { if (fio_fill_issue_time(td)) fio_gettime(&io_u->issue_time, NULL); -- 2.25.1