Only use true random generator for initial seed
authorJens Axboe <jens.axboe@oracle.com>
Thu, 25 Mar 2010 22:31:50 +0000 (23:31 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 25 Mar 2010 22:31:50 +0000 (23:31 +0100)
Than hokus pokus the rest. End result is still OK random, and
it doesn't compress (which is the real test here).

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
io_u.c

diff --git a/io_u.c b/io_u.c
index 3558a0734711a0c80518d11903b9b9f885e73713..23037f1a8c227114bbcf90b8c0372d8ca5ce108d 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1217,14 +1217,16 @@ void io_u_fill_buffer(struct thread_data *td, struct io_u *io_u,
        long *ptr = io_u->buf;
 
        if (!td->o.zero_buffers) {
-               while ((void *) ptr - io_u->buf < max_bs) {
-                       unsigned int r = __rand(&__fio_rand_state);
+               unsigned long r = __rand(&__fio_rand_state);
 
-                       if (sizeof(r) != sizeof(*ptr))
-                               r *= GOLDEN_RATIO_PRIME;
+               if (sizeof(int) != sizeof(*ptr))
+                       r *= (unsigned long) __rand(&__fio_rand_state);
 
+               while ((void *) ptr - io_u->buf < max_bs) {
                        *ptr = r;
                        ptr++;
+                       r *= GOLDEN_RATIO_PRIME;
+                       r >>= 3;
                }
        } else
                memset(ptr, 0, max_bs);