X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fposixaio.c;h=88ed40266390a0b0e2d88420f3aef595a6fa7a10;hb=4b472fa373d45fef6b33ebfc8ede745c55b20e89;hp=71601fdd31c8df937cc08498c04d308875135d5e;hpb=cec6b55da1c282b5b91ad346c7804171fccf151e;p=fio.git diff --git a/engines/posixaio.c b/engines/posixaio.c index 71601fdd..88ed4026 100644 --- a/engines/posixaio.c +++ b/engines/posixaio.c @@ -1,5 +1,7 @@ /* - * posix aio io engine + * posixaio engine + * + * IO engine that uses the posix defined aio interface. * */ #include @@ -9,7 +11,6 @@ #include #include "../fio.h" -#include "../os.h" #ifdef FIO_HAVE_POSIXAIO @@ -96,17 +97,20 @@ restart: continue; err = aio_error(&io_u->aiocb); - switch (err) { - default: - io_u->error = err; - case ECANCELED: - case 0: - pd->aio_events[r++] = io_u; - io_u->seen = 1; - break; - case EINPROGRESS: - break; - } + if (err == EINPROGRESS) + continue; + + io_u->seen = 1; + pd->aio_events[r++] = io_u; + + if (err == ECANCELED) + io_u->resid = io_u->xfer_buflen; + else if (!err) { + ssize_t retval = aio_return(&io_u->aiocb); + + io_u->resid = io_u->xfer_buflen - retval; + } else + io_u->error = err; if (r >= max) break; @@ -151,10 +155,13 @@ static int fio_posixaio_queue(struct thread_data fio_unused *td, else ret = aio_fsync(O_SYNC, aiocb); - if (ret) + if (ret) { io_u->error = errno; - - return io_u->error; + td_verror(td, io_u->error, "xfer"); + return FIO_Q_COMPLETED; + } + + return FIO_Q_QUEUED; } static void fio_posixaio_cleanup(struct thread_data *td) @@ -173,8 +180,8 @@ static int fio_posixaio_init(struct thread_data *td) struct posixaio_data *pd = malloc(sizeof(*pd)); memset(pd, 0, sizeof(*pd)); - pd->aio_events = malloc(td->iodepth * sizeof(struct io_u *)); - memset(pd->aio_events, 0, td->iodepth * sizeof(struct io_u *)); + pd->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *)); + memset(pd->aio_events, 0, td->o.iodepth * sizeof(struct io_u *)); td->io_ops->data = pd; return 0; @@ -190,6 +197,8 @@ static struct ioengine_ops ioengine = { .getevents = fio_posixaio_getevents, .event = fio_posixaio_event, .cleanup = fio_posixaio_cleanup, + .open_file = generic_open_file, + .close_file = generic_close_file, }; #else /* FIO_HAVE_POSIXAIO */