Move rw= write && read_only check to ->verify callback
authorJens Axboe <jens.axboe@oracle.com>
Wed, 1 Jul 2009 08:38:35 +0000 (10:38 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 1 Jul 2009 08:38:35 +0000 (10:38 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c
options.c

diff --git a/init.c b/init.c
index 84c312f9d2194cc878dff29137003bf0d0f05ee5..cd32725c4b9893ed2983419e44835f707b4a1935 100644 (file)
--- a/init.c
+++ b/init.c
@@ -241,11 +241,13 @@ static int fixup_options(struct thread_data *td)
        }
 #endif
 
        }
 #endif
 
+#if 0
        if (read_only && td_write(td)) {
                log_err("fio: job <%s> has write bit set, but fio is in"
                        " read-only mode\n", td->o.name);
                return 1;
        }
        if (read_only && td_write(td)) {
                log_err("fio: job <%s> has write bit set, but fio is in"
                        " read-only mode\n", td->o.name);
                return 1;
        }
+#endif
 
        if (o->write_iolog_file && o->read_iolog_file) {
                log_err("fio: read iolog overrides write_iolog\n");
 
        if (o->write_iolog_file && o->read_iolog_file) {
                log_err("fio: read iolog overrides write_iolog\n");
index 7135231eefeed59b73cf720c73aab14c5c66a3c8..354067d3deafba1fe8e0b946d0b72e7445f85ebc 100644 (file)
--- a/options.c
+++ b/options.c
@@ -575,6 +575,19 @@ static int str_gtod_cpu_cb(void *data, int *il)
        return 0;
 }
 
        return 0;
 }
 
+static int rw_verify(struct fio_option *o, void *data)
+{
+       struct thread_data *td = data;
+
+       if (read_only && td_write(td)) {
+               log_err("fio: job <%s> has write bit set, but fio is in"
+                       " read-only mode\n", td->o.name);
+               return 1;
+       }
+
+       return 0;
+}
+
 #define __stringify_1(x)       #x
 #define __stringify(x)         __stringify_1(x)
 
 #define __stringify_1(x)       #x
 #define __stringify(x)         __stringify_1(x)
 
@@ -648,6 +661,7 @@ static struct fio_option options[] = {
                .off1   = td_var_offset(td_ddir),
                .help   = "IO direction",
                .def    = "read",
                .off1   = td_var_offset(td_ddir),
                .help   = "IO direction",
                .def    = "read",
+               .verify = rw_verify,
                .posval = {
                          { .ival = "read",
                            .oval = TD_DDIR_READ,
                .posval = {
                          { .ival = "read",
                            .oval = TD_DDIR_READ,