From 9dbc7bfe8aab6def3e2b51edd57942371e4e5366 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 23 Jan 2013 09:26:53 -0700 Subject: [PATCH 1/1] Ensure all random seeds are repeatable for randrepeat=1 Currently we only do the offset. Signed-off-by: Jens Axboe --- init.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/init.c b/init.c index 15b54116..d22ed5fd 100644 --- a/init.c +++ b/init.c @@ -706,7 +706,6 @@ void td_fill_rand_seeds(struct thread_data *td) init_rand_seed(&td->buf_state, td->rand_seeds[FIO_RAND_BUF_OFF]); } - /* * Initializes the ioengine configured for a job, if it has not been done so * already. @@ -781,6 +780,26 @@ static void init_flags(struct thread_data *td) td->flags |= TD_F_VER_NONE; } +static int setup_random_seeds(struct thread_data *td) +{ + unsigned long seed; + unsigned int i; + + if (!td->o.rand_repeatable) + return init_random_state(td, td->rand_seeds, sizeof(td->rand_seeds)); + + for (seed = 0x89, i = 0; i < 4; i++) + seed *= 0x9e370001UL; + + for (i = 0; i < FIO_RAND_NR_OFFS; i++) { + td->rand_seeds[i] = seed; + seed *= 0x9e370001UL; + } + + td_fill_rand_seeds(td); + return 0; +} + /* * Adds a job to the list of things todo. Sanitizes the various options * to make sure we don't have conflicts, and initializes various @@ -883,7 +902,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->groupid = groupid; prev_group_jobs++; - if (init_random_state(td, td->rand_seeds, sizeof(td->rand_seeds))) { + if (setup_random_seeds(td)) { td_verror(td, errno, "init_random_state"); goto err; } -- 2.25.1