From d77431b5975096bfd9aafb431c0aa656c9ae8fa8 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 25 Mar 2010 23:31:50 +0100 Subject: [PATCH] Only use true random generator for initial seed 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 --- io_u.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/io_u.c b/io_u.c index 3558a073..23037f1a 100644 --- 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); -- 2.25.1