Add support for non-uniformly random file service type
[fio.git] / init.c
diff --git a/init.c b/init.c
index c579d5c04c82a3db6b9e7aca3dc1af9e955a7218..e8c8afb600cc488088de69cbd5d1684c23ac53d7 100644 (file)
--- a/init.c
+++ b/init.c
@@ -929,6 +929,22 @@ 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);
+               }
+       }
 
        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);