X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=e12382b83f3c959d03cc7c8babea40b8947d02c7;hp=22701274cf3cc5aa2fe78d70a0d25171432281df;hb=8f7630813305a4f4f04a5f9ba20b2a7d486c0cfb;hpb=78475ac3b9453eff01c34778d70a2aed4aecffe8 diff --git a/io_u.c b/io_u.c index 22701274..e12382b8 100644 --- a/io_u.c +++ b/io_u.c @@ -62,6 +62,7 @@ static uint64_t last_block(struct thread_data *td, struct fio_file *f, /* * Hmm, should we make sure that ->io_size <= ->real_file_size? + * -> not for now since there is code assuming it could go either. */ max_size = f->io_size; if (max_size > f->real_file_size) @@ -362,8 +363,12 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f, if (f->last_pos[ddir] < f->real_file_size) { uint64_t pos; - if (f->last_pos[ddir] == f->file_offset && o->ddir_seq_add < 0) - f->last_pos[ddir] = f->real_file_size; + if (f->last_pos[ddir] == f->file_offset && o->ddir_seq_add < 0) { + if (f->real_file_size > f->io_size) + f->last_pos[ddir] = f->io_size; + else + f->last_pos[ddir] = f->real_file_size; + } pos = f->last_pos[ddir] - f->file_offset; if (pos && o->ddir_seq_add) { @@ -378,8 +383,14 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f, if (pos >= f->real_file_size) { if (o->ddir_seq_add > 0) pos = f->file_offset; - else - pos = f->real_file_size + o->ddir_seq_add; + else { + if (f->real_file_size > f->io_size) + pos = f->io_size; + else + pos = f->real_file_size; + + pos += o->ddir_seq_add; + } } } @@ -521,8 +532,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u, int ddir = io_u->ddir; unsigned int buflen = 0; unsigned int minbs, maxbs; - uint64_t frand_max; - unsigned long r; + uint64_t frand_max, r; assert(ddir_rw(ddir)); @@ -551,7 +561,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u, if (buflen < minbs) buflen = minbs; } else { - long perc = 0; + long long perc = 0; unsigned int i; for (i = 0; i < td->o.bssplit_nr[ddir]; i++) { @@ -559,16 +569,14 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u, buflen = bsp->bs; perc += bsp->perc; - if ((r * 100UL <= frand_max * perc) && + if (!perc) + break; + if ((r / perc <= frand_max / 100ULL) && io_u_fits(td, io_u, buflen)) break; } } - if (td->o.verify != VERIFY_NONE) - buflen = (buflen + td->o.verify_interval - 1) & - ~(td->o.verify_interval - 1); - if (!td->o.bs_unaligned && is_power_of_2(minbs)) buflen &= ~(minbs - 1); @@ -642,13 +650,17 @@ int io_u_quiesce(struct thread_data *td) completed += ret; } + if (td->flags & TD_F_REGROW_LOGS) + regrow_logs(td); + return completed; } static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir) { enum fio_ddir odir = ddir ^ 1; - long usec, now; + long usec; + uint64_t now; assert(ddir_rw(ddir)); now = utime_since_now(&td->start); @@ -747,8 +759,10 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td) ddir = DDIR_READ; else if (td_write(td)) ddir = DDIR_WRITE; - else + else if (td_trim(td)) ddir = DDIR_TRIM; + else + ddir = DDIR_INVAL; td->rwmix_ddir = rate_ddir(td, ddir); return td->rwmix_ddir; @@ -1500,7 +1514,7 @@ static bool check_get_trim(struct thread_data *td, struct io_u *io_u) get_trim = 1; } - if (get_trim && !get_next_trim(td, io_u)) + if (get_trim && get_next_trim(td, io_u)) return true; } @@ -1891,7 +1905,7 @@ static void init_icd(struct thread_data *td, struct io_completion_data *icd, icd->nr = nr; icd->error = 0; - for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) + for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) icd->bytes_done[ddir] = 0; } @@ -1930,7 +1944,7 @@ int io_u_sync_complete(struct thread_data *td, struct io_u *io_u) return -1; } - for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) + for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) td->bytes_done[ddir] += icd.bytes_done[ddir]; return 0; @@ -1969,7 +1983,7 @@ int io_u_queued_complete(struct thread_data *td, int min_evts) return -1; } - for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) + for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) td->bytes_done[ddir] += icd.bytes_done[ddir]; return ret; @@ -1980,7 +1994,7 @@ int io_u_queued_complete(struct thread_data *td, int min_evts) */ void io_u_queued(struct thread_data *td, struct io_u *io_u) { - if (!td->o.disable_slat) { + if (!td->o.disable_slat && ramp_time_over(td)) { unsigned long slat_time; slat_time = utime_since(&io_u->start_time, &io_u->issue_time);