Add options to have fio latency profile a device
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index e8b628cee7be114d2579aa5a1d2fe75515653127..6141c91e8d31c4e9d0822fb769f606e1bcd84b00 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -285,7 +285,7 @@ int check_str_bytes(const char *p, long long *val, void *data)
        return str_to_decimal(p, val, 1, data);
 }
 
-static int check_str_time(const char *p, long long *val)
+int check_str_time(const char *p, long long *val)
 {
        return str_to_decimal(p, val, 0, NULL);
 }
@@ -380,7 +380,7 @@ static int str_match_len(const struct value_pair *vp, const char *str)
 static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                           int first, int more, int curr)
 {
-       int il, *ilp;
+       int il=0, *ilp;
        fio_fp64_t *flp;
        long long ull, *ullp;
        long ul1, ul2;
@@ -451,6 +451,8 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                else
                        ret = check_str_bytes(tmp, &ull, data);
 
+               dprint(FD_PARSE, "  ret=%d, out=%llu\n", ret, ull);
+
                if (ret)
                        break;
 
@@ -545,9 +547,11 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                        ** Initialize precision to 0 and zero out list
                        ** in case specified list is shorter than default
                        */
-                       ul2 = 0;
-                       ilp = td_var(data, o->off2);
-                       *ilp = ul2;
+                       if (o->off2) {
+                               ul2 = 0;
+                               ilp = td_var(data, o->off2);
+                               *ilp = ul2;
+                       }
 
                        flp = td_var(data, o->off1);
                        for(i = 0; i < o->maxlen; i++)
@@ -576,6 +580,8 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                flp = td_var(data, o->off1);
                flp[curr].u.f = uf;
 
+               dprint(FD_PARSE, "  out=%f\n", uf);
+
                /*
                ** Calculate precision for output by counting
                ** number of digits after period. Find first
@@ -588,9 +594,11 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                        while (*++cp2 != '\0' && *cp2 >= '0' && *cp2 <= '9')
                                len++;
 
-                       ilp = td_var(data, o->off2);
-                       if (len > *ilp)
-                               *ilp = len;
+                       if (o->off2) {
+                               ilp = td_var(data, o->off2);
+                               if (len > *ilp)
+                                       *ilp = len;
+                       }
                }
 
                break;
@@ -745,6 +753,8 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                else
                        il = 1;
 
+               dprint(FD_PARSE, "  ret=%d, out=%d\n", ret, il);
+
                if (ret)
                        break;
 
@@ -782,6 +792,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
        }
        case FIO_OPT_DEPRECATED:
                log_info("Option %s is deprecated\n", o->name);
+               ret = 1;
                break;
        default:
                log_err("Bad option type %u\n", o->type);
@@ -937,7 +948,8 @@ int parse_cmd_option(const char *opt, const char *val,
 }
 
 int parse_option(char *opt, const char *input,
-                struct fio_option *options, struct fio_option **o, void *data)
+                struct fio_option *options, struct fio_option **o, void *data,
+                int dump_cmdline)
 {
        char *post;
 
@@ -958,11 +970,25 @@ int parse_option(char *opt, const char *input,
                return 1;
        }
 
-       if (!handle_option(*o, post, data))
-               return 0;
+       if (handle_option(*o, post, data)) {
+               log_err("fio: failed parsing %s\n", input);
+               return 1;
+       }
 
-       log_err("fio: failed parsing %s\n", input);
-       return 1;
+       if (dump_cmdline) {
+               const char *delim;
+
+               if (!strcmp("description", (*o)->name))
+                       delim = "\"";
+               else
+                       delim = "";
+
+               log_info("--%s%s", (*o)->name, post ? "" : " ");
+               if (post)
+                       log_info("=%s%s%s ", delim, post, delim);
+       }
+
+       return 0;
 }
 
 /*
@@ -1080,6 +1106,8 @@ int show_cmd_help(struct fio_option *options, const char *name)
                        continue;
                if (!exec_profile && o->prof_name)
                        continue;
+               if (exec_profile && !(o->prof_name && !strcmp(exec_profile, o->prof_name)))
+                       continue;
 
                if (name) {
                        if (!strcmp(name, o->name) ||