[PATCH] fio: avoid lseek() if cur_off == offset
authorJens Axboe <axboe@suse.de>
Tue, 25 Oct 2005 09:23:09 +0000 (11:23 +0200)
committerJens Axboe <axboe@suse.de>
Tue, 25 Oct 2005 09:23:09 +0000 (11:23 +0200)
fio.c

diff --git a/fio.c b/fio.c
index 6c549176a9cd7ea8452701be461fb18fe767948f..c7b92c551bcc77c86f178a9a5b386ad321561bc1 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -197,6 +197,8 @@ struct thread_data {
        unsigned long long file_offset;
        cpu_set_t cpumask;
 
+       off_t cur_off;
+
        io_context_t aio_ctx;
        unsigned int aio_depth;
        struct io_event *aio_events;
@@ -477,6 +479,8 @@ static void do_sync_io(struct thread_data *td)
        unsigned long blocks, msec, usec;
        struct timeval e;
 
+       td->cur_off = 0;
+
        for (blocks = 0; blocks < td->blocks; blocks++) {
                struct io_u *io_u;
                int ret;
@@ -486,9 +490,11 @@ static void do_sync_io(struct thread_data *td)
 
                io_u = get_io_u(td);
 
-               if (lseek(td->fd, io_u->offset, SEEK_SET) == -1) {
-                       td->error = errno;
-                       break;
+               if (td->cur_off != io_u->offset) {
+                       if (lseek(td->fd, io_u->offset, SEEK_SET) == -1) {
+                               td->error = errno;
+                               break;
+                       }
                }
 
                if (td->delay_sleep)
@@ -506,6 +512,7 @@ static void do_sync_io(struct thread_data *td)
                }
 
                td->io_blocks++;
+               td->cur_off = io_u->offset + io_u->buflen;
 
                if (should_fsync(td) && td->fsync_blocks &&
                    (td->io_blocks % td->fsync_blocks) == 0)