From: Sage Weil Date: Thu, 7 Sep 2017 20:28:59 +0000 (-0400) Subject: os/bluestore/aio: handle short return from io_submit X-Git-Tag: v12.2.1~73^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F17601%2Fhead;p=ceph.git 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 (cherry picked from commit dc17dfd9ff05b5676488c2b1bca53026b2ca6244) --- 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)