Unify gauss and zipf/pareto input values
[fio.git] / options.c
index a01b2d9b0c574621e127c1262ce965fc102e73f7..95e0e0c92f4c4df6fac94b97be9c9034187c3c03 100644 (file)
--- a/options.c
+++ b/options.c
@@ -715,9 +715,11 @@ static int str_random_distribution_cb(void *data, const char *str)
                return 0;
 
        if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
-               val = 1.1;
+               val = FIO_DEF_ZIPF;
        else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
-               val = 0.2;
+               val = FIO_DEF_PARETO;
+       else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
+               val = 0.0;
        else
                return 0;
 
@@ -736,12 +738,18 @@ static int str_random_distribution_cb(void *data, const char *str)
                        return 1;
                }
                td->o.zipf_theta.u.f = val;
-       } else {
+       } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
                if (val <= 0.00 || val >= 1.00) {
                        log_err("fio: pareto input out of range (0 < input < 1.0)\n");
                        return 1;
                }
                td->o.pareto_h.u.f = val;
+       } else {
+               if (val <= 0.00 || val >= 100.0) {
+                       log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
+                       return 1;
+               }
+               td->o.gauss_dev.u.f = val;
        }
 
        return 0;
@@ -884,18 +892,6 @@ out:
        return ret;
 }
 
-static int str_lockfile_cb(void *data, const char fio_unused *str)
-{
-       struct thread_data *td = data;
-
-       if (td->files_index) {
-               log_err("fio: lockfile= option must precede filename=\n");
-               return 1;
-       }
-
-       return 0;
-}
-
 static int str_opendir_cb(void *data, const char fio_unused *str)
 {
        struct thread_data *td = data;
@@ -1079,16 +1075,6 @@ static int str_gtod_reduce_cb(void *data, int *il)
        return 0;
 }
 
-static int str_gtod_cpu_cb(void *data, long long *il)
-{
-       struct thread_data *td = data;
-       int val = *il;
-
-       td->o.gtod_cpu = val;
-       td->o.gtod_offload = 1;
-       return 0;
-}
-
 static int str_size_cb(void *data, unsigned long long *__val)
 {
        struct thread_data *td = data;
@@ -1353,7 +1339,6 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .parent = "filename",
                .hide   = 0,
                .def    = "none",
-               .cb     = str_lockfile_cb,
                .category = FIO_OPT_C_FILE,
                .group  = FIO_OPT_G_FILENAME,
                .posval = {
@@ -1898,6 +1883,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .oval = FIO_RAND_DIST_PARETO,
                            .help = "Pareto distribution",
                          },
+                         { .ival = "normal",
+                           .oval = FIO_RAND_DIST_GAUSS,
+                           .help = "Normal (gaussian) distribution",
+                         },
                },
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_RANDOM,
@@ -2028,6 +2017,17 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_FILE,
                .group  = FIO_OPT_G_INVALID,
        },
+#ifdef FIO_HAVE_STREAMID
+       {
+               .name   = "fadvise_stream",
+               .lname  = "Fadvise stream",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(fadvise_stream),
+               .help   = "Use fadvise() to set stream ID",
+               .category = FIO_OPT_C_FILE,
+               .group  = FIO_OPT_G_INVALID,
+       },
+#endif
        {
                .name   = "fsync",
                .lname  = "Fsync",
@@ -3404,7 +3404,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .name   = "gtod_cpu",
                .lname  = "Dedicated gettimeofday() CPU",
                .type   = FIO_OPT_INT,
-               .cb     = str_gtod_cpu_cb,
+               .off1   = td_var_offset(gtod_cpu),
                .help   = "Set up dedicated gettimeofday() thread on this CPU",
                .verify = gtod_cpu_verify,
                .category = FIO_OPT_C_GENERAL,
@@ -4201,23 +4201,32 @@ struct fio_option *fio_option_find(const char *name)
        return find_option(fio_options, name);
 }
 
-int __fio_option_is_set(struct thread_options *o, unsigned int off1)
+static struct fio_option *find_next_opt(struct thread_options *o,
+                                       struct fio_option *from,
+                                       unsigned int off1)
 {
-       unsigned int opt_off, index, offset;
-       struct fio_option *opt = NULL;
-       int i;
+       struct fio_option *opt;
 
-       for (i = 0; fio_options[i].name; i++) {
-               if (off1 == fio_options[i].off1) {
-                       opt = &fio_options[i];
+       if (!from)
+               from = &fio_options[0];
+       else
+               from++;
+
+       opt = NULL;
+       do {
+               if (off1 == from->off1) {
+                       opt = from;
                        break;
                }
-       }
+               from++;
+       } while (from->name);
 
-       if (!opt) {
-               log_err("fio: no option found at offset %u\n", off1);
-               return 0;
-       }
+       return opt;
+}
+
+static int opt_is_set(struct thread_options *o, struct fio_option *opt)
+{
+       unsigned int opt_off, index, offset;
 
        opt_off = opt - &fio_options[0];
        index = opt_off / (8 * sizeof(uint64_t));
@@ -4225,6 +4234,21 @@ int __fio_option_is_set(struct thread_options *o, unsigned int off1)
        return (o->set_options[index] & (1UL << offset)) != 0;
 }
 
+int __fio_option_is_set(struct thread_options *o, unsigned int off1)
+{
+       struct fio_option *opt, *next;
+
+       next = NULL;
+       while ((opt = find_next_opt(o, next, off1)) != NULL) {
+               if (opt_is_set(o, opt))
+                       return 1;
+
+               next = opt;
+       }
+
+       return 0;
+}
+
 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
 {
        unsigned int opt_off, index, offset;