return 1;
}
-static int should_do_random(struct thread_data *td)
+static int should_do_random(struct thread_data *td, enum fio_ddir ddir)
{
unsigned int v;
unsigned long r;
- if (td->o.perc_rand == 100)
+ if (td->o.perc_rand[ddir] == 100)
return 1;
if (td->o.use_os_rand) {
- r = os_random_long(&td->seq_rand_state);
+ r = os_random_long(&td->seq_rand_state[ddir]);
v = 1 + (int) (100.0 * (r / (OS_RAND_MAX + 1.0)));
} else {
- r = __rand(&td->__seq_rand_state);
+ r = __rand(&td->__seq_rand_state[ddir]);
v = 1 + (int) (100.0 * (r / (FRAND_MAX + 1.0)));
}
- return v <= td->o.perc_rand;
+ return v <= td->o.perc_rand[ddir];
}
static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
if (rw_seq) {
if (td_random(td)) {
- if (should_do_random(td))
+ if (should_do_random(td, ddir))
ret = get_next_rand_block(td, f, ddir, &b);
else {
io_u->flags |= IO_U_F_BUSY_OK;
}
}
+ 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);
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);
}
__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;
}
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;
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) {
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);