[PATCH 1/2] qemu-kvm/rbd: use new librados callback for ack/complete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch uses the new librados aio callback function (from the unstable
branch of ceph).

Christian
---
 block/rbd.c |   51 ++++++++++++++++++++++++---------------------------
 1 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index 12a85dc..dfd2eca 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -393,34 +393,31 @@ static void rbd_finish_aiocb(rados_completion_t c, RADOSCB * rcb)
     int64_t r;
     int i;
 
-    if (rados_aio_is_complete(c)) {
-        acb->aiocnt--;
-        r = rados_aio_get_return_value(c);
-        rados_aio_set_callback(c, NULL, NULL);
-        rados_aio_release(c);
-        if (acb->write) {
-            acb->ret += r;
+    acb->aiocnt--;
+    r = rados_aio_get_return_value(c);
+    rados_aio_release(c);
+    if (acb->write) {
+        acb->ret += r;
+    } else {
+        if (r < 0) {
+            memset(rcb->buf, 0, rcb->segsize);
+            acb->ret += rcb->segsize;
+        } else if (r < rcb->segsize) {
+            memset(rcb->buf + r, 0, rcb->segsize - r);
+            acb->ret += rcb->segsize;
         } else {
-            if (r < 0) {
-                memset(rcb->buf, 0, rcb->segsize);
-                acb->ret += rcb->segsize;
-            } else if (r < rcb->segsize) {
-                memset(rcb->buf + r, 0, rcb->segsize - r);
-                acb->ret += rcb->segsize;
-            } else {
-                acb->ret += r;
-            }
-        }
-        qemu_free(rcb);
-        i = 0;
-        while ((acb->aiocnt == 0) && !acb->rccomplete && i < 5) {
-            usleep(100);
-            i++;
-        }
-        if ((acb->aiocnt == 0) && acb->rccomplete && acb->bh) {
-            qemu_bh_schedule(acb->bh);
+            acb->ret += r;
         }
     }
+    qemu_free(rcb);
+    i = 0;
+    while ((acb->aiocnt == 0) && !acb->rccomplete && i < 5) {
+        usleep(100);
+        i++;
+    }
+    if ((acb->aiocnt == 0) && acb->rccomplete && acb->bh) {
+        qemu_bh_schedule(acb->bh);
+    }
 }
 
 static void rbd_aio_bh_cb(void *opaque)
@@ -494,8 +491,8 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState * bs,
 
         acb->aiocnt++;
 
-        rados_aio_create_completion((rados_callback_t) rbd_finish_aiocb,
-                                    rcb, &c);
+        rados_aio_create_completion(rcb, (rados_callback_t) rbd_finish_aiocb,
+                                    NULL, &c);
         if (write) {
             rados_aio_write(s->pool, n, segoffs, buf, segsize, c);
         } else {
-- 
1.6.6.1


-- 
Christian Brunner                              MUC.DE e.V.
                                               Joseph-Dollinger-Bogen 14
                                               D-80807 Muenchen
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux