posixaio: fix thread problem with using errno
authorJens Axboe <axboe@kernel.dk>
Wed, 6 Nov 2013 21:47:22 +0000 (14:47 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 6 Nov 2013 21:47:22 +0000 (14:47 -0700)
If we fail queueing a read or a write, use aio_error() to
retrieve the right error value. This fixes an issue on
(at least) Solaris where we get EAGAIN due to system
shortage of resources, but treat that as a random type
of error due to using errno.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/posixaio.c

index a2b53873124b49cdcc6e14b9d7e508b948265091..2df26af3848eb6b4c14aea90ef16d0e946e8c43e 100644 (file)
@@ -196,18 +196,20 @@ static int fio_posixaio_queue(struct thread_data *td,
                return FIO_Q_COMPLETED;
 #endif
        }
-               
+
        if (ret) {
+               int aio_err = aio_error(aiocb);
+
                /*
                 * At least OSX has a very low limit on the number of pending
                 * IOs, so if it returns EAGAIN, we are out of resources
                 * to queue more. Just return FIO_Q_BUSY to naturally
                 * drop off at this depth.
                 */
-               if (errno == EAGAIN)
+               if (aio_err == EAGAIN)
                        return FIO_Q_BUSY;
 
-               io_u->error = errno;
+               io_u->error = aio_err;
                td_verror(td, io_u->error, "xfer");
                return FIO_Q_COMPLETED;
        }