From 33c48814e08cf961801bf37f759da2748eb3431b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 21 Jan 2013 09:46:06 -0700 Subject: [PATCH] Re-seed random generator when a file is reset Signed-off-by: Jens Axboe --- file.h | 9 +-------- filesetup.c | 14 ++++++++++++-- io_u.c | 2 +- ioengines.c | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/file.h b/file.h index 5f125c3b..95ecefe7 100644 --- a/file.h +++ b/file.h @@ -175,13 +175,6 @@ extern int init_random_map(struct thread_data *); extern void dup_files(struct thread_data *, struct thread_data *); extern int get_fileno(struct thread_data *, const char *); extern void free_release_files(struct thread_data *); - -static inline void fio_file_reset(struct fio_file *f) -{ - f->last_pos = f->file_offset; - f->last_start = -1ULL; - if (f->io_axmap) - axmap_reset(f->io_axmap); -} +void fio_file_reset(struct thread_data *, struct fio_file *); #endif diff --git a/filesetup.c b/filesetup.c index 478bda8c..d0aef21a 100644 --- a/filesetup.c +++ b/filesetup.c @@ -1073,7 +1073,7 @@ int add_file(struct thread_data *td, const char *fname) f->fd = -1; f->shadow_fd = -1; - fio_file_reset(f); + fio_file_reset(td, f); if (td->files_size <= td->files_index) { unsigned int new_size = td->o.nr_files + 1; @@ -1319,7 +1319,7 @@ void dup_files(struct thread_data *td, struct thread_data *org) assert(0); } __f->fd = -1; - fio_file_reset(__f); + fio_file_reset(td, __f); if (f->file_name) { __f->file_name = smalloc_strdup(f->file_name); @@ -1359,3 +1359,13 @@ void free_release_files(struct thread_data *td) td->files_index = 0; td->nr_normal_files = 0; } + +void fio_file_reset(struct thread_data *td, struct fio_file *f) +{ + f->last_pos = f->file_offset; + f->last_start = -1ULL; + if (f->io_axmap) + axmap_reset(f->io_axmap); + if (td->o.random_generator == FIO_RAND_GEN_LFSR) + lfsr_reset(&f->lfsr, td->rand_seeds[FIO_RAND_BLOCK_OFF]); +} diff --git a/io_u.c b/io_u.c index 3de04ef0..1658fb20 100644 --- a/io_u.c +++ b/io_u.c @@ -223,7 +223,7 @@ static int get_next_rand_block(struct thread_data *td, struct fio_file *f, return 0; if (td->o.time_based) { - fio_file_reset(f); + fio_file_reset(td, f); if (!get_next_rand_offset(td, f, ddir, b)) return 0; } diff --git a/ioengines.c b/ioengines.c index a87175a2..f81c46f6 100644 --- a/ioengines.c +++ b/ioengines.c @@ -397,7 +397,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) return 1; } - fio_file_reset(f); + fio_file_reset(td, f); fio_file_set_open(f); fio_file_clear_closing(f); disk_util_inc(f->du); -- 2.25.1