From ccc02050c1a371385897aa964988dbab68597545 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 14 Jul 2011 12:45:13 +0200 Subject: [PATCH] Fix infinite loop on platforms with severely limited aio resources Problem hit on OSX, where with 4 jobs each with a queue depth larger than what the system supports, you can get into a situation where any given process can get EAGAIN on queueing AIO even if it has nothing queued already. Check for this condition to avoid fio's IO loop going into a death spiral. Signed-off-by: Jens Axboe --- fio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fio.c b/fio.c index 9e9106d5..120431e9 100644 --- a/fio.c +++ b/fio.c @@ -550,9 +550,10 @@ sync_done: /* * if we can queue more, do so. but check if there are - * completed io_u's first. + * completed io_u's first. Note that we can get BUSY even + * without IO queued, if the system is resource starved. */ - full = queue_full(td) || ret == FIO_Q_BUSY; + full = queue_full(td) || (ret == FIO_Q_BUSY && td->cur_depth); if (full || !td->o.iodepth_batch_complete) { min_events = min(td->o.iodepth_batch_complete, td->cur_depth); @@ -710,9 +711,11 @@ sync_done: break; /* - * See if we need to complete some commands + * See if we need to complete some commands. Note that we + * can get BUSY even without IO queued, if the system is + * resource starved. */ - full = queue_full(td) || ret == FIO_Q_BUSY; + full = queue_full(td) || (ret == FIO_Q_BUSY && td->cur_depth); if (full || !td->o.iodepth_batch_complete) { min_evts = min(td->o.iodepth_batch_complete, td->cur_depth); -- 2.25.1