genfio: Splitting gen_template in 2 parts
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index f0b6170535d2a77a07861a4a0760d72a4130412e..865c58260d976b916cc2d526a84609c968ca5132 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -459,6 +459,10 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u)
                        }
                }
 
+               if (td->o.do_verify && td->o.verify != VERIFY_NONE)
+                       buflen = (buflen + td->o.verify_interval - 1) &
+                               ~(td->o.verify_interval - 1);
+
                if (!td->o.bs_unaligned && is_power_of_2(minbs))
                        buflen = (buflen + minbs - 1) & ~(minbs - 1);
 
@@ -676,8 +680,7 @@ void put_io_u(struct thread_data *td, struct io_u *io_u)
 
        if (io_u->flags & IO_U_F_IN_CUR_DEPTH)
                td->cur_depth--;
-       flist_del_init(&io_u->list);
-       flist_add(&io_u->list, &td->io_u_freelist);
+       io_u_qpush(&td->io_u_freelist, io_u);
        td_io_u_unlock(td);
        td_io_u_free_notify(td);
 }
@@ -704,8 +707,8 @@ void requeue_io_u(struct thread_data *td, struct io_u **io_u)
        __io_u->flags &= ~IO_U_F_FLIGHT;
        if (__io_u->flags & IO_U_F_IN_CUR_DEPTH)
                td->cur_depth--;
-       flist_del(&__io_u->list);
-       flist_add_tail(&__io_u->list, &td->io_u_requeues);
+
+       io_u_rpush(&td->io_u_requeues, __io_u);
        td_io_u_unlock(td);
        *io_u = NULL;
 }
@@ -1107,16 +1110,17 @@ static int set_io_u_file(struct thread_data *td, struct io_u *io_u)
 
 struct io_u *__get_io_u(struct thread_data *td)
 {
-       struct io_u *io_u = NULL;
+       struct io_u *io_u;
 
        td_io_u_lock(td);
 
 again:
-       if (!flist_empty(&td->io_u_requeues))
-               io_u = flist_entry(td->io_u_requeues.next, struct io_u, list);
-       else if (!queue_full(td)) {
-               io_u = flist_entry(td->io_u_freelist.next, struct io_u, list);
+       if (!io_u_rempty(&td->io_u_requeues))
+               io_u = io_u_rpop(&td->io_u_requeues);
+       else if (!io_u_qempty(&td->io_u_freelist))
+               io_u = io_u_qpop(&td->io_u_freelist);
 
+       if (io_u) {
                io_u->buflen = 0;
                io_u->resid = 0;
                io_u->file = NULL;
@@ -1131,8 +1135,6 @@ again:
 
                io_u->error = 0;
                io_u->acct_ddir = -1;
-               flist_del(&io_u->list);
-               flist_add_tail(&io_u->list, &td->io_u_busylist);
                td->cur_depth++;
                io_u->flags |= IO_U_F_IN_CUR_DEPTH;
        } else if (td->o.verify_async) {
@@ -1368,6 +1370,13 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u,
                tusec = utime_since(&io_u->start_time, &icd->time);
                add_lat_sample(td, idx, tusec, bytes);
 
+               if (td->flags & TD_F_PROFILE_OPS) {
+                       struct prof_io_ops *ops = &td->prof_io_ops;
+
+                       if (ops->io_u_lat)
+                               icd->error = ops->io_u_lat(td, tusec);
+               }
+
                if (td->o.max_latency && tusec > td->o.max_latency) {
                        if (!td->error)
                                log_err("fio: latency of %lu usec exceeds specified max (%u usec)\n", tusec, td->o.max_latency);