Allow explicit setting of a number of files
[fio.git] / engines / libaio.c
index a659ba9bc141890b57ff0b29180eb446bf6dc17f..5295eadfacc113f4a3f13fd0085b205a6a6fe572 100644 (file)
@@ -42,8 +42,21 @@ static int fio_libaio_prep(struct thread_data fio_unused *td, struct io_u *io_u)
 static struct io_u *fio_libaio_event(struct thread_data *td, int event)
 {
        struct libaio_data *ld = td->io_ops->data;
+       struct io_event *ev;
+       struct io_u *io_u;
 
-       return ev_to_iou(ld->aio_events + event);
+       ev = ld->aio_events + event;
+       io_u = ev_to_iou(ev);
+
+       if (ev->res != io_u->xfer_buflen) {
+               if (ev->res > io_u->xfer_buflen)
+                       io_u->error = -ev->res;
+               else
+                       io_u->resid = io_u->xfer_buflen - ev->res;
+       } else
+               io_u->error = 0;
+
+       return io_u;
 }
 
 static int fio_libaio_getevents(struct thread_data *td, int min, int max,
@@ -178,7 +191,7 @@ static int fio_libaio_init(struct thread_data *td)
 
        memset(ld, 0, sizeof(*ld));
        if (io_queue_init(td->iodepth, &ld->aio_ctx)) {
-               td_verror(td, errno);
+               td_verror(td, errno, "io_queue_init");
                free(ld);
                return 1;
        }
@@ -206,6 +219,8 @@ static struct ioengine_ops ioengine = {
        .getevents      = fio_libaio_getevents,
        .event          = fio_libaio_event,
        .cleanup        = fio_libaio_cleanup,
+       .open_file      = generic_open_file,
+       .close_file     = generic_close_file,
 };
 
 #else /* FIO_HAVE_LIBAIO */