Add support for backwards holes
authorJens Axboe <jaxboe@fusionio.com>
Wed, 31 Aug 2011 19:14:12 +0000 (13:14 -0600)
committerJens Axboe <jaxboe@fusionio.com>
Wed, 31 Aug 2011 19:14:12 +0000 (13:14 -0600)
If you did:

bs=4k
rw=read:-8k

you would essentially rewind by 8k after reading 4k, causing
the read to be sequentially backwards.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
fio.h
io_u.c

diff --git a/fio.h b/fio.h
index 0c86f28..8401eda 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -254,7 +254,7 @@ struct thread_options {
        unsigned int rw_seq;
        unsigned int kb_base;
        unsigned int ddir_seq_nr;
-       unsigned long ddir_seq_add;
+       long ddir_seq_add;
        unsigned int iodepth;
        unsigned int iodepth_low;
        unsigned int iodepth_batch;
diff --git a/io_u.c b/io_u.c
index 7709df5..16c98b1 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -249,8 +249,12 @@ static int get_next_seq_block(struct thread_data *td, struct fio_file *f,
        assert(ddir_rw(ddir));
 
        if (f->last_pos < f->real_file_size) {
-               unsigned long long pos = f->last_pos - f->file_offset;
+               unsigned long long pos;
 
+               if (f->last_pos == f->file_offset && td->o.ddir_seq_add < 0)
+                       f->last_pos = f->real_file_size;
+
+               pos = f->last_pos - f->file_offset;
                if (pos)
                        pos += td->o.ddir_seq_add;