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 0c86f2882053e6bb37e74ff181e83eea426d9041..8401eda7132e02660e2d9812cc79e3fc934cfe92 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 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;
        unsigned int iodepth;
        unsigned int iodepth_low;
        unsigned int iodepth_batch;
diff --git a/io_u.c b/io_u.c
index 7709df5fe55bf7fb6237d6b93476b2f09a2d3d3d..16c98b1f454869c43e4862b91c57b1278898de28 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) {
        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;
 
                if (pos)
                        pos += td->o.ddir_seq_add;