From 3f344316b3200143f413c9a4a8fd6476ca5899cf Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 14 Mar 2007 14:14:48 +0100 Subject: [PATCH 1/1] posixaio engine: better handling of partial completions Signed-off-by: Jens Axboe --- engines/posixaio.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/engines/posixaio.c b/engines/posixaio.c index 7d9aaaf1..88dc0e90 100644 --- a/engines/posixaio.c +++ b/engines/posixaio.c @@ -98,18 +98,20 @@ restart: continue; err = aio_error(&io_u->aiocb); - switch (err) { - default: - io_u->error = err; - case ECANCELED: - io_u->resid = io_u->xfer_buflen; - 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; -- 2.25.1