cleanup: add defines for default pareto or zipf values
[fio.git] / options.c
index a01b2d9b0c574621e127c1262ce965fc102e73f7..ab6e399db5208d81689c0ec9752fa0a7e4adeda1 100644 (file)
--- a/options.c
+++ b/options.c
@@ -715,9 +715,9 @@ 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
                return 0;
 
@@ -884,18 +884,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 +1067,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 +1331,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 = {
@@ -3404,7 +3381,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 +4178,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;
+
+       if (!from)
+               from = &fio_options[0];
+       else
+               from++;
 
-       for (i = 0; fio_options[i].name; i++) {
-               if (off1 == fio_options[i].off1) {
-                       opt = &fio_options[i];
+       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 +4211,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;