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 5f125c3b5924e8f95b55be9cde1a00c7786fb13c..95ecefe7d4f5ec1abece4a862f8784caad4fe781 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 478bda8cb0331017b55574d8df67c09cd1151bed..d0aef21a9febb8976e4ea35043d1c971ff86a05f 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 3de04ef0eb91fe25d6561562f931ebfa7fb311f7..1658fb20896e10490161e4b71f3d2c362ede4d53 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 a87175a23aa74999999ec18a64edf823e84aff90..f81c46f6c525571da6f32d5f606d1ee168a75c86 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);