From 82af46be1fa0c0e188bbb6723008fa33a510606f Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 4 Dec 2012 13:12:25 +0100 Subject: [PATCH] lfsr: ensure that the cycle follows the randrepeat= setting Use the regular block offset seed to "seed" the lfsr generator, so that it obeys randrepeat=0/1 as well. Signed-off-by: Jens Axboe --- filesetup.c | 6 +++++- lib/lfsr.c | 4 ++-- lib/lfsr.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/filesetup.c b/filesetup.c index 9fb325bd..f4e1adcb 100644 --- a/filesetup.c +++ b/filesetup.c @@ -918,7 +918,11 @@ int init_random_map(struct thread_data *td) blocks = (f->real_file_size + td->o.rw_min_bs - 1) / (unsigned long long) td->o.rw_min_bs; if (td->o.random_generator == FIO_RAND_GEN_LFSR) { - if (!lfsr_init(&f->lfsr, blocks)) + unsigned long seed; + + seed = td->rand_seeds[FIO_RAND_BLOCK_OFF]; + + if (!lfsr_init(&f->lfsr, blocks, seed)) continue; } else if (!td->o.norandommap) { f->io_axmap = axmap_new(blocks); diff --git a/lib/lfsr.c b/lib/lfsr.c index 01c97cb8..8a700296 100644 --- a/lib/lfsr.c +++ b/lib/lfsr.c @@ -243,7 +243,7 @@ static struct lfsr_taps *find_lfsr(uint64_t size) return NULL; } -int lfsr_init(struct fio_lfsr *fl, uint64_t size) +int lfsr_init(struct fio_lfsr *fl, uint64_t size, unsigned long seed) { struct lfsr_taps *tap; int i; @@ -252,7 +252,7 @@ int lfsr_init(struct fio_lfsr *fl, uint64_t size) if (!tap) return 1; - fl->last_val = 1; + fl->last_val = seed; fl->max_val = size - 1; fl->num_vals = 0; fl->taps.length = tap->length; diff --git a/lib/lfsr.h b/lib/lfsr.h index 0de9ea8e..09f5ac0b 100644 --- a/lib/lfsr.h +++ b/lib/lfsr.h @@ -19,6 +19,6 @@ struct fio_lfsr { }; int lfsr_next(struct fio_lfsr *fl, uint64_t *off); -int lfsr_init(struct fio_lfsr *fl, uint64_t size); +int lfsr_init(struct fio_lfsr *fl, uint64_t size, unsigned long seed); #endif -- 2.25.1