]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/newstore: process multiple aio completions at a time
authorSage Weil <sage@redhat.com>
Sat, 2 May 2015 00:21:23 +0000 (17:21 -0700)
committerSage Weil <sage@redhat.com>
Tue, 1 Sep 2015 17:39:42 +0000 (13:39 -0400)
This isn't affecting things for a slow disk, but it will matter for faster
backends.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/fs/FS.h
src/os/newstore/NewStore.cc

index 4b52732422677a7ca1fcf537f451d7db167d08be..3ab5d67f39aafabc179e0bfe3c440cc707bd43ee 100644 (file)
@@ -109,8 +109,8 @@ public:
       return 0;
     }
 
-    int get_next_completed(int timeout_ms, aio_t **paio) {
-      io_event event[1];
+    int get_next_completed(int timeout_ms, aio_t **paio, int max) {
+      io_event event[max];
       struct timespec t = {
        timeout_ms / 1000,
        (timeout_ms % 1000) * 1000 * 1000
@@ -119,8 +119,10 @@ public:
       if (r <= 0) {
        return r;
       }
-      *paio = (aio_t *)event[0].obj;
-      return 1;
+      for (int i=0; i<r; ++i) {
+       paio[i] = (aio_t *)event[i].obj;
+      }
+      return r;
     }
   };
 
index 566e778a8614beb19573a2d7420313c28eb26286..044f1ebe391765d4b24565df947fb689675e08c1 100644 (file)
@@ -2337,20 +2337,25 @@ void NewStore::_aio_thread()
   dout(10) << __func__ << " start" << dendl;
   while (!aio_stop) {
     dout(40) << __func__ << " polling" << dendl;
-    FS::aio_t *aio;
-    int r = aio_queue.get_next_completed(g_conf->newstore_aio_poll_ms, &aio);
+    int max = 16;
+    FS::aio_t *aio[max];
+    int r = aio_queue.get_next_completed(g_conf->newstore_aio_poll_ms,
+                                        aio, max);
     if (r < 0) {
       derr << __func__ << " got " << cpp_strerror(r) << dendl;
     }
-    if (r == 1) {
-      TransContext *txc = static_cast<TransContext*>(aio->priv);
-      int left = txc->num_aio.dec();
-      dout(10) << __func__ << " finished aio " << aio << " txc " << txc
-              << " state " << txc->get_state_name() << ", "
-              << left << " aios left" << dendl;
-      VOID_TEMP_FAILURE_RETRY(::close(aio->fd));
-      if (left == 0) {
-       _txc_state_proc(txc);
+    if (r > 0) {
+      dout(30) << __func__ << " got " << r << " completed aios" << dendl;
+      for (int i = 0; i < r; ++i) {
+       TransContext *txc = static_cast<TransContext*>(aio[i]->priv);
+       int left = txc->num_aio.dec();
+       dout(10) << __func__ << " finished aio " << aio[i] << " txc " << txc
+                << " state " << txc->get_state_name() << ", "
+                << left << " aios left" << dendl;
+       VOID_TEMP_FAILURE_RETRY(::close(aio[i]->fd));
+       if (left == 0) {
+         _txc_state_proc(txc);
+       }
       }
     }
   }