Fix segfault with verify_async
[fio.git] / options.c
index f07cc7c42aedcee338fb5e9a7b7a7bbf773f4998..bb46dc9df8cbf707a87671c4b1f0b1867dd79f4b 100644 (file)
--- a/options.c
+++ b/options.c
@@ -595,6 +595,14 @@ static char *get_next_file_name(char **ptr)
        return start;
 }
 
+static int str_hostname_cb(void *data, const char *input)
+{
+       struct thread_data *td = data;
+
+       td->o.filename = strdup(input);
+       return 0;
+}
+
 static int str_filename_cb(void *data, const char *input)
 {
        struct thread_data *td = data;
@@ -769,6 +777,7 @@ static int str_gtod_reduce_cb(void *data, int *il)
        td->o.disable_clat = !!val;
        td->o.disable_slat = !!val;
        td->o.disable_bw = !!val;
+       td->o.clat_percentiles = !val;
        if (val)
                td->tv_cache_mask = 63;
 
@@ -871,6 +880,12 @@ static struct fio_option options[FIO_MAX_OPTS] = {
                .prio   = -1, /* must come after "directory" */
                .help   = "File(s) to use for the workload",
        },
+       {
+               .name   = "hostname",
+               .type   = FIO_OPT_STR_STORE,
+               .cb     = str_hostname_cb,
+               .help   = "Hostname for net IO engine",
+       },
        {
                .name   = "kb_base",
                .type   = FIO_OPT_INT,
@@ -1566,7 +1581,7 @@ static struct fio_option options[FIO_MAX_OPTS] = {
                .name   = "verify_dump",
                .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(verify_dump),
-               .def    = "1",
+               .def    = "0",
                .help   = "Dump contents of good and bad blocks on failure",
                .parent = "verify",
        },
@@ -2002,7 +2017,7 @@ static struct fio_option options[FIO_MAX_OPTS] = {
                .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(clat_percentiles),
                .help   = "Enable the reporting of completion latency percentiles",
-               .def    = "0",
+               .def    = "1",
        },
        {
                .name   = "percentile_list",
@@ -2332,7 +2347,10 @@ int fio_show_option_help(const char *opt)
        return show_cmd_help(options, opt);
 }
 
-static void __options_mem(struct thread_data *td, int alloc)
+/*
+ * dupe FIO_OPT_STR_STORE options
+ */
+void options_mem_dupe(struct thread_data *td)
 {
        struct thread_options *o = &td->o;
        struct fio_option *opt;
@@ -2344,32 +2362,13 @@ static void __options_mem(struct thread_data *td, int alloc)
                        continue;
 
                ptr = (void *) o + opt->off1;
-               if (*ptr) {
-                       if (alloc)
-                               *ptr = strdup(*ptr);
-                       else {
-                               free(*ptr);
-                               *ptr = NULL;
-                       }
-               }
+               if (!*ptr)
+                       ptr = td_var(o, opt->off1);
+               if (*ptr)
+                       *ptr = strdup(*ptr);
        }
 }
 
-/*
- * dupe FIO_OPT_STR_STORE options
- */
-void options_mem_dupe(struct thread_data *td)
-{
-       __options_mem(td, 1);
-}
-
-void options_mem_free(struct thread_data fio_unused *td)
-{
-#if 0
-       __options_mem(td, 0);
-#endif
-}
-
 unsigned int fio_get_kb_base(void *data)
 {
        struct thread_data *td = data;
@@ -2450,3 +2449,8 @@ void del_opt_posval(const char *optname, const char *ival)
                o->posval[i].help = NULL;
        }
 }
+
+void fio_options_free(struct thread_data *td)
+{
+       options_free(options, td);
+}