]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/os/fs/aio.cc
bump version to 12.1.1-pve1 while rebasing patches
[ceph.git] / ceph / src / os / fs / aio.cc
index a5edf62666558596a7d9268d84b24c37277bdc18..cfe0c5cf8c899f0fd71a7a46f6ef2c2a77711098 100644 (file)
@@ -5,14 +5,16 @@
 
 #if defined(HAVE_LIBAIO)
 
+
 int aio_queue_t::submit(aio_t &aio, int *retries)
 {
   // 2^16 * 125us = ~8 seconds, so max sleep is ~16 seconds
   int attempts = 16;
   int delay = 125;
   iocb *piocb = &aio.iocb;
+  int r;
   while (true) {
-    int r = io_submit(ctx, 1, &piocb);
+    r = io_submit(ctx, 1, &piocb);
     if (r < 0) {
       if (r == -EAGAIN && attempts-- > 0) {
        usleep(delay);
@@ -20,12 +22,43 @@ int aio_queue_t::submit(aio_t &aio, int *retries)
        (*retries)++;
        continue;
       }
-      return r;
     }
     assert(r == 1);
     break;
   }
-  return 0;
+  return r;
+}
+
+int aio_queue_t::submit_batch(aio_iter begin, aio_iter end, 
+                             uint16_t aios_size, void *priv, 
+                             int *retries)
+{
+  // 2^16 * 125us = ~8 seconds, so max sleep is ~16 seconds
+  int attempts = 16;
+  int delay = 125;
+
+  aio_iter cur = begin;
+  struct iocb *piocb[aios_size];
+  int r, pos = 0;
+  while (cur != end) {
+    cur->priv = priv;
+    *(piocb+pos) = &cur->iocb;
+    ++pos;
+    ++cur;
+  }
+  while (true) {
+    r = io_submit(ctx, pos, piocb);
+    if (r < 0) {
+      if (r == -EAGAIN && attempts-- > 0) {
+       usleep(delay);
+       delay *= 2;
+       (*retries)++;
+       continue;
+      }
+    }
+    break;
+  }
+  return r;
 }
 
 int aio_queue_t::get_next_completed(int timeout_ms, aio_t **paio, int max)