From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 12/23] quorum: do not allocate multiple iovecs for FIFO strategy
Date: Mon, 24 Oct 2016 19:02:00 +0200 [thread overview]
Message-ID: <1477328531-30879-13-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1477328531-30879-1-git-send-email-kwolf@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
In FIFO mode there are no parallel reads, hence there is no need to
allocate separate buffers and clone the iovecs.
The two cases of quorum_aio_cb are now even more different, and
most of quorum_aio_finalize is only needed in one of them, so split
them in separate functions.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1475685327-22767-3-git-send-email-pbonzini@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/quorum.c | 79 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 40 insertions(+), 39 deletions(-)
diff --git a/block/quorum.c b/block/quorum.c
index 435296e..d122299 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -156,21 +156,7 @@ static AIOCBInfo quorum_aiocb_info = {
static void quorum_aio_finalize(QuorumAIOCB *acb)
{
- int i, ret = 0;
-
- if (acb->vote_ret) {
- ret = acb->vote_ret;
- }
-
- acb->common.cb(acb->common.opaque, ret);
-
- if (acb->is_read) {
- for (i = 0; i < acb->children_read; i++) {
- qemu_vfree(acb->qcrs[i].buf);
- qemu_iovec_destroy(&acb->qcrs[i].qiov);
- }
- }
-
+ acb->common.cb(acb->common.opaque, acb->vote_ret);
g_free(acb->qcrs);
qemu_aio_unref(acb);
}
@@ -282,38 +268,52 @@ static void quorum_copy_qiov(QEMUIOVector *dest, QEMUIOVector *source)
}
}
-static void quorum_aio_cb(void *opaque, int ret)
+static void quorum_report_bad_acb(QuorumChildRequest *sacb, int ret)
+{
+ QuorumAIOCB *acb = sacb->parent;
+ QuorumOpType type = acb->is_read ? QUORUM_OP_TYPE_READ : QUORUM_OP_TYPE_WRITE;
+ quorum_report_bad(type, acb->sector_num, acb->nb_sectors,
+ sacb->aiocb->bs->node_name, ret);
+}
+
+static void quorum_fifo_aio_cb(void *opaque, int ret)
{
QuorumChildRequest *sacb = opaque;
QuorumAIOCB *acb = sacb->parent;
BDRVQuorumState *s = acb->common.bs->opaque;
- bool rewrite = false;
- if (ret == 0) {
- acb->success_count++;
- } else {
- QuorumOpType type;
- type = acb->is_read ? QUORUM_OP_TYPE_READ : QUORUM_OP_TYPE_WRITE;
- quorum_report_bad(type, acb->sector_num, acb->nb_sectors,
- sacb->aiocb->bs->node_name, ret);
- }
+ assert(acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO);
+
+ if (ret < 0) {
+ quorum_report_bad_acb(sacb, ret);
- if (acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO) {
/* We try to read next child in FIFO order if we fail to read */
- if (ret < 0 && acb->children_read < s->num_children) {
+ if (acb->children_read < s->num_children) {
read_fifo_child(acb);
return;
}
-
- if (ret == 0) {
- quorum_copy_qiov(acb->qiov, &acb->qcrs[acb->children_read - 1].qiov);
- }
- acb->vote_ret = ret;
- quorum_aio_finalize(acb);
- return;
}
+ acb->vote_ret = ret;
+
+ /* FIXME: rewrite failed children if acb->children_read > 1? */
+ quorum_aio_finalize(acb);
+}
+
+static void quorum_aio_cb(void *opaque, int ret)
+{
+ QuorumChildRequest *sacb = opaque;
+ QuorumAIOCB *acb = sacb->parent;
+ BDRVQuorumState *s = acb->common.bs->opaque;
+ bool rewrite = false;
+ int i;
+
sacb->ret = ret;
+ if (ret == 0) {
+ acb->success_count++;
+ } else {
+ quorum_report_bad_acb(sacb, ret);
+ }
acb->count++;
assert(acb->count <= s->num_children);
assert(acb->success_count <= s->num_children);
@@ -324,6 +324,10 @@ static void quorum_aio_cb(void *opaque, int ret)
/* Do the vote on read */
if (acb->is_read) {
rewrite = quorum_vote(acb);
+ for (i = 0; i < s->num_children; i++) {
+ qemu_vfree(acb->qcrs[i].buf);
+ qemu_iovec_destroy(&acb->qcrs[i].qiov);
+ }
} else {
quorum_has_too_much_io_failed(acb);
}
@@ -672,12 +676,9 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb)
BDRVQuorumState *s = acb->common.bs->opaque;
int n = acb->children_read++;
- acb->qcrs[n].buf = qemu_blockalign(s->children[n]->bs, acb->qiov->size);
- qemu_iovec_init(&acb->qcrs[n].qiov, acb->qiov->niov);
- qemu_iovec_clone(&acb->qcrs[n].qiov, acb->qiov, acb->qcrs[n].buf);
acb->qcrs[n].aiocb = bdrv_aio_readv(s->children[n], acb->sector_num,
- &acb->qcrs[n].qiov, acb->nb_sectors,
- quorum_aio_cb, &acb->qcrs[n]);
+ acb->qiov, acb->nb_sectors,
+ quorum_fifo_aio_cb, &acb->qcrs[n]);
return &acb->common;
}
--
1.8.3.1
next prev parent reply other threads:[~2016-10-24 17:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 17:01 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 01/23] block: failed qemu-img command should return non-zero exit code Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 02/23] qcow2: Support BDRV_REQ_MAY_UNMAP Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 03/23] block: Remove "options" indirection from blockdev-add Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 04/23] block: improve error handling in raw_open Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 05/23] qapi: fix memory leak in bdrv_image_info_specific_dump Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 06/23] throttle: Correct access to wrong BlockBackendPublic structures Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 07/23] qemu-iotests: Test I/O in a single drive from a throttling group Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 08/23] qemu-nbd: Add --fork option Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 09/23] iotests: Remove raciness from 162 Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 10/23] iotests: Do not rely on unavailable domains in 162 Kevin Wolf
2016-10-24 17:01 ` [Qemu-devel] [PULL 11/23] quorum: change child_iter to children_read Kevin Wolf
2016-10-24 17:02 ` Kevin Wolf [this message]
2016-10-24 17:02 ` [Qemu-devel] [PULL 13/23] block: Hide HBitmap in block dirty bitmap interface Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 14/23] HBitmap: Introduce "meta" bitmap to track bit changes Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 15/23] tests: Add test code for meta bitmap Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 16/23] block: Support meta dirty bitmap Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 17/23] block: Add two dirty bitmap getters Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 18/23] block: Assert that bdrv_release_dirty_bitmap succeeded Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 19/23] hbitmap: serialization Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 20/23] block: BdrvDirtyBitmap serialization interface Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 21/23] tests: Add test code for hbitmap serialization Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 22/23] block: More operations for meta dirty bitmap Kevin Wolf
2016-10-24 17:02 ` [Qemu-devel] [PULL 23/23] block/replication: Clarify 'top-id' parameter usage Kevin Wolf
2016-10-24 18:36 ` [Qemu-devel] [PULL 00/23] Block layer patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477328531-30879-13-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).