Fix problem with f->last_completed_pos not being correct on requeues
authorJens Axboe <jens.axboe@oracle.com>
Mon, 16 Apr 2007 19:39:33 +0000 (21:39 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 16 Apr 2007 19:39:33 +0000 (21:39 +0200)
This causes an unnecessary seek. Usually this is just noise, but if
the device isn't seekable, it becomes a real problem.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c
fio.h
io_u.c

diff --git a/fio.c b/fio.c
index 160d533583b6850c30bacbd98e1ef345db5c7680..296ac343fb437bd14bca2ca1691ae8b66c8670b4 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -332,6 +332,7 @@ static void do_verify(struct thread_data *td)
                                ret = -io_u->error;
                        else if (io_u->resid) {
                                int bytes = io_u->xfer_buflen - io_u->resid;
+                               struct fio_file *f = io_u->file;
 
                                /*
                                 * zero read, fail
@@ -345,8 +346,9 @@ static void do_verify(struct thread_data *td)
                                io_u->xfer_buflen = io_u->resid;
                                io_u->xfer_buf += bytes;
                                io_u->offset += bytes;
+                               f->last_completed_pos = io_u->offset;
 
-                               if (io_u->offset == io_u->file->real_file_size)
+                               if (io_u->offset == f->real_file_size)
                                        goto sync_done;
 
                                requeue_io_u(td, &io_u);
@@ -446,6 +448,7 @@ static void do_io(struct thread_data *td)
                                ret = -io_u->error;
                        else if (io_u->resid) {
                                int bytes = io_u->xfer_buflen - io_u->resid;
+                               struct fio_file *f = io_u->file;
 
                                /*
                                 * zero read, fail
@@ -459,8 +462,9 @@ static void do_io(struct thread_data *td)
                                io_u->xfer_buflen = io_u->resid;
                                io_u->xfer_buf += bytes;
                                io_u->offset += bytes;
+                               f->last_completed_pos = io_u->offset;
 
-                               if (io_u->offset == io_u->file->real_file_size)
+                               if (io_u->offset == f->real_file_size)
                                        goto sync_done;
 
                                requeue_io_u(td, &io_u);
diff --git a/fio.h b/fio.h
index 7ac5734308bff9d72bfa2b2a8c6b93844fdb994c..9c398a20e3b7d191af6c1546a4519cb02c232644 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -135,6 +135,7 @@ struct io_u {
        void *buf;
        unsigned long buflen;
        unsigned long long offset;
+       unsigned long long endpos;
 
        /*
         * IO engine state, may be different from above when we get
diff --git a/io_u.c b/io_u.c
index 1ae63789c7edc8703f3edad2d32c770533385e4d..0487857e74851b3752d38747b5307fcbebbf4416 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -588,6 +588,7 @@ set_file:
        /*
         * Set io data pointers.
         */
+       io_u->endpos = io_u->offset + io_u->buflen;
 out:
        io_u->xfer_buf = io_u->buf;
        io_u->xfer_buflen = io_u->buflen;
@@ -645,7 +646,7 @@ static void io_completed(struct thread_data *td, struct io_u *io_u,
                td->zone_bytes += bytes;
                td->this_io_bytes[idx] += bytes;
 
-               io_u->file->last_completed_pos = io_u->offset + io_u->buflen;
+               io_u->file->last_completed_pos = io_u->endpos;
 
                msec = mtime_since(&io_u->issue_time, &icd->time);