static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
enum fio_ddir ddir, uint64_t *b)
{
- uint64_t r, lastb;
-
- lastb = last_block(td, f, ddir);
- if (!lastb)
- return 1;
+ uint64_t r;
if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE) {
+ uint64_t lastb;
+
+ lastb = last_block(td, f, ddir);
+ if (!lastb)
+ return 1;
+
r = __rand(&td->random_state);
dprint(FD_RANDOM, "off rand %llu\n", (unsigned long long) r);
} else {
uint64_t off = 0;
- if (lfsr_next(&f->lfsr, &off, lastb))
+ if (lfsr_next(&f->lfsr, &off))
return 1;
*b = off;
if (td_rw(td) && __should_check_rate(td, odir))
td->rate_pending_usleep[odir] -= usec;
- if (ddir_trim(ddir))
- return ddir;
+ if (ddir == DDIR_TRIM)
+ return DDIR_TRIM;
return ddir;
}
{
struct io_u *io_u = NULL;
+ if (td->stop_io)
+ return NULL;
+
td_io_u_lock(td);
again:
if (!(io_u->flags & IO_U_F_VER_LIST))
td->this_io_bytes[ddir] += bytes;
- if (ddir == DDIR_WRITE && f) {
- if (f->first_write == -1ULL ||
- io_u->offset < f->first_write)
- f->first_write = io_u->offset;
- if (f->last_write == -1ULL ||
- ((io_u->offset + bytes) > f->last_write))
- f->last_write = io_u->offset + bytes;
+ if (ddir == DDIR_WRITE) {
+ if (f) {
+ if (f->first_write == -1ULL ||
+ io_u->offset < f->first_write)
+ f->first_write = io_u->offset;
+ if (f->last_write == -1ULL ||
+ ((io_u->offset + bytes) > f->last_write))
+ f->last_write = io_u->offset + bytes;
+ }
+ if (td->last_write_comp) {
+ int idx = td->last_write_idx++;
+
+ td->last_write_comp[idx] = io_u->offset;
+ if (td->last_write_idx == td->o.iodepth)
+ td->last_write_idx = 0;
+ }
}
if (ramp_time_over(td) && (td->runstate == TD_RUNNING ||
void fill_io_buffer(struct thread_data *td, void *buf, unsigned int min_write,
unsigned int max_bs)
{
- if (td->o.buffer_pattern_bytes)
- fill_buffer_pattern(td, buf, max_bs);
- else if (!td->o.zero_buffers) {
+ struct thread_options *o = &td->o;
+
+ if (o->compress_percentage) {
unsigned int perc = td->o.compress_percentage;
struct frand_state *rs;
unsigned int left = max_bs;
seg = min_write;
fill_random_buf_percentage(rs, buf, perc, seg,
- min_write);
+ min_write, o->buffer_pattern,
+ o->buffer_pattern_bytes);
} else
fill_random_buf(rs, buf, min_write);
left -= min_write;
save_buf_state(td, rs);
} while (left);
- } else
+ } else if (o->buffer_pattern_bytes)
+ fill_buffer_pattern(td, buf, max_bs);
+ else
memset(buf, 0, max_bs);
}