Add LFSR generator
[fio.git] / options.c
index 05a6a5081fa576810c9071506e634077ec27a401..d46bcbbcf6c9cab8fc1c41e8800bc5071429ccd9 100644 (file)
--- a/options.c
+++ b/options.c
@@ -734,20 +734,36 @@ static int str_random_distribution_cb(void *data, const char *str)
        double val;
        char *nr;
 
-       if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
+       if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
+               val = 1.1;
+       else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
+               val = 0.2;
+       else
                return 0;
 
        nr = get_opt_postfix(str);
-       if (!nr)
-               val = 0.6;
-       else if (!str_to_float(nr, &val)) {
+       if (nr && !str_to_float(nr, &val)) {
                log_err("fio: random postfix parsing failed\n");
                free(nr);
                return 1;
        }
 
-       td->o.zipf_theta = val;
        free(nr);
+
+       if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
+               if (val == 1.00) {
+                       log_err("fio: zipf theta must different than 1.0\n");
+                       return 1;
+               }
+               td->o.zipf_theta = val;
+       } else {
+               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 = val;
+       }
+
        return 0;
 }
 
@@ -1495,6 +1511,23 @@ static struct fio_option options[FIO_MAX_OPTS] = {
                .parent = "norandommap",
                .def    = "0",
        },
+       {
+               .name   = "random_generator",
+               .type   = FIO_OPT_STR,
+               .off1   = td_var_offset(random_generator),
+               .help   = "Type of random number generator to use",
+               .def    = "tausworthe",
+               .posval = {
+                         { .ival = "tausworthe",
+                           .oval = FIO_RAND_GEN_TAUSWORTHE,
+                           .help = "Strong Tausworthe generator",
+                         },
+                         { .ival = "lfsr",
+                           .oval = FIO_RAND_GEN_LFSR,
+                           .help = "Variable length LFSR",
+                         },
+               },
+       },
        {
                .name   = "random_distribution",
                .type   = FIO_OPT_STR,
@@ -1511,6 +1544,10 @@ static struct fio_option options[FIO_MAX_OPTS] = {
                            .oval = FIO_RAND_DIST_ZIPF,
                            .help = "Zipf distribution",
                          },
+                         { .ival = "pareto",
+                           .oval = FIO_RAND_DIST_PARETO,
+                           .help = "Pareto distribution",
+                         },
                },
        },
        {