[PATCH] fio: make the aio path handle resubmits
authorJens Axboe <axboe@suse.de>
Mon, 7 Nov 2005 15:48:11 +0000 (16:48 +0100)
committerJens Axboe <axboe@suse.de>
Mon, 7 Nov 2005 15:48:11 +0000 (16:48 +0100)
fio.c

diff --git a/fio.c b/fio.c
index 8085c746c78be0af5e791056e7f9962a318d5123..27e0e36629ca4b418702accf73f28b1a83cc0ff7 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1007,6 +1007,20 @@ static void do_sync_io(struct thread_data *td)
                fsync(td->fd);
 }
 
+static int io_u_getevents(struct thread_data *td, int min, int max,
+                         struct timespec *t)
+{
+       int r;
+
+       do {
+               r = io_getevents(td->aio_ctx, min, max, td->aio_events, t);
+               if (r != -EAGAIN && r != -EINTR)
+                       break;
+       } while (1);
+
+       return r;
+}
+
 static int io_u_queue(struct thread_data *td, struct io_u *io_u)
 {
        struct iocb *iocb = &io_u->iocb;
@@ -1071,7 +1085,7 @@ static void cleanup_pending_aio(struct thread_data *td)
        /*
         * get immediately available events, if any
         */
-       r = io_getevents(td->aio_ctx, 0, td->cur_depth, td->aio_events, &ts);
+       r = io_u_getevents(td, 0, td->cur_depth, &ts);
        if (r > 0)
                ios_completed(td, r);
 
@@ -1087,7 +1101,7 @@ static void cleanup_pending_aio(struct thread_data *td)
        }
 
        if (td->cur_depth) {
-               r = io_getevents(td->aio_ctx, td->cur_depth, td->cur_depth, td->aio_events, NULL);
+               r = io_u_getevents(td, td->cur_depth, td->cur_depth, NULL);
                if (r > 0)
                        ios_completed(td, r);
        }
@@ -1147,7 +1161,7 @@ static void do_async_verify(struct thread_data *td)
                if (async_do_verify(td, &v_io_u))
                        break;
 
-               ret = io_getevents(td->aio_ctx, 1, 1, td->aio_events, NULL);
+               ret = io_u_getevents(td, 1, 1, NULL);
                if (ret != 1) {
                        if (ret < 0)
                                td->error = ret;
@@ -1212,7 +1226,7 @@ static void do_async_io(struct thread_data *td)
                        min_evts = 1;
                }
 
-               ret = io_getevents(td->aio_ctx, min_evts, td->cur_depth, td->aio_events, timeout);
+               ret = io_u_getevents(td, min_evts, td->cur_depth, timeout);
                if (ret < 0) {
                        td->error = errno;
                        break;