From 7b504eddc4b039f2db3a0626bd08f880c5f4de27 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 11 Feb 2014 14:19:38 -0700 Subject: [PATCH 1/1] parse: get rid of raw option offsets Signed-off-by: Jens Axboe --- goptions.c | 211 +++++++++++++++++++++++++++++++++++--------- options.c | 6 ++ parse.c | 174 +++++++++++++++--------------------- parse.h | 2 +- profile.c | 1 + profile.h | 1 + profiles/act.c | 28 ++++-- profiles/tiobench.c | 23 +++-- 8 files changed, 285 insertions(+), 161 deletions(-) diff --git a/goptions.c b/goptions.c index 08b17ac9..33183682 100644 --- a/goptions.c +++ b/goptions.c @@ -885,8 +885,12 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, unsigned long long *ullp = NULL; struct gopt_int *i; - if (o->off1) - ullp = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ullp = td_var(o->prof_opts, o->off1); + else + ullp = td_var(to, o->off1); + } i = container_of(gopt, struct gopt_int, gopt); if (ullp) @@ -898,8 +902,12 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, unsigned int *ip = NULL; struct gopt_combo *c; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } c = container_of(gopt, struct gopt_combo, gopt); if (ip) @@ -908,8 +916,12 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, unsigned int *ip = NULL; struct gopt_int *i; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } i = container_of(gopt, struct gopt_int, gopt); if (ip) @@ -921,8 +933,12 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, unsigned int *ip = NULL; struct gopt_bool *b; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } b = container_of(gopt, struct gopt_bool, gopt); if (ip) @@ -934,8 +950,12 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, unsigned int *ip = NULL; struct gopt_combo *c; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } c = container_of(gopt, struct gopt_combo, gopt); if (ip) @@ -945,7 +965,12 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, char *text = NULL; if (o->off1) { - char **p = td_var(to, o->off1); + char **p; + + if (o->prof_opts) + p = td_var(o->prof_opts, o->off1); + else + p = td_var(to, o->off1); text = *p; } @@ -961,7 +986,13 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, char *text = NULL; if (o->off1) { - char **p = td_var(to, o->off1); + char **p; + + if (o->prof_opts) + p = td_var(o->prof_opts, o->off1); + else + p = td_var(to, o->off1); + text = *p; } @@ -983,10 +1014,19 @@ static void gopt_set_option(struct gopt_job_view *gjv, struct fio_option *o, break; case FIO_OPT_RANGE: { struct gopt_range *r; - unsigned int *ip[4] = { td_var(to, o->off1), - td_var(to, o->off2), - td_var(to, o->off3), - td_var(to, o->off4) }; + unsigned int *ip[4]; + + if (o->prof_opts) { + ip[0] = td_var(o->prof_opts, o->off1); + ip[1] = td_var(o->prof_opts, o->off2); + ip[2] = td_var(o->prof_opts, o->off3); + ip[3] = td_var(o->prof_opts, o->off4); + } else { + ip[0] = td_var(to, o->off1); + ip[1] = td_var(to, o->off2); + ip[2] = td_var(to, o->off3); + ip[3] = td_var(to, o->off4); + } r = container_of(gopt, struct gopt_range, gopt); gopt_int_range_set_val(r, *ip); @@ -1013,8 +1053,12 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox, case FIO_OPT_STR_VAL: { unsigned long long *ullp = NULL; - if (o->off1) - ullp = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ullp = td_var(o->prof_opts, o->off1); + else + ullp = td_var(to, o->off1); + } go = gopt_new_str_val(gjv, o, ullp, opt_index); break; @@ -1022,8 +1066,12 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox, case FIO_OPT_STR_VAL_TIME: { unsigned long long *ullp = NULL; - if (o->off1) - ullp = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ullp = td_var(o->prof_opts, o->off1); + else + ullp = td_var(to, o->off1); + } go = gopt_new_ullong(gjv, o, ullp, opt_index); break; @@ -1032,15 +1080,23 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox, if (o->posval[0].ival) { unsigned int *ip = NULL; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } go = gopt_new_combo_int(gjv, o, ip, opt_index); } else { unsigned int *ip = NULL; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } go = gopt_new_int(gjv, o, ip, opt_index); } @@ -1049,8 +1105,12 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox, case FIO_OPT_BOOL: { unsigned int *ip = NULL; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } go = gopt_new_bool(gjv, o, ip, opt_index); break; @@ -1059,8 +1119,12 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox, if (o->posval[0].ival) { unsigned int *ip = NULL; - if (o->off1) - ip = td_var(to, o->off1); + if (o->off1) { + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(to, o->off1); + } go = gopt_new_combo_int(gjv, o, ip, opt_index); } else { @@ -1074,7 +1138,13 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox, char *text = NULL; if (o->off1) { - char **p = td_var(to, o->off1); + char **p; + + if (o->prof_opts) + p = td_var(o->prof_opts, o->off1); + else + p = td_var(to, o->off1); + text = *p; } @@ -1090,10 +1160,19 @@ static void gopt_add_option(struct gopt_job_view *gjv, GtkWidget *hbox, go = gopt_new_str_multi(gjv, o, opt_index); break; case FIO_OPT_RANGE: { - unsigned int *ip[4] = { td_var(to, o->off1), - td_var(to, o->off2), - td_var(to, o->off3), - td_var(to, o->off4) }; + unsigned int *ip[4]; + + if (o->prof_opts) { + ip[0] = td_var(o->prof_opts, o->off1); + ip[1] = td_var(o->prof_opts, o->off2); + ip[2] = td_var(o->prof_opts, o->off3); + ip[3] = td_var(o->prof_opts, o->off4); + } else { + ip[0] = td_var(to, o->off1); + ip[1] = td_var(to, o->off2); + ip[2] = td_var(to, o->off3); + ip[3] = td_var(to, o->off4); + } go = gopt_new_int_range(gjv, o, ip, opt_index); break; @@ -1203,12 +1282,17 @@ static void gopt_handle_str_multi_changed(struct gopt_job_view *gjv, struct gopt_str_multi *m, struct fio_option *o) { - unsigned int *ip = td_var(gjv->o, o->off1); struct value_pair *vp; + unsigned int *ip; gboolean set; guint val = 0; int i; + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(gjv->o, o->off1); + i = 0; vp = &o->posval[0]; while (vp->ival) { @@ -1233,13 +1317,22 @@ static void gopt_handle_range_changed(struct gopt_job_view *gjv, struct gopt_range *r, struct fio_option *o) { - unsigned int *ip[4] = { td_var(gjv->o, o->off1), - td_var(gjv->o, o->off2), - td_var(gjv->o, o->off3), - td_var(gjv->o, o->off4) }; + unsigned int *ip[4]; gint val; int i; + if (o->prof_opts) { + ip[0] = td_var(o->prof_opts, o->off1); + ip[1] = td_var(o->prof_opts, o->off2); + ip[2] = td_var(o->prof_opts, o->off3); + ip[3] = td_var(o->prof_opts, o->off4); + } else { + ip[0] = td_var(gjv->o, o->off1); + ip[1] = td_var(gjv->o, o->off2); + ip[2] = td_var(gjv->o, o->off3); + ip[3] = td_var(gjv->o, o->off4); + } + for (i = 0; i < GOPT_RANGE_SPIN; i++) { val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(r->spins[i])); *ip[i] = val; @@ -1250,10 +1343,15 @@ static void gopt_handle_str_val_changed(struct gopt_job_view *gjv, struct gopt_str_val *s, struct fio_option *o) { - unsigned long long *ullp = td_var(gjv->o, o->off1); + unsigned long long *ullp; GtkAdjustment *adj; gint index; + if (o->prof_opts) + ullp = td_var(o->prof_opts, o->off1); + else + ullp = td_var(gjv->o, o->off1); + if (!ullp) return; @@ -1274,7 +1372,12 @@ static void gopt_handle_str_val_changed(struct gopt_job_view *gjv, static void gopt_handle_str_changed(struct gopt_job_view *gjv, struct gopt_str *s, struct fio_option *o) { - char **p = td_var(gjv->o, o->off1); + char **p; + + if (o->prof_opts) + p = td_var(o->prof_opts, o->off1); + else + p = td_var(gjv->o, o->off1); if (*p) free(*p); @@ -1285,9 +1388,14 @@ static void gopt_handle_str_changed(struct gopt_job_view *gjv, static void gopt_handle_bool_changed(struct gopt_job_view *gjv, struct gopt_bool *b, struct fio_option *o) { - unsigned int *ip = td_var(gjv->o, o->off1); + unsigned int *ip; gboolean set; + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(gjv->o, o->off1); + set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b->check)); *ip = set; } @@ -1295,10 +1403,15 @@ static void gopt_handle_bool_changed(struct gopt_job_view *gjv, static void gopt_handle_int_changed(struct gopt_job_view *gjv, struct gopt_int *i, struct fio_option *o) { - unsigned int *ip = td_var(gjv->o, o->off1); GtkAdjustment *adj; + unsigned int *ip; guint val; + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(gjv->o, o->off1); + adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(i->spin)); val = gtk_adjustment_get_value(adj); *ip = val; @@ -1308,7 +1421,12 @@ static void gopt_handle_combo_str_changed(struct gopt_job_view *gjv, struct gopt_combo *c, struct fio_option *o) { - char **p = td_var(gjv->o, o->off1); + char **p; + + if (o->prof_opts) + p = td_var(o->prof_opts, o->off1); + else + p = td_var(gjv->o, o->off1); if (*p) free(*p); @@ -1320,9 +1438,14 @@ static void gopt_handle_combo_int_changed(struct gopt_job_view *gjv, struct gopt_combo *c, struct fio_option *o) { - unsigned int *ip = td_var(gjv->o, o->off1); + unsigned int *ip; gint index; + if (o->prof_opts) + ip = td_var(o->prof_opts, o->off1); + else + ip = td_var(gjv->o, o->off1); + index = gtk_combo_box_get_active(GTK_COMBO_BOX(c->combo)); *ip = o->posval[index].oval; } diff --git a/options.c b/options.c index 29b181a0..5ee70bef 100644 --- a/options.c +++ b/options.c @@ -3786,7 +3786,13 @@ int add_option(struct fio_option *o) __o++; } + if (opt_index + 1 == FIO_MAX_OPTS) { + log_err("fio: FIO_MAX_OPTS is too small\n"); + return 1; + } + memcpy(&fio_options[opt_index], o, sizeof(*o)); + fio_options[opt_index + 1].name = NULL; return 0; } diff --git a/parse.c b/parse.c index 6141c91e..f82bca3f 100644 --- a/parse.c +++ b/parse.c @@ -368,13 +368,16 @@ static int str_match_len(const struct value_pair *vp, const char *str) return max(strlen(vp->ival), opt_len(str)); } -#define val_store(ptr, val, off, or, data) \ - do { \ - ptr = td_var((data), (off)); \ - if ((or)) \ - *ptr |= (val); \ - else \ - *ptr = (val); \ +#define val_store(ptr, val, off, or, data, o) \ + do { \ + if ((o)->prof_opts) \ + ptr = td_var((o)->prof_opts, (off)); \ + else \ + ptr = td_var((data), (off)); \ + if ((or)) \ + *ptr |= (val); \ + else \ + *ptr = (val); \ } while (0) static int __handle_option(struct fio_option *o, const char *ptr, void *data, @@ -414,16 +417,8 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, all_skipped = 0; if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) { ret = 0; - if (o->roff1) { - if (vp->or) - *(unsigned int *) o->roff1 |= vp->oval; - else - *(unsigned int *) o->roff1 = vp->oval; - } else { - if (!o->off1) - continue; - val_store(ilp, vp->oval, o->off1, vp->or, data); - } + if (o->off1) + val_store(ilp, vp->oval, o->off1, vp->or, data, o); continue; } } @@ -490,50 +485,32 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, ret = fn(data, &ull); else { if (o->type == FIO_OPT_INT) { - if (first) { - if (o->roff1) - *(unsigned int *) o->roff1 = ull; - else - val_store(ilp, ull, o->off1, 0, data); - } + if (first) + val_store(ilp, ull, o->off1, 0, data, o); if (curr == 1) { - if (o->roff2) - *(unsigned int *) o->roff2 = ull; - else if (o->off2) - val_store(ilp, ull, o->off2, 0, data); + if (o->off2) + val_store(ilp, ull, o->off2, 0, data, o); } if (curr == 2) { - if (o->roff3) - *(unsigned int *) o->roff3 = ull; - else if (o->off3) - val_store(ilp, ull, o->off3, 0, data); + if (o->off3) + val_store(ilp, ull, o->off3, 0, data, o); } if (!more) { if (curr < 1) { - if (o->roff2) - *(unsigned int *) o->roff2 = ull; - else if (o->off2) - val_store(ilp, ull, o->off2, 0, data); + if (o->off2) + val_store(ilp, ull, o->off2, 0, data, o); } if (curr < 2) { - if (o->roff3) - *(unsigned int *) o->roff3 = ull; - else if (o->off3) - val_store(ilp, ull, o->off3, 0, data); + if (o->off3) + val_store(ilp, ull, o->off3, 0, data, o); } } } else { - if (first) { - if (o->roff1) - *(unsigned long long *) o->roff1 = ull; - else - val_store(ullp, ull, o->off1, 0, data); - } + if (first) + val_store(ullp, ull, o->off1, 0, data, o); if (!more) { - if (o->roff2) - *(unsigned long long *) o->roff2 = ull; - else if (o->off2) - val_store(ullp, ull, o->off2, 0, data); + if (o->off2) + val_store(ullp, ull, o->off2, 0, data, o); } } } @@ -549,11 +526,17 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, */ if (o->off2) { ul2 = 0; - ilp = td_var(data, o->off2); + if (o->prof_opts) + ilp = td_var(o->prof_opts, o->off2); + else + ilp = td_var(data, o->off2); *ilp = ul2; } - flp = td_var(data, o->off1); + if (o->prof_opts) + flp = td_var(o->prof_opts, o->off1); + else + flp = td_var(data, o->off1); for(i = 0; i < o->maxlen; i++) flp[i].u.f = 0.0; } @@ -577,7 +560,10 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, return 1; } - flp = td_var(data, o->off1); + if (o->prof_opts) + flp = td_var(o->prof_opts, o->off1); + else + flp = td_var(data, o->off1); flp[curr].u.f = uf; dprint(FD_PARSE, " out=%f\n", uf); @@ -595,7 +581,10 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, len++; if (o->off2) { - ilp = td_var(data, o->off2); + if (o->prof_opts) + ilp = td_var(o->prof_opts, o->off2); + else + ilp = td_var(data, o->off2); if (len > *ilp) *ilp = len; } @@ -606,10 +595,10 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, case FIO_OPT_STR_STORE: { fio_opt_str_fn *fn = o->cb; - if (o->roff1 || o->off1) { - if (o->roff1) - cp = (char **) o->roff1; - else if (o->off1) + if (o->off1) { + if (o->prof_opts) + cp = td_var(o->prof_opts, o->off1); + else cp = td_var(data, o->off1); *cp = strdup(ptr); @@ -691,50 +680,32 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, } if (first) { - if (o->roff1) - *(unsigned int *) o->roff1 = ul1; - else - val_store(ilp, ul1, o->off1, 0, data); - if (o->roff2) - *(unsigned int *) o->roff2 = ul2; - else - val_store(ilp, ul2, o->off2, 0, data); + val_store(ilp, ul1, o->off1, 0, data, o); + val_store(ilp, ul2, o->off2, 0, data, o); } if (curr == 1) { - if (o->roff3 && o->roff4) { - *(unsigned int *) o->roff3 = ul1; - *(unsigned int *) o->roff4 = ul2; - } else if (o->off3 && o->off4) { - val_store(ilp, ul1, o->off3, 0, data); - val_store(ilp, ul2, o->off4, 0, data); + if (o->off3 && o->off4) { + val_store(ilp, ul1, o->off3, 0, data, o); + val_store(ilp, ul2, o->off4, 0, data, o); } } if (curr == 2) { - if (o->roff5 && o->roff6) { - *(unsigned int *) o->roff5 = ul1; - *(unsigned int *) o->roff6 = ul2; - } else if (o->off5 && o->off6) { - val_store(ilp, ul1, o->off5, 0, data); - val_store(ilp, ul2, o->off6, 0, data); + if (o->off5 && o->off6) { + val_store(ilp, ul1, o->off5, 0, data, o); + val_store(ilp, ul2, o->off6, 0, data, o); } } if (!more) { if (curr < 1) { - if (o->roff3 && o->roff4) { - *(unsigned int *) o->roff3 = ul1; - *(unsigned int *) o->roff4 = ul2; - } else if (o->off3 && o->off4) { - val_store(ilp, ul1, o->off3, 0, data); - val_store(ilp, ul2, o->off4, 0, data); + if (o->off3 && o->off4) { + val_store(ilp, ul1, o->off3, 0, data, o); + val_store(ilp, ul2, o->off4, 0, data, o); } } if (curr < 2) { - if (o->roff5 && o->roff6) { - *(unsigned int *) o->roff5 = ul1; - *(unsigned int *) o->roff6 = ul2; - } else if (o->off5 && o->off6) { - val_store(ilp, ul1, o->off5, 0, data); - val_store(ilp, ul2, o->off6, 0, data); + if (o->off5 && o->off6) { + val_store(ilp, ul1, o->off5, 0, data, o); + val_store(ilp, ul2, o->off6, 0, data, o); } } } @@ -775,17 +746,11 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (fn) ret = fn(data, &il); else { - if (first) { - if (o->roff1) - *(unsigned int *)o->roff1 = il; - else - val_store(ilp, il, o->off1, 0, data); - } + if (first) + val_store(ilp, il, o->off1, 0, data, o); if (!more) { - if (o->roff2) - *(unsigned int *) o->roff2 = il; - else if (o->off2) - val_store(ilp, il, o->off2, 0, data); + if (o->off2) + val_store(ilp, il, o->off2, 0, data, o); } } break; @@ -1194,7 +1159,7 @@ void option_init(struct fio_option *o) log_err("Option %s: string set option with" " default will always be true\n", o->name); } - if (!o->cb && (!o->off1 && !o->roff1)) + if (!o->cb && !o->off1) log_err("Option %s: neither cb nor offset given\n", o->name); if (!o->category) { log_info("Option %s: no category defined. Setting to misc\n", o->name); @@ -1204,10 +1169,8 @@ void option_init(struct fio_option *o) if (o->type == FIO_OPT_STR || o->type == FIO_OPT_STR_STORE || o->type == FIO_OPT_STR_MULTI) return; - if (o->cb && ((o->off1 || o->off2 || o->off3 || o->off4) || - (o->roff1 || o->roff2 || o->roff3 || o->roff4))) { + if (o->cb && (o->off1 || o->off2 || o->off3 || o->off4)) log_err("Option %s: both cb and offset given\n", o->name); - } } /* @@ -1238,7 +1201,10 @@ void options_free(struct fio_option *options, void *data) if (o->type != FIO_OPT_STR_STORE || !o->off1) continue; - ptr = td_var(data, o->off1); + if (o->prof_opts) + ptr = td_var(o->prof_opts, o->off1); + else + ptr = td_var(data, o->off1); if (*ptr) { free(*ptr); *ptr = NULL; diff --git a/parse.h b/parse.h index 34d99d46..66b1850a 100644 --- a/parse.h +++ b/parse.h @@ -49,7 +49,6 @@ struct fio_option { unsigned int off4; unsigned int off5; unsigned int off6; - void *roff1, *roff2, *roff3, *roff4, *roff5, *roff6; unsigned int maxval; /* max and min value */ int minval; double maxfp; /* max and min floating value */ @@ -69,6 +68,7 @@ struct fio_option { struct fio_option *inv_opt; /* cached lookup */ int (*verify)(struct fio_option *, void *); const char *prof_name; /* only valid for specific profile */ + void *prof_opts; unsigned int category; /* what type of option */ unsigned int group; /* who to group with */ void *gui_data; diff --git a/profile.c b/profile.c index 5d0b8667..90c9ea8d 100644 --- a/profile.c +++ b/profile.c @@ -52,6 +52,7 @@ static int add_profile_options(struct profile_ops *ops) o = ops->options; while (o->name) { o->prof_name = ops->name; + o->prof_opts = ops->opt_data; if (add_option(o)) return 1; o++; diff --git a/profile.h b/profile.h index de35e9b1..8d1f757d 100644 --- a/profile.h +++ b/profile.h @@ -27,6 +27,7 @@ struct profile_ops { * Profile specific options */ struct fio_option *options; + void *opt_data; /* * Called after parsing options, to prepare 'cmdline' diff --git a/profiles/act.c b/profiles/act.c index 7e2f8af1..4d2ec5c3 100644 --- a/profiles/act.c +++ b/profiles/act.c @@ -74,12 +74,25 @@ static unsigned int org_idx; static int act_add_opt(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +struct act_options { + unsigned int pad; + char *device_names; + unsigned int load; + unsigned int prep; + unsigned int threads_per_queue; + unsigned int num_read_blocks; + unsigned int write_size; + unsigned long long test_duration; +}; + +static struct act_options act_options; + static struct fio_option options[] = { { .name = "device-names", .lname = "device-names", .type = FIO_OPT_STR_STORE, - .roff1 = &device_names, + .off1 = offsetof(struct act_options, device_names), .help = "Devices to use", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_ACT, @@ -88,7 +101,7 @@ static struct fio_option options[] = { .name = "load", .lname = "Load multiplier", .type = FIO_OPT_INT, - .roff1 = &load, + .off1 = offsetof(struct act_options, load), .help = "ACT load multipler (default 1x)", .def = "1", .category = FIO_OPT_C_PROFILE, @@ -98,7 +111,7 @@ static struct fio_option options[] = { .name = "test-duration", .lname = "Test duration", .type = FIO_OPT_STR_VAL_TIME, - .roff1 = &test_duration, + .off1 = offsetof(struct act_options, test_duration), .help = "How long the entire test takes to run", .def = "24h", .category = FIO_OPT_C_PROFILE, @@ -108,7 +121,7 @@ static struct fio_option options[] = { .name = "threads-per-queue", .lname = "Number of read IO threads per device", .type = FIO_OPT_INT, - .roff1 = &threads_per_queue, + .off1 = offsetof(struct act_options, threads_per_queue), .help = "Number of read IO threads per device", .def = "8", .category = FIO_OPT_C_PROFILE, @@ -118,7 +131,7 @@ static struct fio_option options[] = { .name = "read-req-num-512-blocks", .lname = "Number of 512b blocks to read", .type = FIO_OPT_INT, - .roff1 = &num_read_blocks, + .off1 = offsetof(struct act_options, num_read_blocks), .help = "Number of 512b blocks to read at the time", .def = "3", .category = FIO_OPT_C_PROFILE, @@ -128,7 +141,7 @@ static struct fio_option options[] = { .name = "large-block-op-kbytes", .lname = "Size of large block ops (writes)", .type = FIO_OPT_INT, - .roff1 = &write_size, + .off1 = offsetof(struct act_options, write_size), .help = "Size of large block ops (writes)", .def = "128k", .category = FIO_OPT_C_PROFILE, @@ -138,7 +151,7 @@ static struct fio_option options[] = { .name = "prep", .lname = "Run ACT prep phase", .type = FIO_OPT_STR_SET, - .roff1 = &prep, + .off1 = offsetof(struct act_options, prep), .help = "Set to run ACT prep phase", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_ACT, @@ -445,6 +458,7 @@ static struct profile_ops act_profile = { .name = "act", .desc = "ACT Aerospike like benchmark", .options = options, + .opt_data = &act_options, .prep_cmd = act_prep_cmdline, .cmdline = act_opts, .io_ops = &act_io_ops, diff --git a/profiles/tiobench.c b/profiles/tiobench.c index bdb5985d..99c88c45 100644 --- a/profiles/tiobench.c +++ b/profiles/tiobench.c @@ -21,12 +21,23 @@ static const char *tb_opts[] = { "name=randread", "stonewall", "rw=randread", NULL, }; +struct tiobench_options { + unsigned int pad; + unsigned long long size; + unsigned int loops; + unsigned int bs; + unsigned int nthreads; + char *dir; +}; + +static struct tiobench_options tiobench_options; + static struct fio_option options[] = { { .name = "size", .lname = "Tiobench size", .type = FIO_OPT_STR_VAL, - .roff1 = &size, + .off1 = offsetof(struct tiobench_options, size), .help = "Size in MB", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_TIOBENCH, @@ -35,7 +46,7 @@ static struct fio_option options[] = { .name = "block", .lname = "Tiobench block", .type = FIO_OPT_INT, - .roff1 = &bs, + .off1 = offsetof(struct tiobench_options, bs), .help = "Block size in bytes", .def = "4k", .category = FIO_OPT_C_PROFILE, @@ -45,7 +56,7 @@ static struct fio_option options[] = { .name = "numruns", .lname = "Tiobench numruns", .type = FIO_OPT_INT, - .roff1 = &loops, + .off1 = offsetof(struct tiobench_options, loops), .help = "Number of runs", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_TIOBENCH, @@ -54,7 +65,7 @@ static struct fio_option options[] = { .name = "dir", .lname = "Tiobench directory", .type = FIO_OPT_STR_STORE, - .roff1 = &dir, + .off1 = offsetof(struct tiobench_options, dir), .help = "Test directory", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_TIOBENCH, @@ -63,7 +74,7 @@ static struct fio_option options[] = { .name = "threads", .lname = "Tiobench threads", .type = FIO_OPT_INT, - .roff1 = &nthreads, + .off1 = offsetof(struct tiobench_options, nthreads), .help = "Number of Threads", .category = FIO_OPT_C_PROFILE, .group = FIO_OPT_G_TIOBENCH, @@ -105,6 +116,8 @@ static struct profile_ops tiobench_profile = { .options = options, .prep_cmd = tb_prep_cmdline, .cmdline = tb_opts, + .options = options, + .opt_data = &tiobench_options, }; static void fio_init tiobench_register(void) -- 2.25.1