posixaio engine: better handling of partial completions
authorJens Axboe <jens.axboe@oracle.com>
Wed, 14 Mar 2007 13:14:48 +0000 (14:14 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 14 Mar 2007 13:14:48 +0000 (14:14 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
engines/posixaio.c

index 7d9aaaf18314bffe3ea30fe211918d69e89b8095..88dc0e90a654f2d49f372194a3caf6fe575684de 100644 (file)
@@ -98,18 +98,20 @@ restart:
                        continue;
 
                err = aio_error(&io_u->aiocb);
                        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;
 
                if (r >= max)
                        break;