X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=dc4473beab1737660f2ebeb2f1c91418b1a14da6;hp=bffacb404e860864b51e7c89b443eb0a54cb15b6;hb=cbe8d7561cf6d81d741d87eb7940db2a111d2144;hpb=f8a75c992b8f7166c423f9282b660640c1d6c397 diff --git a/io_u.c b/io_u.c index bffacb40..dc4473be 100644 --- a/io_u.c +++ b/io_u.c @@ -54,11 +54,8 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u) * 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); @@ -69,10 +66,20 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u) 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; @@ -976,6 +983,14 @@ struct io_u *get_io_u(struct thread_data *td) populate_verify_io_u(td, io_u); else if (td->o.refill_buffers && io_u->ddir == DDIR_WRITE) io_u_fill_buffer(td, io_u, io_u->xfer_buflen); + else if (io_u->ddir == DDIR_READ) { + /* + * Reset the buf_filled parameters so next time if the + * buffer is used for writes it is refilled. + */ + io_u->buf_filled = 0; + io_u->buf_filled_len = 0; + } } /* @@ -1072,7 +1087,13 @@ static void io_completed(struct thread_data *td, struct io_u *io_u, if (!td->o.disable_clat || !td->o.disable_bw) lusec = utime_since(&io_u->issue_time, &icd->time); + if (!td->o.disable_lat) { + unsigned long tusec; + tusec = utime_since(&io_u->start_time, + &icd->time); + add_lat_sample(td, idx, tusec, bytes); + } if (!td->o.disable_clat) { add_clat_sample(td, idx, lusec, bytes); io_u_mark_latency(td, lusec); @@ -1233,20 +1254,8 @@ void io_u_queued(struct thread_data *td, struct io_u *io_u) void io_u_fill_buffer(struct thread_data *td, struct io_u *io_u, unsigned int max_bs) { - 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 = r; - ptr++; - r *= GOLDEN_RATIO_PRIME; - r >>= 3; - } - } else - memset(ptr, 0, max_bs); + if (!td->o.zero_buffers) + fill_random_buf(io_u->buf, max_bs); + else + memset(io_u->buf, 0, max_bs); }