X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=backend.c;h=4c2607477c5404fbfc588b0e07d79b367017f997;hb=c9af088bc9f52b58c8ee68d96403b48c8da9964b;hp=6290e0d652a838c510634e62cc123eea8da3e277;hpb=b54e0d80c52e626021aacd0ae4d9875940cff9aa;p=fio.git diff --git a/backend.c b/backend.c index 6290e0d6..4c260747 100644 --- a/backend.c +++ b/backend.c @@ -858,15 +858,47 @@ static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir) return 0; } +static void init_thinktime(struct thread_data *td) +{ + if (td->o.thinktime_blocks_type == THINKTIME_BLOCKS_TYPE_COMPLETE) + td->thinktime_blocks_counter = td->io_blocks; + else + td->thinktime_blocks_counter = td->io_issues; + td->last_thinktime = td->epoch; + td->last_thinktime_blocks = 0; +} + static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir, struct timespec *time) { unsigned long long b; uint64_t total; int left; + struct timespec now; + bool stall = false; + + if (td->o.thinktime_iotime) { + fio_gettime(&now, NULL); + if (utime_since(&td->last_thinktime, &now) + >= td->o.thinktime_iotime + td->o.thinktime) { + stall = true; + } else if (!fio_option_is_set(&td->o, thinktime_blocks)) { + /* + * When thinktime_iotime is set and thinktime_blocks is + * not set, skip the thinktime_blocks check, since + * thinktime_blocks default value 1 does not work + * together with thinktime_iotime. + */ + return; + } + + } b = ddir_rw_sum(td->thinktime_blocks_counter); - if (b % td->o.thinktime_blocks || !b) + if (b >= td->last_thinktime_blocks + td->o.thinktime_blocks) + stall = true; + + if (!stall) return; io_u_quiesce(td); @@ -902,6 +934,10 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir, if (time && should_check_rate(td)) fio_gettime(time, NULL); + + td->last_thinktime_blocks = b; + if (td->o.thinktime_iotime) + td->last_thinktime = now; } /* @@ -1407,7 +1443,7 @@ static int set_ioscheduler(struct thread_data *td, struct fio_file *file) sprintf(tmp2, "[%s]", td->o.ioscheduler); if (!strstr(tmp, tmp2)) { - log_err("fio: io scheduler %s not found\n", td->o.ioscheduler); + log_err("fio: unable to set io scheduler to %s\n", td->o.ioscheduler); td_verror(td, EINVAL, "iosched_switch"); fclose(f); return 1; @@ -1760,6 +1796,7 @@ static void *thread_main(void *data) td_verror(td, errno, "ioprio_set"); goto err; } + td->ioprio = ioprio_value(o->ioprio_class, o->ioprio); } if (o->cgroup && cgroup_setup(td, cgroup_list, &cgroup_mnt)) @@ -1791,17 +1828,14 @@ static void *thread_main(void *data) if (rate_submit_init(td, sk_out)) goto err; - if (td->o.thinktime_blocks_type == THINKTIME_BLOCKS_TYPE_COMPLETE) - td->thinktime_blocks_counter = td->io_blocks; - else - td->thinktime_blocks_counter = td->io_issues; - set_epoch_time(td, o->log_unix_epoch); fio_getrusage(&td->ru_start); memcpy(&td->bw_sample_time, &td->epoch, sizeof(td->epoch)); memcpy(&td->iops_sample_time, &td->epoch, sizeof(td->epoch)); memcpy(&td->ss.prev_time, &td->epoch, sizeof(td->epoch)); + init_thinktime(td); + if (o->ratemin[DDIR_READ] || o->ratemin[DDIR_WRITE] || o->ratemin[DDIR_TRIM]) { memcpy(&td->lastrate[DDIR_READ], &td->bw_sample_time, @@ -1886,13 +1920,13 @@ static void *thread_main(void *data) if (td->error || td->terminate) break; + clear_io_state(td, 0); + if (!o->do_verify || o->verify == VERIFY_NONE || td_ioengine_flagged(td, FIO_UNIDIR)) continue; - clear_io_state(td, 0); - fio_gettime(&td->start, NULL); do_verify(td, verify_bytes);