parse: enable options to be marked dont-free
[fio.git] / profiles / tiobench.c
index bdb5985da006b11a4c611c48fc5e4e9e93f9b912..f19a08577bb2450f0597cc9202e8c00c9eb495a6 100644 (file)
@@ -1,6 +1,7 @@
 #include "../fio.h"
 #include "../profile.h"
 #include "../parse.h"
+#include "../optgroup.h"
 
 static unsigned long long size;
 static unsigned int loops = 1;
@@ -8,7 +9,7 @@ static unsigned int bs = 4096;
 static unsigned int nthreads = 1;
 static char *dir;
 
-char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];
+static char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];
 
 static const char *tb_opts[] = {
        "buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx,
@@ -21,13 +22,24 @@ static const char *tb_opts[] = {
        "name=randread", "stonewall", "rw=randread", NULL,
 };
 
+struct tiobench_options {
+       unsigned int pad;
+       unsigned long long size;
+       unsigned int loops;
+       unsigned int bs;
+       unsigned int nthreads;
+       char *dir;
+};
+
+static struct tiobench_options tiobench_options;
+
 static struct fio_option options[] = {
        {
                .name   = "size",
                .lname  = "Tiobench size",
                .type   = FIO_OPT_STR_VAL,
-               .roff1  = &size,
-               .help   = "Size in MB",
+               .off1   = offsetof(struct tiobench_options, size),
+               .help   = "Size in MiB",
                .category = FIO_OPT_C_PROFILE,
                .group  = FIO_OPT_G_TIOBENCH,
        },
@@ -35,9 +47,9 @@ static struct fio_option options[] = {
                .name   = "block",
                .lname  = "Tiobench block",
                .type   = FIO_OPT_INT,
-               .roff1  = &bs,
+               .off1   = offsetof(struct tiobench_options, bs),
                .help   = "Block size in bytes",
-               .def    = "4k",
+               .def    = "4096",
                .category = FIO_OPT_C_PROFILE,
                .group  = FIO_OPT_G_TIOBENCH,
        },
@@ -45,7 +57,7 @@ static struct fio_option options[] = {
                .name   = "numruns",
                .lname  = "Tiobench numruns",
                .type   = FIO_OPT_INT,
-               .roff1  = &loops,
+               .off1   = offsetof(struct tiobench_options, loops),
                .help   = "Number of runs",
                .category = FIO_OPT_C_PROFILE,
                .group  = FIO_OPT_G_TIOBENCH,
@@ -54,16 +66,17 @@ static struct fio_option options[] = {
                .name   = "dir",
                .lname  = "Tiobench directory",
                .type   = FIO_OPT_STR_STORE,
-               .roff1  = &dir,
+               .off1   = offsetof(struct tiobench_options, dir),
                .help   = "Test directory",
                .category = FIO_OPT_C_PROFILE,
                .group  = FIO_OPT_G_TIOBENCH,
+               .no_free = true,
        },
        {
                .name   = "threads",
                .lname  = "Tiobench threads",
                .type   = FIO_OPT_INT,
-               .roff1  = &nthreads,
+               .off1   = offsetof(struct tiobench_options, nthreads),
                .help   = "Number of Threads",
                .category = FIO_OPT_C_PROFILE,
                .group  = FIO_OPT_G_TIOBENCH,
@@ -79,7 +92,7 @@ static struct fio_option options[] = {
 static int tb_prep_cmdline(void)
 {
        /*
-        * tiobench uses size as MB, so multiply up
+        * tiobench uses size as MiB, so multiply up
         */
        size *= 1024 * 1024ULL;
        if (size)
@@ -102,9 +115,10 @@ static int tb_prep_cmdline(void)
 static struct profile_ops tiobench_profile = {
        .name           = "tiobench",
        .desc           = "tiotest/tiobench benchmark",
-       .options        = options,
        .prep_cmd       = tb_prep_cmdline,
        .cmdline        = tb_opts,
+       .options        = options,
+       .opt_data       = &tiobench_options,
 };
 
 static void fio_init tiobench_register(void)