Add pareto distribution randomizer
[fio.git] / init.c
diff --git a/init.c b/init.c
index b3215f52fca3ebb2306c5e02e8437aac0a6d57fa..bf4aa03041435a038bd6fd72b636cab10ddd4c9a 100644 (file)
--- a/init.c
+++ b/init.c
@@ -382,6 +382,24 @@ static int fixed_block_size(struct thread_options *o)
                o->min_bs[DDIR_READ] == o->min_bs[DDIR_TRIM];
 }
 
+static void init_rand_distribution(struct thread_data *td)
+{
+       unsigned int range_size;
+       unsigned long nranges;
+
+       if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
+               return;
+
+       range_size = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
+
+       nranges = (td->o.size + range_size - 1) / range_size;
+
+       if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
+               zipf_init(&td->zipf, nranges, td->o.zipf_theta);
+       else
+               pareto_init(&td->zipf, nranges, td->o.pareto_h);
+}
+
 /*
  * Lazy way of fixing up options that depend on each other. We could also
  * define option callback handlers, but this is easier.
@@ -592,6 +610,8 @@ static int fixup_options(struct thread_data *td)
                td->o.compress_percentage = 0;
        }
 
+       init_rand_distribution(td);
+
        return ret;
 }
 
@@ -1198,7 +1218,7 @@ static int fill_def_thread(void)
 
        fio_getaffinity(getpid(), &def_thread.o.cpumask);
        def_thread.o.timeout = def_timeout;
-
+       def_thread.o.error_dump = 1;
        /*
         * fill default options
         */
@@ -1456,8 +1476,8 @@ int parse_cmd_line(int argc, char *argv[])
                        break;
                case 'V':
                        terse_version = atoi(optarg);
-                       if (!(terse_version == 2 || terse_version == 3) ||
-                            (terse_version == 4)) {
+                       if (!(terse_version == 2 || terse_version == 3 ||
+                            terse_version == 4)) {
                                log_err("fio: bad terse version format\n");
                                exit_val = 1;
                                do_exit++;