From dc17dfd9ff05b5676488c2b1bca53026b2ca6244 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 7 Sep 2017 16:28:59 -0400 Subject: [PATCH] os/bluestore/aio: handle short return from io_submit io_submit may return a value less than nr, indicating that only some of the provided iocbs were queued. If that happens we should loop, not return and silently drop those aios on the floor. Signed-off-by: Sage Weil --- src/os/bluestore/aio.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/aio.cc b/src/os/bluestore/aio.cc index cfe0c5cf8c89..4996e73452b1 100644 --- a/src/os/bluestore/aio.cc +++ b/src/os/bluestore/aio.cc @@ -39,15 +39,16 @@ int aio_queue_t::submit_batch(aio_iter begin, aio_iter end, aio_iter cur = begin; struct iocb *piocb[aios_size]; - int r, pos = 0; + int left = 0; while (cur != end) { cur->priv = priv; - *(piocb+pos) = &cur->iocb; - ++pos; + *(piocb+left) = &cur->iocb; + ++left; ++cur; } - while (true) { - r = io_submit(ctx, pos, piocb); + int done = 0; + while (left > 0) { + int r = io_submit(ctx, left, piocb + done); if (r < 0) { if (r == -EAGAIN && attempts-- > 0) { usleep(delay); @@ -55,10 +56,13 @@ int aio_queue_t::submit_batch(aio_iter begin, aio_iter end, (*retries)++; continue; } + return r; } - break; + assert(r > 0); + done += r; + left -= r; } - return r; + return done; } int aio_queue_t::get_next_completed(int timeout_ms, aio_t **paio, int max) -- 2.47.3