Re-seed random generator when a file is reset
authorJens Axboe <axboe@kernel.dk>
Mon, 21 Jan 2013 16:46:06 +0000 (09:46 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 21 Jan 2013 16:46:06 +0000 (09:46 -0700)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
file.h
filesetup.c
io_u.c
ioengines.c

diff --git a/file.h b/file.h
index 5f125c3..95ecefe 100644 (file)
--- 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
index 478bda8..d0aef21 100644 (file)
@@ -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 3de04ef..1658fb2 100644 (file)
--- 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;
        }
index a87175a..f81c46f 100644 (file)
@@ -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);