Patchwork [RFC,10/12] qorum: Add qorum_aio_readv.

login
register
mail settings
Submitter Benoit Canet
Date Aug. 2, 2012, 10:16 a.m.
Message ID <1343902604-13981-11-git-send-email-benoit@irqsave.net>
Download mbox | patch
Permalink /patch/174717/
State New
Headers show

Comments

Benoit Canet - Aug. 2, 2012, 10:16 a.m.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 block/qorum.c |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Patch

diff --git a/block/qorum.c b/block/qorum.c
index eeffac2..772d138 100644
--- a/block/qorum.c
+++ b/block/qorum.c
@@ -175,6 +175,14 @@  static int qorum_check_ret(QorumAIOCB *acb)
 static void qorum_aio_bh(void *opaque)
 {
     QorumAIOCB *acb = opaque;
+    int i;
+
+    for (i = 0; i <= 2; i++) {
+        if (acb->aios[i].buf) {
+            g_free(acb->aios[i].buf);
+            acb->aios[i].buf = NULL;
+        }
+    }
 
     qemu_bh_delete(acb->bh);
     acb->common.cb(acb->common.opaque, qorum_check_ret(acb));
@@ -227,6 +235,32 @@  static void qorum_aio_cb(void *opaque, int ret)
     }
 }
 
+static BlockDriverAIOCB *qorum_aio_readv(BlockDriverState *bs,
+                                         int64_t sector_num,
+                                         QEMUIOVector *qiov,
+                                         int nb_sectors,
+                                         BlockDriverCompletionFunc *cb,
+                                         void *opaque)
+{
+    BDRVQorumState *s = bs->opaque;
+    QorumAIOCB *acb = qorum_aio_get(bs, qiov, true, sector_num,
+                                    nb_sectors, cb, opaque);
+    int i;
+
+    for (i = 0; i <= 2; i++) {
+        acb->aios[i].buf = qemu_blockalign(bs->file, qiov->size);
+        qemu_iovec_init(&acb->qiovs[i], qiov->niov);
+        blkverify_iovec_clone(&acb->qiovs[i], qiov, acb->aios[i].buf);
+    }
+
+    for (i = 0; i <= 2; i++) {
+        bdrv_aio_readv(s->bs[i], sector_num, qiov, nb_sectors,
+                       qorum_aio_cb, &acb->aios[i]);
+    }
+
+    return &acb->common;
+}
+
 static BlockDriverAIOCB *qorum_aio_writev(BlockDriverState *bs,
                                           int64_t sector_num,
                                           QEMUIOVector *qiov,
@@ -275,6 +309,7 @@  static BlockDriver bdrv_qorum = {
     .bdrv_close         = qorum_close,
     .bdrv_co_flush_to_disk = qorum_co_flush,
 
+    .bdrv_aio_readv     = qorum_aio_readv,
     .bdrv_aio_writev    = qorum_aio_writev,
 };