Add randtrimwrite data direction
[fio.git] / ioengines.c
index 68f307e541a9f5b0cd469c5f7fc695506b8e5144..e2316ee4e391d0d5899c960552fec4d19aa33ca2 100644 (file)
 
 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,17 +357,17 @@ 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)) {
-               if (fio_fill_issue_time(td))
+               async_ioengine_sync_trim(td, io_u)) {
+               if (fio_fill_issue_time(td)) {
                        fio_gettime(&io_u->issue_time, NULL);
 
-               /*
-                * only used for iolog
-                */
-               if (td->o.read_iolog_file)
-                       memcpy(&td->last_issue, &io_u->issue_time,
-                                       sizeof(io_u->issue_time));
+                       /*
+                        * only used for iolog
+                        */
+                       if (td->o.read_iolog_file)
+                               memcpy(&td->last_issue, &io_u->issue_time,
+                                               sizeof(io_u->issue_time));
+               }
        }
 
 
@@ -435,17 +442,18 @@ 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)) {
-               if (fio_fill_issue_time(td))
+               !async_ioengine_sync_trim(td, io_u)) {
+               if (fio_fill_issue_time(td) &&
+                       !td_ioengine_flagged(td, FIO_ASYNCIO_SETS_ISSUE_TIME)) {
                        fio_gettime(&io_u->issue_time, NULL);
 
-               /*
-                * only used for iolog
-                */
-               if (td->o.read_iolog_file)
-                       memcpy(&td->last_issue, &io_u->issue_time,
-                                       sizeof(io_u->issue_time));
+                       /*
+                        * only used for iolog
+                        */
+                       if (td->o.read_iolog_file)
+                               memcpy(&td->last_issue, &io_u->issue_time,
+                                               sizeof(io_u->issue_time));
+               }
        }
 
        return ret;