The following changes since commit a7f5831f1feafbaa41a558028226b517734c54a0: Revert "Change preferred default clocksource to gettimeofday()" (2012-12-01 15:02:11 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (2): Name the various random offsets we use lfsr: ensure that the cycle follows the randrepeat= setting filesetup.c | 6 +++++- fio.h | 14 +++++++++++++- init.c | 34 +++++++++++++++++----------------- lib/lfsr.c | 4 ++-- lib/lfsr.h | 2 +- 5 files changed, 38 insertions(+), 22 deletions(-) --- Diff of recent changes: diff --git a/filesetup.c b/filesetup.c index 9fb325b..f4e1adc 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/fio.h b/fio.h index 58364aa..3de3f00 100644 --- a/fio.h +++ b/fio.h @@ -319,6 +319,18 @@ enum { TD_F_PROFILE_OPS = 64, }; +enum { + FIO_RAND_BS_OFF = 0, + FIO_RAND_VER_OFF, + FIO_RAND_MIX_OFF, + FIO_RAND_FILE_OFF, + FIO_RAND_BLOCK_OFF, + FIO_RAND_FILE_SIZE_OFF, + FIO_RAND_TRIM_OFF, + FIO_RAND_BUF_OFF, + FIO_RAND_NR_OFFS, +}; + /* * This describes a single thread/process executing a fio job. */ @@ -379,7 +391,7 @@ struct thread_data { char *sysfs_root; - unsigned long rand_seeds[8]; + unsigned long rand_seeds[FIO_RAND_NR_OFFS]; union { os_random_state_t bsrange_state; diff --git a/init.c b/init.c index 563dcb7..e90d735 100644 --- a/init.c +++ b/init.c @@ -660,44 +660,44 @@ static int exists_and_not_file(const char *filename) static void td_fill_rand_seeds_os(struct thread_data *td) { - os_random_seed(td->rand_seeds[0], &td->bsrange_state); - os_random_seed(td->rand_seeds[1], &td->verify_state); - os_random_seed(td->rand_seeds[2], &td->rwmix_state); + os_random_seed(td->rand_seeds[FIO_RAND_BS_OFF], &td->bsrange_state); + os_random_seed(td->rand_seeds[FIO_RAND_VER_OFF], &td->verify_state); + os_random_seed(td->rand_seeds[FIO_RAND_MIX_OFF], &td->rwmix_state); if (td->o.file_service_type == FIO_FSERVICE_RANDOM) - os_random_seed(td->rand_seeds[3], &td->next_file_state); + os_random_seed(td->rand_seeds[FIO_RAND_FILE_OFF], &td->next_file_state); - os_random_seed(td->rand_seeds[5], &td->file_size_state); - os_random_seed(td->rand_seeds[6], &td->trim_state); + os_random_seed(td->rand_seeds[FIO_RAND_FILE_SIZE_OFF], &td->file_size_state); + os_random_seed(td->rand_seeds[FIO_RAND_TRIM_OFF], &td->trim_state); if (!td_random(td)) return; if (td->o.rand_repeatable) - td->rand_seeds[4] = FIO_RANDSEED * td->thread_number; + td->rand_seeds[FIO_RAND_BLOCK_OFF] = FIO_RANDSEED * td->thread_number; - os_random_seed(td->rand_seeds[4], &td->random_state); + os_random_seed(td->rand_seeds[FIO_RAND_BLOCK_OFF], &td->random_state); } static void td_fill_rand_seeds_internal(struct thread_data *td) { - init_rand_seed(&td->__bsrange_state, td->rand_seeds[0]); - init_rand_seed(&td->__verify_state, td->rand_seeds[1]); - init_rand_seed(&td->__rwmix_state, td->rand_seeds[2]); + init_rand_seed(&td->__bsrange_state, td->rand_seeds[FIO_RAND_BS_OFF]); + init_rand_seed(&td->__verify_state, td->rand_seeds[FIO_RAND_VER_OFF]); + init_rand_seed(&td->__rwmix_state, td->rand_seeds[FIO_RAND_MIX_OFF]); if (td->o.file_service_type == FIO_FSERVICE_RANDOM) - init_rand_seed(&td->__next_file_state, td->rand_seeds[3]); + init_rand_seed(&td->__next_file_state, td->rand_seeds[FIO_RAND_FILE_OFF]); - init_rand_seed(&td->__file_size_state, td->rand_seeds[5]); - init_rand_seed(&td->__trim_state, td->rand_seeds[6]); + init_rand_seed(&td->__file_size_state, td->rand_seeds[FIO_RAND_FILE_SIZE_OFF]); + init_rand_seed(&td->__trim_state, td->rand_seeds[FIO_RAND_TRIM_OFF]); if (!td_random(td)) return; if (td->o.rand_repeatable) - td->rand_seeds[4] = FIO_RANDSEED * td->thread_number; + td->rand_seeds[FIO_RAND_BLOCK_OFF] = FIO_RANDSEED * td->thread_number; - init_rand_seed(&td->__random_state, td->rand_seeds[4]); + init_rand_seed(&td->__random_state, td->rand_seeds[FIO_RAND_BLOCK_OFF]); } void td_fill_rand_seeds(struct thread_data *td) @@ -707,7 +707,7 @@ void td_fill_rand_seeds(struct thread_data *td) else td_fill_rand_seeds_internal(td); - init_rand_seed(&td->buf_state, td->rand_seeds[7]); + init_rand_seed(&td->buf_state, td->rand_seeds[FIO_RAND_BUF_OFF]); } diff --git a/lib/lfsr.c b/lib/lfsr.c index 01c97cb..8a70029 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 0de9ea8..09f5ac0 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 -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html