Fixup rwmixread/write options
authorJens Axboe <jens.axboe@oracle.com>
Wed, 28 May 2008 08:33:32 +0000 (10:33 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 28 May 2008 08:33:32 +0000 (10:33 +0200)
They would always end up as 50/50.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c
options.c

diff --git a/init.c b/init.c
index ca4e2bf..1291361 100644 (file)
--- a/init.c
+++ b/init.c
@@ -220,9 +220,6 @@ static int fixup_options(struct thread_data *td)
                return 1;
        }
 
-       if (o->rwmix[DDIR_READ] + o->rwmix[DDIR_WRITE] > 100)
-               o->rwmix[DDIR_WRITE] = 100 - o->rwmix[DDIR_READ];
-
        if (o->write_iolog_file && o->read_iolog_file) {
                log_err("fio: read iolog overrides write_iolog\n");
                free(o->write_iolog_file);
index 51914af..b8df1da 100644 (file)
--- a/options.c
+++ b/options.c
@@ -178,6 +178,24 @@ static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
        return 0;
 }
 
+static int str_rwmix_read_cb(void *data, unsigned int *val)
+{
+       struct thread_data *td = data;
+
+       td->o.rwmix[DDIR_READ] = *val;
+       td->o.rwmix[DDIR_WRITE] = 100 - *val;
+       return 0;
+}
+
+static int str_rwmix_write_cb(void *data, unsigned int *val)
+{
+       struct thread_data *td = data;
+
+       td->o.rwmix[DDIR_WRITE] = *val;
+       td->o.rwmix[DDIR_READ] = 100 - *val;
+       return 0;
+}
+
 #ifdef FIO_HAVE_IOPRIO
 static int str_prioclass_cb(void *data, unsigned int *val)
 {
@@ -982,7 +1000,7 @@ static struct fio_option options[] = {
        {
                .name   = "rwmixread",
                .type   = FIO_OPT_INT,
-               .off1   = td_var_offset(rwmix[DDIR_READ]),
+               .cb     = str_rwmix_read_cb,
                .maxval = 100,
                .help   = "Percentage of mixed workload that is reads",
                .def    = "50",
@@ -990,7 +1008,7 @@ static struct fio_option options[] = {
        {
                .name   = "rwmixwrite",
                .type   = FIO_OPT_INT,
-               .off1   = td_var_offset(rwmix[DDIR_WRITE]),
+               .cb     = str_rwmix_write_cb,
                .maxval = 100,
                .help   = "Percentage of mixed workload that is writes",
                .def    = "50",