Add parent link to options
authorJens Axboe <jens.axboe@oracle.com>
Tue, 31 Jul 2007 14:14:34 +0000 (16:14 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 31 Jul 2007 14:14:34 +0000 (16:14 +0200)
Then we can nest display for --cmdhelp=all, to tie options
together.

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

index 9ba9ca566802eea7743b1ec9d177024d2938d6fc..7f4ed2db994b9a6d1b2ccbf003b3ac81277e018e 100644 (file)
--- a/options.c
+++ b/options.c
@@ -390,12 +390,14 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(iodepth_batch),
                .help   = "Number of IO to submit in one go",
+               .parent = "iodepth",
        },
        {
                .name   = "iodepth_low",
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(iodepth_low),
                .help   = "Low water mark for queuing depth",
+               .parent = "iodepth",
        },
        {
                .name   = "size",
@@ -649,6 +651,7 @@ static struct fio_option options[] = {
                .off1   = td_var_offset(verify_interval),
                .minval = 2 * sizeof(struct verify_header),
                .help   = "Store verify buffer header every N bytes",
+               .parent = "verify",
        },
        {
                .name   = "verify_offset",
@@ -656,12 +659,14 @@ static struct fio_option options[] = {
                .help   = "Offset verify header location by N bytes",
                .def    = "0",
                .cb     = str_verify_offset_cb, 
+               .parent = "verify",
        },
        {
                .name   = "verify_pattern",
                .type   = FIO_OPT_INT,
                .cb     = str_verify_pattern_cb,
                .help   = "Fill pattern for IO buffers",
+               .parent = "verify",
        },
        {
                .name   = "write_iolog",
@@ -716,13 +721,6 @@ static struct fio_option options[] = {
                .help   = "Lock down this amount of memory",
                .def    = "0",
        },
-       {
-               .name   = "rwmixcycle",
-               .type   = FIO_OPT_INT,
-               .off1   = td_var_offset(rwmixcycle),
-               .help   = "Cycle period for mixed read/write workloads (msec)",
-               .def    = "500",
-       },
        {
                .name   = "rwmixread",
                .type   = FIO_OPT_INT,
@@ -739,6 +737,14 @@ static struct fio_option options[] = {
                .help   = "Percentage of mixed workload that is writes",
                .def    = "50",
        },
+       {
+               .name   = "rwmixcycle",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(rwmixcycle),
+               .help   = "Cycle period for mixed read/write workloads (msec)",
+               .def    = "500",
+               .parent = "rwmixread",
+       },
        {
                .name   = "nice",
                .type   = FIO_OPT_INT,
@@ -779,6 +785,7 @@ static struct fio_option options[] = {
                .off1   = td_var_offset(thinktime_spin),
                .help   = "Start think time by spinning this amount (usec)",
                .def    = "0",
+               .parent = "thinktime",
        },
        {
                .name   = "thinktime_blocks",
@@ -786,6 +793,7 @@ static struct fio_option options[] = {
                .off1   = td_var_offset(thinktime_blocks),
                .help   = "IO buffer period between 'thinktime'",
                .def    = "1",
+               .parent = "thinktime",
        },
        {
                .name   = "rate",
@@ -798,6 +806,7 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(ratemin),
                .help   = "Job must meet this rate or it will be shutdown",
+               .parent = "rate",
        },
        {
                .name   = "rate_iops",
@@ -810,6 +819,7 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(rate_iops_min),
                .help   = "Job must meet this rate or it will be shutdown",
+               .parent = "rate_iops",
        },
        {
                .name   = "ratecycle",
@@ -817,6 +827,7 @@ static struct fio_option options[] = {
                .off1   = td_var_offset(ratecycle),
                .help   = "Window average for rate limits (msec)",
                .def    = "1000",
+               .parent = "rate",
        },
        {
                .name   = "invalidate",
diff --git a/parse.c b/parse.c
index 6fd617ce57468883b777d8d2e346076383690f92..962538c066ecace330da6ebb1a946b4294a003e2 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -561,6 +561,37 @@ static void show_option_help(struct fio_option *o)
        show_option_values(o);
 }
 
+static struct fio_option *find_child(struct fio_option *options,
+                                    struct fio_option *o)
+{
+       struct fio_option *__o;
+
+       for (__o = &options[0]; __o->name; __o++)
+               if (__o->parent && !strcmp(__o->parent, o->name))
+                       return __o;
+
+       return NULL;
+}
+
+static void print_option(struct fio_option *options, struct fio_option *o,
+                        int level)
+{
+       char name[256], *p;
+       int i;
+
+       if (!o)
+               return;
+       
+       p = name;
+       for (i = 0; i < level; i++)
+               p += sprintf(p, "%s", "    ");
+
+       sprintf(p, "%s", o->name);
+
+       printf("%-24s: %s\n", name, o->help);
+       print_option(options, find_child(options, o), level + 1);
+}
+
 int show_cmd_help(struct fio_option *options, const char *name)
 {
        struct fio_option *o, *closest;
@@ -594,9 +625,10 @@ int show_cmd_help(struct fio_option *options, const char *name)
                if (show_all || match) {
                        found = 1;
                        if (match)
-                               printf("%20s: %s\n", o->name, o->help);
+                               printf("%24s: %s\n", o->name, o->help);
                        if (show_all) {
-                               printf("%-20s: %s\n", o->name, o->help);
+                               if (!o->parent)
+                                       print_option(options, o, 0);
                                continue;
                        }
                }
diff --git a/parse.h b/parse.h
index 752da346d2aabbfc3c57280211b5086f1480c79e..c3b66d75be34216ff1f3df33b85db9d7779ef6c6 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -45,6 +45,7 @@ struct fio_option {
        const char *help;               /* help text for option */
        const char *def;                /* default setting */
        const struct value_pair posval[PARSE_MAX_VP];/* possible values */
+       const char *parent;             /* parent option */
 };
 
 typedef int (str_cb_fn)(void *, char *);