struct libaio_data {
io_context_t aio_ctx;
struct io_event *aio_events;
+ struct io_u *sync_io_u;
};
static int fio_libaio_prep(struct thread_data fio_unused *td, struct io_u *io_u)
{
struct libaio_data *ld = td->io_ops->data;
+ if (ld->sync_io_u) {
+ struct io_u *ret = ld->sync_io_u;
+
+ ld->sync_io_u = NULL;
+ return ret;
+ }
+
return ev_to_iou(ld->aio_events + event);
}
struct libaio_data *ld = td->io_ops->data;
long r;
+ if (ld->sync_io_u)
+ return 1;
+
do {
r = io_getevents(ld->aio_ctx, min, max, ld->aio_events, t);
if (r >= min)
do {
ret = io_submit(ld->aio_ctx, 1, &iocb);
if (ret == 1)
- return 0;
+ break;
else if (ret == -EAGAIN || !ret)
usleep(100);
else if (ret == -EINTR)
* with libaio (still), we don't have pending
* requests to flush first.
*/
- ret = fsync(io_u->file->fd);
+ if (fsync(io_u->file->fd) < 0)
+ ret = errno;
+ else {
+ ret = 1;
+ ld->sync_io_u = io_u;
+ }
break;
} else
break;
if (ret <= 0) {
io_u->resid = io_u->xfer_buflen;
io_u->error = -ret;
+ td_verror(td, io_u->error);
return 1;
}