[PATCH] Introduce bool option type
[fio.git] / init.c
diff --git a/init.c b/init.c
index 37b84e68bb1ded485f828e4843bfeacbd3863e0c..79b6e5cb0c0d4748a940d15b95d9d7d54402de5a 100644 (file)
--- a/init.c
+++ b/init.c
@@ -63,29 +63,35 @@ static struct fio_option options[] = {
                .name   = "rw",
                .type   = FIO_OPT_STR,
                .cb     = str_rw_cb,
-               .help   = "IO direction (read, write, rw, etc)",
+               .help   = "IO direction",
                .def    = "read",
+               .posval = { "read", "write", "randwrite", "randread", "rw",
+                               "randrw", },
        },
        {
                .name   = "ioengine",
                .type   = FIO_OPT_STR,
                .cb     = str_ioengine_cb,
-               .help   = "IO engine to use (sync, aio, etc)",
+               .help   = "IO engine to use",
                .def    = "sync",
+               .posval = { "sync", "libaio", "posixaio", "mmap", "splice",
+                               "sg", "null", },
        },
        {
                .name   = "mem",
                .type   = FIO_OPT_STR,
                .cb     = str_mem_cb,
-               .help   = "Backing type for IO buffers (malloc, shm, etc)",
+               .help   = "Backing type for IO buffers",
                .def    = "malloc",
+               .posval =  { "malloc", "shm", "shmhuge", "mmap", "mmaphuge", },
        },
        {
                .name   = "verify",
                .type   = FIO_OPT_STR,
                .cb     = str_verify_cb,
-               .help   = "Verify sum function (md5 or crc32)",
+               .help   = "Verify sum function",
                .def    = "0",
+               .posval = { "crc32", "md5", },
        },
        {
                .name   = "write_iolog",
@@ -172,7 +178,7 @@ static struct fio_option options[] = {
        },
        {
                .name   = "randrepeat",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(rand_repeatable),
                .help   = "Use repeatable random IO pattern",
                .def    = "1",
@@ -226,6 +232,7 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(nice),
                .help   = "Set job CPU nice value",
+               .minval = -19,
                .maxval = 20,
                .def    = "0",
        },
@@ -235,12 +242,16 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .cb     = str_prio_cb,
                .help   = "Set job IO priority value",
+               .minval = 0,
+               .maxval = 7,
        },
        {
                .name   = "prioclass",
                .type   = FIO_OPT_INT,
                .cb     = str_prioclass_cb,
                .help   = "Set job IO priority class",
+               .minval = 0,
+               .maxval = 3,
        },
 #endif
        {
@@ -292,14 +303,14 @@ static struct fio_option options[] = {
        },
        {
                .name   = "invalidate",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(invalidate_cache),
                .help   = "Invalidate buffer/page cache prior to running job",
                .def    = "1",
        },
        {
                .name   = "sync",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(sync_io),
                .help   = "Use O_SYNC for buffered writes",
                .def    = "0",
@@ -313,14 +324,14 @@ static struct fio_option options[] = {
        },
        {
                .name   = "create_serialize",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(create_serialize),
                .help   = "Serialize creating of job files",
                .def    = "1",
        },
        {
                .name   = "create_fsync",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(create_fsync),
                .help   = "Fsync file after creation",
                .def    = "1",
@@ -353,14 +364,14 @@ static struct fio_option options[] = {
        },
        {
                .name   = "direct",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(odirect),
                .help   = "Use O_DIRECT IO",
                .def    = "1",
        },
        {
                .name   = "overwrite",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(overwrite),
                .help   = "When writing, set whether to overwrite current data",
                .def    = "0",
@@ -375,14 +386,14 @@ static struct fio_option options[] = {
 #endif
        {
                .name   = "end_fsync",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(end_fsync),
                .help   = "Include fsync at the end of job",
                .def    = "0",
        },
        {
                .name   = "unlink",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(unlink),
                .help   = "Unlink created files after job has completed",
                .def    = "1",
@@ -1316,6 +1327,8 @@ int parse_options(int argc, char *argv[])
        f_out = stdout;
        f_err = stderr;
 
+       options_init(options);
+
        dupe_job_options();
 
        if (setup_thread_area())