X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=2adcbd7f498ee94ae793456f8d4131b04b0df30d;hp=0a3988699987c282f6004b832e4096bc2de49f88;hb=94a6e1bb4e7d8e7fee66374841634b0f871c6d6d;hpb=094e66cbf2bc85617b3705eadc81940b202e5014 diff --git a/io_u.c b/io_u.c index 0a398869..2adcbd7f 100644 --- a/io_u.c +++ b/io_u.c @@ -177,7 +177,7 @@ bail: /* * Generate a value, v, between 1 and 100, both inclusive */ - v = rand_between(&td->zone_state, 1, 100); + v = rand32_between(&td->zone_state, 1, 100); zsi = &td->zone_state_index[ddir][v - 1]; stotal = zsi->size_perc_prev; @@ -279,7 +279,7 @@ static bool should_do_random(struct thread_data *td, enum fio_ddir ddir) if (td->o.perc_rand[ddir] == 100) return true; - v = rand_between(&td->seq_rand_state[ddir], 1, 100); + v = rand32_between(&td->seq_rand_state[ddir], 1, 100); return v <= td->o.perc_rand[ddir]; } @@ -553,7 +553,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u, buflen = bsp->bs; perc += bsp->perc; - if ((r <= ((frand_max / 100L) * perc)) && + if ((r * 100UL <= frand_max * perc) && io_u_fits(td, io_u, buflen)) break; } @@ -601,7 +601,7 @@ static inline enum fio_ddir get_rand_ddir(struct thread_data *td) { unsigned int v; - v = rand_between(&td->rwmix_state, 1, 100); + v = rand32_between(&td->rwmix_state, 1, 100); if (v <= td->o.rwmix[DDIR_READ]) return DDIR_READ; @@ -1735,6 +1735,25 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u, } } +static void file_log_write_comp(const struct thread_data *td, struct fio_file *f, + uint64_t offset, unsigned int bytes) +{ + int idx; + + if (f->first_write == -1ULL || offset < f->first_write) + f->first_write = offset; + if (f->last_write == -1ULL || ((offset + bytes) > f->last_write)) + f->last_write = offset + bytes; + + if (!f->last_write_comp) + return; + + idx = f->last_write_idx++; + f->last_write_comp[idx] = offset; + if (f->last_write_idx == td->o.iodepth) + f->last_write_idx = 0; +} + static void io_completed(struct thread_data *td, struct io_u **io_u_ptr, struct io_completion_data *icd) { @@ -1785,23 +1804,8 @@ static void io_completed(struct thread_data *td, struct io_u **io_u_ptr, if (!(io_u->flags & IO_U_F_VER_LIST)) td->this_io_bytes[ddir] += 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 (ddir == DDIR_WRITE && f) + file_log_write_comp(td, f, io_u->offset, bytes); if (ramp_time_over(td) && (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING)) @@ -1964,7 +1968,7 @@ static struct frand_state *get_buf_state(struct thread_data *td) return &td->buf_state; } - v = rand_between(&td->dedupe_state, 1, 100); + v = rand32_between(&td->dedupe_state, 1, 100); if (v <= td->o.dedupe_percentage) return &td->buf_state_prev;