parse: get rid of raw option offsets
authorJens Axboe <axboe@fb.com>
Tue, 11 Feb 2014 21:19:38 +0000 (14:19 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 11 Feb 2014 21:19:38 +0000 (14:19 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
goptions.c
options.c
parse.c
parse.h
profile.c
profile.h
profiles/act.c
profiles/tiobench.c

index 08b17ac931ae2395ecc38c00a070fd9701505cdd..33183682d97f7eb3f2ab0887ffe6cea575245e24 100644 (file)
@@ -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;
 
                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)
 
                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;
 
                        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)
 
                        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;
 
                        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)
 
                        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;
 
                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)
 
                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;
 
                        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)
 
                        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 *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;
                        }
 
                                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 *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;
                }
 
                        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;
                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);
 
                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;
 
        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;
 
                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;
 
        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;
 
                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->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;
 
 
                        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);
                }
 
                        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;
 
        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;
 
                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->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 {
 
                        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 *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;
                }
 
                        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: {
                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;
 
                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)
 {
                                          struct gopt_str_multi *m,
                                          struct fio_option *o)
 {
-       unsigned int *ip = td_var(gjv->o, o->off1);
        struct value_pair *vp;
        struct value_pair *vp;
+       unsigned int *ip;
        gboolean set;
        guint val = 0;
        int i;
 
        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) {
        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)
 {
                                      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;
 
        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;
        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)
 {
                                        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;
 
        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;
 
        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)
 {
 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);
 
        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)
 {
 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;
 
        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;
 }
        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)
 {
 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;
        GtkAdjustment *adj;
+       unsigned int *ip;
        guint val;
 
        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;
        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)
 {
                                          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);
 
        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)
 {
                                          struct gopt_combo *c,
                                          struct fio_option *o)
 {
-       unsigned int *ip = td_var(gjv->o, o->off1);
+       unsigned int *ip;
        gint index;
 
        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;
 }
        index = gtk_combo_box_get_active(GTK_COMBO_BOX(c->combo));
        *ip = o->posval[index].oval;
 }
index 29b181a020ac5a62cdfd7b6eaed3fc6db133ab17..5ee70befced30f6729f6684b725d5493c9ca22ae 100644 (file)
--- a/options.c
+++ b/options.c
@@ -3786,7 +3786,13 @@ int add_option(struct fio_option *o)
                __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));
        memcpy(&fio_options[opt_index], o, sizeof(*o));
+       fio_options[opt_index + 1].name = NULL;
        return 0;
 }
 
        return 0;
 }
 
diff --git a/parse.c b/parse.c
index 6141c91e8d31c4e9d0822fb769f606e1bcd84b00..f82bca3fdccc22af2c704eb15e9ff98e2162f537 100644 (file)
--- 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));
 }
 
        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,
        } 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;
                        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;
                        }
                }
                                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) {
                        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 (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 (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 (!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 (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 {
                                        }
                                }
                        } 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 (!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;
                        */
                        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;
                        }
 
                                *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;
                }
                        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;
                }
 
                        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);
                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) {
                                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;
                        }
                                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;
 
        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);
                                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 (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 (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 (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 (!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 (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 (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 (!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;
                        }
                }
                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);
        }
                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);
                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->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);
                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;
 
                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;
                if (*ptr) {
                        free(*ptr);
                        *ptr = NULL;
diff --git a/parse.h b/parse.h
index 34d99d46d3e47d9b6c356d10aa6afeccf0eaadbf..66b1850ae9e753243e6289156c299bee79c447dc 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -49,7 +49,6 @@ struct fio_option {
        unsigned int off4;
        unsigned int off5;
        unsigned int off6;
        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 */
        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 */
        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;
        unsigned int category;          /* what type of option */
        unsigned int group;             /* who to group with */
        void *gui_data;
index 5d0b866708559c1adb5253306c83fe4fc50e3fd8..90c9ea8d14eb6c4d52c5a94bef7eab3e32fc0a0e 100644 (file)
--- 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 = ops->options;
        while (o->name) {
                o->prof_name = ops->name;
+               o->prof_opts = ops->opt_data;
                if (add_option(o))
                        return 1;
                o++;
                if (add_option(o))
                        return 1;
                o++;
index de35e9b192e8c089e918dc55e1b3e7243f3cd10d..8d1f757dd558a68d4bb28e5d0b9d6a6abf1f8710 100644 (file)
--- a/profile.h
+++ b/profile.h
@@ -27,6 +27,7 @@ struct profile_ops {
         * Profile specific options
         */
        struct fio_option *options;
         * Profile specific options
         */
        struct fio_option *options;
+       void *opt_data;
 
        /*
         * Called after parsing options, to prepare 'cmdline'
 
        /*
         * Called after parsing options, to prepare 'cmdline'
index 7e2f8af10876b6542b3307dc0539830ac91e7dc7..4d2ec5c33c2a4d9a99b34b686be0e1649b9731da 100644 (file)
@@ -74,12 +74,25 @@ static unsigned int org_idx;
 
 static int act_add_opt(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
 
 
 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,
 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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
        .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,
        .prep_cmd       = act_prep_cmdline,
        .cmdline        = act_opts,
        .io_ops         = &act_io_ops,
index bdb5985da006b11a4c611c48fc5e4e9e93f9b912..99c88c4507006176707804fc133aa8d45080169d 100644 (file)
@@ -21,12 +21,23 @@ static const char *tb_opts[] = {
        "name=randread", "stonewall", "rw=randread", NULL,
 };
 
        "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,
 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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
                .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,
        .prep_cmd       = tb_prep_cmdline,
        .cmdline        = tb_opts,
+       .options        = options,
+       .opt_data       = &tiobench_options,
 };
 
 static void fio_init tiobench_register(void)
 };
 
 static void fio_init tiobench_register(void)