init: cleanup random inits
authorJens Axboe <axboe@fb.com>
Tue, 17 May 2016 14:16:12 +0000 (08:16 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 17 May 2016 14:16:12 +0000 (08:16 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
init.c
options.c

diff --git a/init.c b/init.c
index e8c8afb600cc488088de69cbd5d1684c23ac53d7..7166ea766d8a669bddf619dd105b3b8ce6b3f58d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -919,6 +919,23 @@ static int exists_and_not_file(const char *filename)
        return 1;
 }
 
+static void init_rand_file_service(struct thread_data *td)
+{
+       unsigned long nranges = td->o.nr_files << FIO_FSERVICE_SHIFT;
+       const unsigned int seed = td->rand_seeds[FIO_RAND_FILE_OFF];
+
+       if (td->o.file_service_type == FIO_FSERVICE_ZIPF) {
+               zipf_init(&td->next_file_zipf, nranges, td->zipf_theta, seed);
+               zipf_disable_hash(&td->next_file_zipf);
+       } else if (td->o.file_service_type == FIO_FSERVICE_PARETO) {
+               pareto_init(&td->next_file_zipf, nranges, td->pareto_h, seed);
+               zipf_disable_hash(&td->next_file_zipf);
+       } else if (td->o.file_service_type == FIO_FSERVICE_GAUSS) {
+               gauss_init(&td->next_file_gauss, nranges, td->gauss_dev, seed);
+               gauss_disable_hash(&td->next_file_gauss);
+       }
+}
+
 static void td_fill_rand_seeds_internal(struct thread_data *td, bool use64)
 {
        int i;
@@ -929,22 +946,8 @@ static void td_fill_rand_seeds_internal(struct thread_data *td, bool use64)
 
        if (td->o.file_service_type == FIO_FSERVICE_RANDOM)
                init_rand_seed(&td->next_file_state, td->rand_seeds[FIO_RAND_FILE_OFF], use64);
-       else if (td->o.file_service_type & __FIO_FSERVICE_NONUNIFORM) {
-               unsigned long nranges;
-
-               nranges = td->o.nr_files << FIO_FSERVICE_SHIFT;
-
-               if (td->o.file_service_type == FIO_FSERVICE_ZIPF) {
-                       zipf_init(&td->next_file_zipf, nranges, td->zipf_theta, td->rand_seeds[FIO_RAND_FILE_OFF]);
-                       zipf_disable_hash(&td->next_file_zipf);
-               } else if (td->o.file_service_type == FIO_FSERVICE_PARETO) {
-                       pareto_init(&td->next_file_zipf, nranges, td->pareto_h, td->rand_seeds[FIO_RAND_FILE_OFF]);
-                       zipf_disable_hash(&td->next_file_zipf);
-               } else if (td->o.file_service_type == FIO_FSERVICE_GAUSS) {
-                       gauss_init(&td->next_file_gauss, nranges, td->gauss_dev, td->rand_seeds[FIO_RAND_FILE_OFF]);
-                       gauss_disable_hash(&td->next_file_gauss);
-               }
-       }
+       else if (td->o.file_service_type & __FIO_FSERVICE_NONUNIFORM)
+               init_rand_file_service(td);
 
        init_rand_seed(&td->file_size_state, td->rand_seeds[FIO_RAND_FILE_SIZE_OFF], use64);
        init_rand_seed(&td->trim_state, td->rand_seeds[FIO_RAND_TRIM_OFF], use64);
index a9256632d360c3cab7be2a7f67bf77886285cf65..07589c47509787719362f0b6b2d0fefe2b3eb4f2 100644 (file)
--- a/options.c
+++ b/options.c
@@ -788,7 +788,7 @@ static int str_fst_cb(void *data, const char *str)
                break;
        case FIO_FSERVICE_GAUSS:
                if (val < 0.00 || val >= 100.00) {
-                          log_err("fio: normal deviation out of range (0 < input < 100.0  )\n");
+                          log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
                           return 1;
                }
                if (parse_dryrun())
@@ -1048,7 +1048,7 @@ static int str_random_distribution_cb(void *data, const char *str)
                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");
+                       log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
                        return 1;
                }
                if (parse_dryrun())