Support for setting rated based on IOPS
[fio.git] / init.c
diff --git a/init.c b/init.c
index b70ccaf8b7a68d13bffc0967490963ac775a7bf2..15e96aacbebdea4e21ab874a6df0511aed1c7b19 100644 (file)
--- a/init.c
+++ b/init.c
@@ -135,7 +135,7 @@ static void put_job(struct thread_data *td)
  * 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 +221,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 +366,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 +391,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) {