[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 45/54] quorum: Add quorum_aio_readv.
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 45/54] quorum: Add quorum_aio_readv. |
Date: |
Fri, 21 Feb 2014 23:12:42 +0100 |
From: BenoƮt Canet <address@hidden>
Add code to do num_children reads in parallel and cleanup the structures
afterwards.
Signed-off-by: Benoit Canet <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/quorum.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/block/quorum.c b/block/quorum.c
index 99e0e03..fd19662 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -91,10 +91,18 @@ static AIOCBInfo quorum_aiocb_info = {
static void quorum_aio_finalize(QuorumAIOCB *acb)
{
- int ret = 0;
+ BDRVQuorumState *s = acb->common.bs->opaque;
+ int i, ret = 0;
acb->common.cb(acb->common.opaque, ret);
+ if (acb->is_read) {
+ for (i = 0; i < s->num_children; i++) {
+ qemu_vfree(acb->qcrs[i].buf);
+ qemu_iovec_destroy(&acb->qcrs[i].qiov);
+ }
+ }
+
g_free(acb->qcrs);
qemu_aio_release(acb);
}
@@ -149,6 +157,34 @@ static void quorum_aio_cb(void *opaque, int ret)
quorum_aio_finalize(acb);
}
+static BlockDriverAIOCB *quorum_aio_readv(BlockDriverState *bs,
+ int64_t sector_num,
+ QEMUIOVector *qiov,
+ int nb_sectors,
+ BlockDriverCompletionFunc *cb,
+ void *opaque)
+{
+ BDRVQuorumState *s = bs->opaque;
+ QuorumAIOCB *acb = quorum_aio_get(s, bs, qiov, sector_num,
+ nb_sectors, cb, opaque);
+ int i;
+
+ acb->is_read = true;
+
+ for (i = 0; i < s->num_children; i++) {
+ acb->qcrs[i].buf = qemu_blockalign(s->bs[i], qiov->size);
+ qemu_iovec_init(&acb->qcrs[i].qiov, qiov->niov);
+ qemu_iovec_clone(&acb->qcrs[i].qiov, qiov, acb->qcrs[i].buf);
+ }
+
+ for (i = 0; i < s->num_children; i++) {
+ bdrv_aio_readv(s->bs[i], sector_num, qiov, nb_sectors,
+ quorum_aio_cb, &acb->qcrs[i]);
+ }
+
+ return &acb->common;
+}
+
static BlockDriverAIOCB *quorum_aio_writev(BlockDriverState *bs,
int64_t sector_num,
QEMUIOVector *qiov,
@@ -176,6 +212,7 @@ static BlockDriver bdrv_quorum = {
.instance_size = sizeof(BDRVQuorumState),
+ .bdrv_aio_readv = quorum_aio_readv,
.bdrv_aio_writev = quorum_aio_writev,
};
--
1.8.1.4
- [Qemu-devel] [PULL 35/54] qemu-img: Allow -o help with incomplete argument list, (continued)
- [Qemu-devel] [PULL 35/54] qemu-img: Allow -o help with incomplete argument list, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 36/54] qemu-iotests: Check qemu-img command line parsing, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 37/54] qemu-config: Sections must consist of keys, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 38/54] qdict: Extract non-QDicts in qdict_array_split(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 41/54] quorum: Create quorum.c, add QuorumChildRequest and QuorumAIOCB., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 42/54] quorum: Create BDRVQuorumState and BlkDriver and do init., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 43/54] quorum: Add quorum_aio_writev and its dependencies., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 40/54] check-qdict: Test termination of qdict_array_split(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 39/54] check-qdict: Adjust test for qdict_array_split(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 44/54] blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 45/54] quorum: Add quorum_aio_readv.,
Kevin Wolf <=
- [Qemu-devel] [PULL 46/54] quorum: Add quorum mechanism., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 48/54] quorum: Add quorum_invalidate_cache()., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 47/54] quorum: Add quorum_getlength()., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 49/54] quorum: Add quorum_co_flush()., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 50/54] quorum: Implement recursive .bdrv_recurse_is_first_non_filter in quorum., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 51/54] quorum: Add quorum_open() and quorum_close()., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 52/54] quorum: Add unit test., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 53/54] quorum: Simplify quorum_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 54/54] iotests: Mixed quorum child device specifications, Kevin Wolf, 2014/02/21
- Re: [Qemu-devel] [PULL 00/54] Block patches, Peter Maydell, 2014/02/25