stat: work around 'numjobs' oddity in dumping job output
authorJens Axboe <axboe@fb.com>
Tue, 15 Dec 2015 17:38:05 +0000 (10:38 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 15 Dec 2015 17:38:05 +0000 (10:38 -0700)
Inherit options between duped jobs, and don't include 'numjobs' in the
global option output.

Signed-off-by: Jens Axboe <axboe@fb.com>
init.c
stat.c

diff --git a/init.c b/init.c
index e314fa1d9d8586b486555d37e0673c83b4a375ce..8773138c766af52f8a77397d9bacf53378d14172 100644 (file)
--- a/init.c
+++ b/init.c
@@ -426,6 +426,27 @@ static void fio_dump_options_free(struct thread_data *td)
        }
 }
 
+static void copy_opt_list(struct thread_data *dst, struct thread_data *src)
+{
+       struct flist_head *entry;
+
+       if (flist_empty(&src->opt_list))
+               return;
+
+       flist_for_each(entry, &src->opt_list) {
+               struct print_option *srcp, *dstp;
+
+               srcp = flist_entry(entry, struct print_option, list);
+               dstp = malloc(sizeof(*dstp));
+               dstp->name = strdup(srcp->name);
+               if (srcp->value)
+                       dstp->value = strdup(srcp->value);
+               else
+                       dstp->value = NULL;
+               flist_add_tail(&dstp->list, &dst->opt_list);
+       }
+}
+
 /*
  * Return a free job structure.
  */
@@ -452,6 +473,8 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent,
        *td = *parent;
 
        INIT_FLIST_HEAD(&td->opt_list);
+       if (parent != &def_thread)
+               copy_opt_list(td, parent);
 
        td->io_ops = NULL;
        if (!preserve_eo)
diff --git a/stat.c b/stat.c
index e47b510f55d20f65e065d0807a20f81dd3402182..1c1dceb5beccbe3cd6e1950addf1ab93d5b22937 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1087,7 +1087,7 @@ static void show_thread_status_terse_v3_v4(struct thread_stat *ts,
 }
 
 static void json_add_job_opts(struct json_object *root, const char *name,
-                             struct flist_head *opt_list)
+                             struct flist_head *opt_list, bool num_jobs)
 {
        struct json_object *dir_object;
        struct flist_head *entry;
@@ -1103,6 +1103,8 @@ static void json_add_job_opts(struct json_object *root, const char *name,
                const char *pos = "";
 
                p = flist_entry(entry, struct print_option, list);
+               if (!num_jobs && !strcmp(p->name, "numjobs"))
+                       continue;
                if (p->value)
                        pos = p->value;
                json_object_add_value_string(dir_object, p->name, pos);
@@ -1135,7 +1137,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts,
        }
 
        if (opt_list)
-               json_add_job_opts(root, "job options", opt_list);
+               json_add_job_opts(root, "job options", opt_list, true);
 
        add_ddir_status_json(ts, rs, DDIR_READ, root);
        add_ddir_status_json(ts, rs, DDIR_WRITE, root);
@@ -1642,7 +1644,7 @@ void __show_run_stats(void)
                json_object_add_value_int(root, "timestamp", time_p);
                json_object_add_value_string(root, "time", time_buf);
                global = get_global_options();
-               json_add_job_opts(root, "global options", &global->opt_list);
+               json_add_job_opts(root, "global options", &global->opt_list, false);
                array = json_create_array();
                json_object_add_value_array(root, "jobs", array);
        }