enum fio_ddir ddir, uint64_t *b)
{
struct zone_split_index *zsi;
- uint64_t offset, lastb;
- uint64_t send, stotal;
+ uint64_t lastb, send, stotal;
static int warned;
unsigned int v;
*/
v = rand32_between(&td->zone_state, 1, 100);
+ /*
+ * Find our generated table. 'send' is the end block of this zone,
+ * 'stotal' is our start offset.
+ */
zsi = &td->zone_state_index[ddir][v - 1];
stotal = zsi->size_prev / td->o.ba[ddir];
send = zsi->size / td->o.ba[ddir];
}
/*
- * 'send' is some percentage below or equal to 100 that
- * marks the end of the current IO range. 'stotal' marks
- * the start, in percent.
+ * Generate index from 0..send-stotal
*/
- if (stotal)
- offset = stotal;
- else
- offset = 0;
-
- lastb = send - stotal;
-
- /*
- * Generate index from 0..send-of-lastb
- */
- if (__get_next_rand_offset(td, f, ddir, b, lastb) == 1)
+ if (__get_next_rand_offset(td, f, ddir, b, send - stotal) == 1)
return 1;
- /*
- * Add our start offset, if any
- */
- if (offset)
- *b += offset;
-
+ *b += stotal;
return 0;
}
}
static void lat_fatal(struct thread_data *td, struct io_completion_data *icd,
- unsigned long tusec, unsigned long max_usec)
+ unsigned long long tnsec, unsigned long long max_nsec)
{
if (!td->error)
- log_err("fio: latency of %lu usec exceeds specified max (%lu usec)\n", tusec, max_usec);
+ log_err("fio: latency of %llu nsec exceeds specified max (%llu nsec)\n", tnsec, max_nsec);
td_verror(td, ETIMEDOUT, "max latency exceeded");
icd->error = ETIMEDOUT;
}
static void small_content_scramble(struct io_u *io_u)
{
unsigned int i, nr_blocks = io_u->buflen / 512;
- uint64_t boffset;
unsigned int offset;
+ uint64_t boffset;
char *p, *end;
if (!nr_blocks)
for (i = 0; i < nr_blocks; i++) {
/*
* Fill the byte offset into a "random" start offset of
- * the buffer, given by the product of the usec time
- * and the actual offset.
+ * the first half of the buffer.
*/
- offset = ((io_u->start_time.tv_nsec/1000) ^ boffset) & 511;
- offset &= ~(sizeof(uint64_t) - 1);
- if (offset >= 512 - sizeof(uint64_t))
- offset -= sizeof(uint64_t);
+ offset = (io_u->start_time.tv_nsec ^ boffset) & 255;
+ offset &= ~(sizeof(boffset) - 1);
memcpy(p + offset, &boffset, sizeof(boffset));
+ /*
+ * Fill the start time into the end of the buffer
+ */
end = p + 512 - sizeof(io_u->start_time);
memcpy(end, &io_u->start_time, sizeof(io_u->start_time));
p += 512;
struct prof_io_ops *ops = &td->prof_io_ops;
if (ops->io_u_lat)
- icd->error = ops->io_u_lat(td, tnsec/1000);
+ icd->error = ops->io_u_lat(td, tnsec);
}
- if (td->o.max_latency && tnsec/1000 > td->o.max_latency)
- lat_fatal(td, icd, tnsec/1000, td->o.max_latency);
- if (td->o.latency_target && tnsec/1000 > td->o.latency_target) {
+ if (td->o.max_latency && tnsec > td->o.max_latency)
+ lat_fatal(td, icd, tnsec, td->o.max_latency);
+ if (td->o.latency_target && tnsec > td->o.latency_target) {
if (lat_target_failed(td))
- lat_fatal(td, icd, tnsec/1000, td->o.latency_target);
+ lat_fatal(td, icd, tnsec, td->o.latency_target);
}
}