+ goto err_out;
+
+ if (!o->zone_size)
+ o->zone_size = o->size;
+
+ /*
+ * iolog already set the total io size, if we read back
+ * stored entries.
+ */
+ if (!o->read_iolog_file) {
+ if (o->io_limit)
+ td->total_io_size = o->io_limit * o->loops;
+ else
+ td->total_io_size = o->size * o->loops;
+ }
+
+done:
+ if (o->create_only)
+ td->done = 1;
+
+ td_restore_runstate(td, old_state);
+ return 0;
+err_offset:
+ log_err("%s: you need to specify valid offset=\n", o->name);
+err_out:
+ td_restore_runstate(td, old_state);
+ return 1;
+}
+
+int pre_read_files(struct thread_data *td)
+{
+ struct fio_file *f;
+ unsigned int i;
+
+ dprint(FD_FILE, "pre_read files\n");
+
+ for_each_file(td, f, i) {
+ pre_read_file(td, f);
+ }
+
+ return 1;
+}
+
+static int __init_rand_distribution(struct thread_data *td, struct fio_file *f)
+{
+ unsigned int range_size, seed;
+ unsigned long nranges;
+ uint64_t fsize;
+
+ range_size = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
+ fsize = min(f->real_file_size, f->io_size);
+
+ nranges = (fsize + range_size - 1) / range_size;
+
+ seed = jhash(f->file_name, strlen(f->file_name), 0) * td->thread_number;
+ if (!td->o.rand_repeatable)
+ seed = td->rand_seeds[4];
+
+ if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
+ zipf_init(&f->zipf, nranges, td->o.zipf_theta.u.f, seed);
+ else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
+ pareto_init(&f->zipf, nranges, td->o.pareto_h.u.f, seed);
+ else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
+ gauss_init(&f->gauss, nranges, td->o.gauss_dev.u.f, seed);
+
+ return 1;
+}
+
+static int init_rand_distribution(struct thread_data *td)
+{
+ struct fio_file *f;
+ unsigned int i;
+ int state;
+
+ if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
+ return 0;
+
+ state = td_bump_runstate(td, TD_SETTING_UP);
+
+ for_each_file(td, f, i)
+ __init_rand_distribution(td, f);
+
+ td_restore_runstate(td, state);
+
+ return 1;
+}