X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=b044e28903a24f16bb549f647fba4a2b144b0cd1;hp=b70ccaf8b7a68d13bffc0967490963ac775a7bf2;hb=127f686514ef8b1d9ab6ed702971b205454974e6;hpb=214e1ecae844a32bf8f66d19132f4948d922dcee diff --git a/init.c b/init.c index b70ccaf8..b044e289 100644 --- a/init.c +++ b/init.c @@ -131,11 +131,43 @@ static void put_job(struct thread_data *td) thread_number--; } +static int setup_rate(struct thread_data *td) +{ + unsigned long nr_reads_per_msec; + unsigned long long rate; + unsigned int bs; + + if (!td->rate && !td->rate_iops) + return 0; + + if (td_rw(td)) + bs = td->rw_min_bs; + else if (td_read(td)) + bs = td->min_bs[DDIR_READ]; + else + bs = td->min_bs[DDIR_WRITE]; + + if (td->rate) { + rate = td->rate; + nr_reads_per_msec = (rate * 1024 * 1000LL) / bs; + } else + nr_reads_per_msec = td->rate_iops * 1000UL; + + if (!nr_reads_per_msec) { + log_err("rate lower than supported\n"); + return -1; + } + + td->rate_usec_cycle = 1000000000ULL / nr_reads_per_msec; + td->rate_pending_usleep = 0; + return 0; +} + /* * Lazy way of fixing up options that depend on each other. We could also * define option callback handlers, but this is easier. */ -static void fixup_options(struct thread_data *td) +static int fixup_options(struct thread_data *td) { if (!td->rwmixread && td->rwmixwrite) td->rwmixread = 100 - td->rwmixwrite; @@ -221,6 +253,17 @@ static void fixup_options(struct thread_data *td) if (td->open_files > td->nr_files || !td->open_files) td->open_files = td->nr_files; + + if ((td->rate && td->rate_iops) || (td->ratemin && td->rate_iops_min)) { + log_err("fio: rate and rate_iops are mutually exclusive\n"); + return 1; + } + if ((td->rate < td->ratemin) || (td->rate_iops < td->rate_iops_min)) { + log_err("fio: minimum rate exceeds rate\n"); + return 1; + } + + return 0; } /* @@ -355,7 +398,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->io_ops = load_ioengine(td, engine); if (!td->io_ops) { log_err("fio: failed to load engine %s\n", engine); - return 1; + goto err; } if (td->use_thread) @@ -380,7 +423,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) } } - fixup_options(td); + if (fixup_options(td)) + goto err; for_each_file(td, f, i) { if (td->directory && f->filetype == FIO_TYPE_FILE) {