io_u: if we're doing backwards IO, wrap to end (not start)
authorJens Axboe <axboe@fb.com>
Mon, 9 May 2016 19:31:01 +0000 (13:31 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 9 May 2016 19:31:01 +0000 (13:31 -0600)
If we have a job with a start file offset and we're doing holed
IO, we want to wrap to the start offset for forwards holes, but
to the end for backwards holes.

Signed-off-by: Jens Axboe <axboe@fb.com>
io_u.c

diff --git a/io_u.c b/io_u.c
index eb15dc2873f77fc3144466b2225c2890a7043614..f9870e70bc8d408ab7bf72adcf46cddf6818b4da 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -371,10 +371,15 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f,
                        /*
                         * If we reach beyond the end of the file
                         * with holed IO, wrap around to the
                        /*
                         * If we reach beyond the end of the file
                         * with holed IO, wrap around to the
-                        * beginning again.
+                        * beginning again. If we're doing backwards IO,
+                        * wrap to the end.
                         */
                         */
-                       if (pos >= f->real_file_size)
-                               pos = f->file_offset;
+                       if (pos >= f->real_file_size) {
+                               if (o->ddir_seq_add > 0)
+                                       pos = f->file_offset;
+                               else
+                                       pos = f->real_file_size + o->ddir_seq_add;
+                       }
                }
 
                *offset = pos;
                }
 
                *offset = pos;