Change IO engine queuing
[fio.git] / engines / libaio.c
index 9a644f6fe4d07d17be9997a7cc94c882c275cd3e..ba8c49df6583ddf7051e215f9da46c968d3b34aa 100644 (file)
@@ -77,22 +77,36 @@ static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
        do {
                ret = io_submit(ld->aio_ctx, 1, &iocb);
                if (ret == 1)
-                       return 0;
+                       return FIO_Q_QUEUED;
                else if (ret == -EAGAIN || !ret)
                        usleep(100);
                else if (ret == -EINTR)
                        continue;
-               else
+               else if (ret == -EINVAL && io_u->ddir == DDIR_SYNC) {
+                       /*
+                        * the async fsync doesn't currently seem to be
+                        * supported, so just fsync if we fail with EINVAL
+                        * for a sync. since buffered io is also sync
+                        * with libaio (still), we don't have pending
+                        * requests to flush first.
+                        */
+                       if (fsync(io_u->file->fd) < 0)
+                               ret = errno;
+                       else
+                               ret = FIO_Q_COMPLETED;
+                       break;
+               } else
                        break;
        } while (1);
 
        if (ret <= 0) {
                io_u->resid = io_u->xfer_buflen;
                io_u->error = -ret;
-               return 1;
+               td_verror(td, io_u->error);
+               return FIO_Q_COMPLETED;
        }
 
-       return 0;
+       return ret;
 }
 
 static int fio_libaio_cancel(struct thread_data *td, struct io_u *io_u)