From 876e10015bc3191a71512c3ae57482bf1add4e0e Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 15 Dec 2015 10:38:05 -0700 Subject: [PATCH] stat: work around 'numjobs' oddity in dumping job output Inherit options between duped jobs, and don't include 'numjobs' in the global option output. Signed-off-by: Jens Axboe --- init.c | 23 +++++++++++++++++++++++ stat.c | 8 +++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/init.c b/init.c index e314fa1d..8773138c 100644 --- 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 e47b510f..1c1dceb5 100644 --- 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); } -- 2.25.1