vsync: Fix issue with double issue of io_u
[fio.git] / engines / sync.c
index c5410c7d4a97f6cbef713de04e15608b0e90f7e8..3b96ee1d4ba682949d3067a795b81f7728db0853 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/uio.h>
 #include <errno.h>
 #include <assert.h>
 
@@ -17,6 +18,7 @@ struct syncio_data {
        struct iovec *iovecs;
        struct io_u **io_us;
        unsigned int queued;
+       unsigned int events;
        unsigned long queued_bytes;
 
        unsigned long long last_offset;
@@ -30,8 +32,6 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
 
        if (io_u->ddir == DDIR_SYNC)
                return 0;
-       if (io_u->offset == f->last_completed_pos)
-               return 0;
 
        if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
                td_verror(td, errno, "lseek");
@@ -100,8 +100,8 @@ static int fio_vsyncio_getevents(struct thread_data *td, unsigned int min,
        int ret;
 
        if (min) {
-               ret = sd->queued;
-               sd->queued = 0;
+               ret = sd->events;
+               sd->events = 0;
        } else
                ret = 0;
 
@@ -232,6 +232,7 @@ static int fio_vsyncio_commit(struct thread_data *td)
        if (!sd->queued)
                return 0;
 
+       io_u_mark_submit(td, sd->queued);
        f = sd->last_file;
 
        if (lseek(f->fd, sd->io_us[0]->offset, SEEK_SET) == -1) {
@@ -247,6 +248,8 @@ static int fio_vsyncio_commit(struct thread_data *td)
                ret = writev(f->fd, sd->iovecs, sd->queued);
 
        dprint(FD_IO, "vsyncio_commit: %d\n", (int) ret);
+       sd->events = sd->queued;
+       sd->queued = 0;
        return fio_vsyncio_end(td, ret);
 }