Add support for normal/gaussian random distributions
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index a45dd4021c4e161f945367a3aec59dde0ebd4c57..16065128c324e76e3cf9326ff1824fec42baad5b 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -149,6 +149,15 @@ static int __get_next_rand_offset_pareto(struct thread_data *td,
        return 0;
 }
 
        return 0;
 }
 
+static int __get_next_rand_offset_gauss(struct thread_data *td,
+                                       struct fio_file *f, enum fio_ddir ddir,
+                                       uint64_t *b)
+{
+       *b = gauss_next(&f->gauss);
+       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);
 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);
@@ -166,6 +175,8 @@ static int get_off_from_method(struct thread_data *td, struct fio_file *f,
                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);
                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);
+       else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
+               return __get_next_rand_offset_gauss(td, f, ddir, b);
 
        log_err("fio: unknown random distribution: %d\n", td->o.random_distribution);
        return 1;
 
        log_err("fio: unknown random distribution: %d\n", td->o.random_distribution);
        return 1;
@@ -1484,8 +1495,7 @@ struct io_u *get_io_u(struct thread_data *td)
                                io_u_fill_buffer(td, io_u,
                                        td->o.min_bs[DDIR_WRITE],
                                        io_u->xfer_buflen);
                                io_u_fill_buffer(td, io_u,
                                        td->o.min_bs[DDIR_WRITE],
                                        io_u->xfer_buflen);
-                       }
-                       if ((td->flags & TD_F_SCRAMBLE_BUFFERS) &&
+                       } else if ((td->flags & TD_F_SCRAMBLE_BUFFERS) &&
                                   !(td->flags & TD_F_COMPRESS))
                                do_scramble = 1;
                        if (td->flags & TD_F_VER_NONE) {
                                   !(td->flags & TD_F_COMPRESS))
                                do_scramble = 1;
                        if (td->flags & TD_F_VER_NONE) {