Fixing wraparound behavior for time-based sequential read jobs
authorDan Ehrenberg <dehrenberg@google.com>
Thu, 16 Aug 2012 06:58:21 +0000 (08:58 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 16 Aug 2012 06:58:21 +0000 (08:58 +0200)
Previously, a buggy patch made sequential jobs wrap around when they
reached an offset of 'size'. However, the appropriate wraparound is at
size + initial offset. This patch restores the previous behavior.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
file.h
filesetup.c
io_u.c

diff --git a/file.h b/file.h
index 51df839e8c0eaa1ca1262dc3b219f9c9471a2a71..68f9a6eead88014e129c90f6e93abf191d22020f 100644 (file)
--- a/file.h
+++ b/file.h
@@ -147,6 +147,7 @@ FILE_FLAG_FNS(partial_mmap);
 struct thread_data;
 extern void close_files(struct thread_data *);
 extern void close_and_free_files(struct thread_data *);
+extern unsigned long long get_start_offset(struct thread_data *);
 extern int __must_check setup_files(struct thread_data *);
 extern int __must_check file_invalidate_cache(struct thread_data *, struct fio_file *);
 extern int __must_check generic_open_file(struct thread_data *, struct fio_file *);
index 6277f0f40cd33d24f7ddd566f142ebb81f291d2e..3594a80faf3bfe8300e29fc7cc04f7c892e826f8 100644 (file)
@@ -657,6 +657,12 @@ static unsigned long long get_fs_free_counts(struct thread_data *td)
        return ret;
 }
 
+unsigned long long get_start_offset(struct thread_data *td)
+{
+       return td->o.start_offset +
+               (td->thread_number - 1) * td->o.offset_increment;
+}
+
 /*
  * Open the files and setup files sizes, creating files if necessary.
  */
@@ -718,8 +724,7 @@ int setup_files(struct thread_data *td)
        extend_size = total_size = 0;
        need_extend = 0;
        for_each_file(td, f, i) {
-               f->file_offset = td->o.start_offset +
-                       (td->thread_number - 1) * td->o.offset_increment;
+               f->file_offset = get_start_offset(td);
 
                if (!td->o.file_size_low) {
                        /*
diff --git a/io_u.c b/io_u.c
index 66463328dd0c3cd9667ce57095f998402da9fcf9..2f5456294cea559bd97504f7c534626eb0933344 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -256,7 +256,7 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f,
 {
        assert(ddir_rw(ddir));
 
-       if (f->last_pos >= f->io_size && td->o.time_based)
+       if (f->last_pos >= f->io_size + get_start_offset(td) && td->o.time_based)
                f->last_pos = f->last_pos - f->io_size;
 
        if (f->last_pos < f->real_file_size) {
@@ -377,7 +377,7 @@ static inline int io_u_fits(struct thread_data *td, struct io_u *io_u,
 {
        struct fio_file *f = io_u->file;
 
-       return io_u->offset + buflen <= f->io_size + td->o.start_offset;
+       return io_u->offset + buflen <= f->io_size + get_start_offset(td);
 }
 
 static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u)