#include "fio.h"
#include "hash.h"
#include "verify.h"
+#include "lib/rand.h"
struct io_completion_data {
int nr; /* input */
* If we have a mixed random workload, we may
* encounter blocks we already did IO to.
*/
- if ((td->o.ddir_nr == 1) && !random_map_free(f, block)) {
- if (!blocks)
- blocks = 1;
+ if ((td->o.ddir_nr == 1) && !random_map_free(f, block))
break;
- }
idx = RAND_MAP_IDX(f, block);
bit = RAND_MAP_BIT(f, block);
if (this_blocks + bit > BLOCKS_PER_MAP)
this_blocks = BLOCKS_PER_MAP - bit;
- if (this_blocks == BLOCKS_PER_MAP)
- mask = -1U;
- else
- mask = ((1U << this_blocks) - 1) << bit;
+ do {
+ if (this_blocks == BLOCKS_PER_MAP)
+ mask = -1U;
+ else
+ mask = ((1U << this_blocks) - 1) << bit;
+
+ if (!(f->file_map[idx] & mask))
+ break;
+
+ this_blocks--;
+ } while (this_blocks);
+
+ if (!this_blocks)
+ break;
f->file_map[idx] |= mask;
nr_blocks -= this_blocks;
return NULL;
}
+ if (td->o.verify_backlog && td->io_hist_len) {
+ int get_verify = 0;
+
+ if (td->verify_batch) {
+ td->verify_batch--;
+ get_verify = 1;
+ } else if (!(td->io_hist_len % td->o.verify_backlog) &&
+ td->last_ddir != DDIR_READ) {
+ td->verify_batch = td->o.verify_batch;
+ if (!td->verify_batch)
+ td->verify_batch = td->o.verify_backlog;
+ get_verify = 1;
+ }
+
+ if (get_verify && !get_next_verify(td, io_u))
+ goto out;
+ }
+
/*
* from a requeue, io_u already setup
*/
}
td->last_was_sync = 0;
+ td->last_ddir = io_u->ddir;
if (!io_u->error) {
unsigned int bytes = io_u->buflen - io_u->resid;
long *ptr = io_u->buf;
if (!td->o.zero_buffers) {
+ unsigned long r = __rand(&__fio_rand_state);
+
+ if (sizeof(int) != sizeof(*ptr))
+ r *= (unsigned long) __rand(&__fio_rand_state);
+
while ((void *) ptr - io_u->buf < max_bs) {
- *ptr = rand() * GOLDEN_RATIO_PRIME;
+ *ptr = r;
ptr++;
+ r *= GOLDEN_RATIO_PRIME;
+ r >>= 3;
}
} else
memset(ptr, 0, max_bs);