+ /*
+ * if we are not maintaining a random map, we are done.
+ */
+ if (!file_randommap(td, f))
+ goto ret;
+
+ /*
+ * calculate map offset and check if it's free
+ */
+ if (random_map_free(f, *b))
+ goto ret;
+
+ dprint(FD_RANDOM, "get_next_rand_offset: offset %llu busy\n", *b);
+
+ *b = axmap_next_free(f->io_axmap, *b);
+ if (*b == (uint64_t) -1ULL)
+ return 1;
+ret:
+ return 0;
+}
+
+static int __get_next_rand_offset_zipf(struct thread_data *td,
+ struct fio_file *f, enum fio_ddir ddir,
+ uint64_t *b)
+{
+ *b = zipf_next(&f->zipf);
+ return 0;
+}
+
+static int __get_next_rand_offset_pareto(struct thread_data *td,
+ struct fio_file *f, enum fio_ddir ddir,
+ uint64_t *b)
+{
+ *b = pareto_next(&f->zipf);
+ return 0;
+}
+
+static int flist_cmp(void *data, struct flist_head *a, struct flist_head *b)
+{
+ struct rand_off *r1 = flist_entry(a, struct rand_off, list);
+ struct rand_off *r2 = flist_entry(b, struct rand_off, list);
+
+ return r1->off - r2->off;
+}
+
+static int get_off_from_method(struct thread_data *td, struct fio_file *f,
+ enum fio_ddir ddir, uint64_t *b)
+{
+ if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
+ return __get_next_rand_offset(td, f, ddir, b);
+ else if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
+ return __get_next_rand_offset_zipf(td, f, ddir, b);
+ else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
+ return __get_next_rand_offset_pareto(td, f, ddir, b);
+
+ log_err("fio: unknown random distribution: %d\n", td->o.random_distribution);