]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/aio: handle short return from io_submit 17601/head
authorSage Weil <sage@redhat.com>
Thu, 7 Sep 2017 20:28:59 +0000 (16:28 -0400)
committerSage Weil <sage@redhat.com>
Fri, 8 Sep 2017 12:17:33 +0000 (08:17 -0400)
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 <sage@redhat.com>
(cherry picked from commit dc17dfd9ff05b5676488c2b1bca53026b2ca6244)

src/os/bluestore/aio.cc

index cfe0c5cf8c899f0fd71a7a46f6ef2c2a77711098..4996e73452b119a8c9c50085d5c858e71534ece5 100644 (file)
@@ -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)