vsync: Fix issue with double issue of io_u
[fio.git] / engines / sync.c
index 46cb864d770b7819015f354c325c8410fbb878b5..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;
@@ -98,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;
 
@@ -230,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) {
@@ -245,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);
 }