X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=23a9e4ada729efbc2a53bd9b3d4e12047be1d5c6;hp=c51982d88a2468254dda05796db69143c16f1142;hb=e51a662940b8a24d2c1430bfe003423297171680;hpb=ca09be4b1a8e97f0bca5cfbddb399899cf561eaa diff --git a/io_u.c b/io_u.c index c51982d8..23a9e4ad 100644 --- a/io_u.c +++ b/io_u.c @@ -83,13 +83,15 @@ struct rand_off { 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); @@ -98,7 +100,9 @@ static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f, } else { uint64_t off = 0; - if (lfsr_next(&f->lfsr, &off, lastb)) + assert(fio_file_lfsr(f)); + + if (lfsr_next(&f->lfsr, &off)) return 1; *b = off; @@ -247,7 +251,7 @@ static int get_next_rand_block(struct thread_data *td, struct fio_file *f, } dprint(FD_IO, "%s: rand offset failed, last=%llu, size=%llu\n", - f->file_name, (unsigned long long) f->last_pos, + f->file_name, (unsigned long long) f->last_pos[ddir], (unsigned long long) f->real_file_size); return 1; } @@ -259,17 +263,17 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f, assert(ddir_rw(ddir)); - if (f->last_pos >= f->io_size + get_start_offset(td, f) && + if (f->last_pos[ddir] >= f->io_size + get_start_offset(td, f) && o->time_based) - f->last_pos = f->last_pos - f->io_size; + f->last_pos[ddir] = f->last_pos[ddir] - f->io_size; - if (f->last_pos < f->real_file_size) { + if (f->last_pos[ddir] < f->real_file_size) { uint64_t pos; - if (f->last_pos == f->file_offset && o->ddir_seq_add < 0) - f->last_pos = f->real_file_size; + if (f->last_pos[ddir] == f->file_offset && o->ddir_seq_add < 0) + f->last_pos[ddir] = f->real_file_size; - pos = f->last_pos - f->file_offset; + pos = f->last_pos[ddir] - f->file_offset; if (pos && o->ddir_seq_add) { pos += o->ddir_seq_add; @@ -328,8 +332,8 @@ static int get_next_block(struct thread_data *td, struct io_u *io_u, *is_random = 0; } } else if (td->o.rw_seq == RW_SEQ_IDENT) { - if (f->last_start != -1ULL) - offset = f->last_start - f->file_offset; + if (f->last_start[ddir] != -1ULL) + offset = f->last_start[ddir] - f->file_offset; else offset = 0; ret = 0; @@ -741,7 +745,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) */ if (f->file_offset >= f->real_file_size) f->file_offset = f->real_file_size - f->file_offset; - f->last_pos = f->file_offset; + f->last_pos[io_u->ddir] = f->file_offset; td->io_skip_bytes += td->o.zone_skip; } @@ -1469,8 +1473,8 @@ struct io_u *get_io_u(struct thread_data *td) goto err_put; } - f->last_start = io_u->offset; - f->last_pos = io_u->offset + io_u->buflen; + f->last_start[io_u->ddir] = io_u->offset; + f->last_pos[io_u->ddir] = io_u->offset + io_u->buflen; if (io_u->ddir == DDIR_WRITE) { if (td->flags & TD_F_REFILL_BUFFERS) { @@ -1857,9 +1861,9 @@ static void save_buf_state(struct thread_data *td, struct frand_state *rs) 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; @@ -1877,7 +1881,8 @@ void fill_io_buffer(struct thread_data *td, void *buf, unsigned int min_write, 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); @@ -1885,7 +1890,9 @@ void fill_io_buffer(struct thread_data *td, void *buf, unsigned int 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); }