Add support for non-uniformly random file service type
[fio.git] / init.c
diff --git a/init.c b/init.c
index 9052addc9c7ff2117e557ad74ca5f90096f5e139..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);
@@ -1079,7 +1095,7 @@ static int setup_random_seeds(struct thread_data *td)
                seed *= 0x9e370001UL;
 
        for (i = 0; i < FIO_RAND_NR_OFFS; i++) {
-               td->rand_seeds[i] = seed;
+               td->rand_seeds[i] = seed * td->thread_number + i;
                seed *= 0x9e370001UL;
        }
 
@@ -1416,6 +1432,11 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                };
                const char *suf;
 
+               if (fio_option_is_set(o, bw_avg_time))
+                       p.avg_msec = min(o->log_avg_msec, o->bw_avg_time);
+               else
+                       o->bw_avg_time = p.avg_msec;
+
                if (p.log_gz_store)
                        suf = "log.fz";
                else
@@ -1436,6 +1457,11 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                };
                const char *suf;
 
+               if (fio_option_is_set(o, iops_avg_time))
+                       p.avg_msec = min(o->log_avg_msec, o->iops_avg_time);
+               else
+                       o->iops_avg_time = p.avg_msec;
+
                if (p.log_gz_store)
                        suf = "log.fz";
                else
@@ -2552,14 +2578,14 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                                    !strncmp(argv[optind], "-", 1))
                                        break;
 
-                               if (fio_client_add_ini_file(cur_client, argv[optind], 0))
+                               if (fio_client_add_ini_file(cur_client, argv[optind], false))
                                        break;
                                optind++;
                        }
                        break;
                case 'R':
                        did_arg = 1;
-                       if (fio_client_add_ini_file(cur_client, optarg, 1)) {
+                       if (fio_client_add_ini_file(cur_client, optarg, true)) {
                                do_exit++;
                                exit_val = 1;
                        }