io_u: sequence random buflen generation individually
authorJens Axboe <axboe@kernel.dk>
Fri, 7 Jul 2017 14:33:57 +0000 (08:33 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 7 Jul 2017 14:33:57 +0000 (08:33 -0600)
For trimwrite, we rely on write+trim generating identical
buffer lengths, if they have identical settings. If we use
bssplit, then we generate them using a random generator
according to the percentages set. This means we may not get
the same offsets in sequence.

Split the seeding into separate random generators, and ensure
that we seed the write and trim ones identically, if we are
doing trim writes.

Fixes: https://github.com/axboe/fio/issues/399
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio.h
init.c
io_u.c

diff --git a/fio.h b/fio.h
index d5d6bfe..39d775c 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -91,6 +91,8 @@ enum {
 
 enum {
        FIO_RAND_BS_OFF         = 0,
+       FIO_RAND_BS1_OFF,
+       FIO_RAND_BS2_OFF,
        FIO_RAND_VER_OFF,
        FIO_RAND_MIX_OFF,
        FIO_RAND_FILE_OFF,
@@ -214,7 +216,7 @@ struct thread_data {
 
        unsigned long rand_seeds[FIO_RAND_NR_OFFS];
 
-       struct frand_state bsrange_state;
+       struct frand_state bsrange_state[DDIR_RWDIR_CNT];
        struct frand_state verify_state;
        struct frand_state trim_state;
        struct frand_state delay_state;
diff --git a/init.c b/init.c
index a4b5adb..1f1ceeb 100644 (file)
--- a/init.c
+++ b/init.c
@@ -921,7 +921,16 @@ static void td_fill_rand_seeds_internal(struct thread_data *td, bool use64)
 {
        int i;
 
-       init_rand_seed(&td->bsrange_state, td->rand_seeds[FIO_RAND_BS_OFF], use64);
+       if (td_trimwrite(td)) {
+               init_rand_seed(&td->bsrange_state[DDIR_READ], td->rand_seeds[FIO_RAND_BS_OFF], use64);
+               init_rand_seed(&td->bsrange_state[DDIR_WRITE], td->rand_seeds[FIO_RAND_BS1_OFF], use64);
+               init_rand_seed(&td->bsrange_state[DDIR_TRIM], td->rand_seeds[FIO_RAND_BS1_OFF], use64);
+       } else {
+               init_rand_seed(&td->bsrange_state[DDIR_READ], td->rand_seeds[FIO_RAND_BS_OFF], use64);
+               init_rand_seed(&td->bsrange_state[DDIR_WRITE], td->rand_seeds[FIO_RAND_BS1_OFF], use64);
+               init_rand_seed(&td->bsrange_state[DDIR_TRIM], td->rand_seeds[FIO_RAND_BS2_OFF], use64);
+       }
+
        td_fill_verify_state_seed(td);
        init_rand_seed(&td->rwmix_state, td->rand_seeds[FIO_RAND_MIX_OFF], false);
 
diff --git a/io_u.c b/io_u.c
index 8d42d65..ed8e84a 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -552,9 +552,9 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
        if (!io_u_fits(td, io_u, minbs))
                return 0;
 
-       frand_max = rand_max(&td->bsrange_state);
+       frand_max = rand_max(&td->bsrange_state[ddir]);
        do {
-               r = __rand(&td->bsrange_state);
+               r = __rand(&td->bsrange_state[ddir]);
 
                if (!td->o.bssplit_nr[ddir]) {
                        buflen = 1 + (unsigned int) ((double) maxbs *