From: Paolo Bonzini <pbonzini@redhat.com>
To: Wen Congyang <wency@cn.fujitsu.com>,
qemu devel <qemu-devel@nongnu.org>, Fam Zheng <famz@redhat.com>,
Max Reitz <mreitz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
qemu block <qemu-block@nongnu.org>,
Jiang Yunhong <yunhong.jiang@intel.com>,
Dong Eddie <eddie.dong@intel.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Gonglei <arei.gonglei@huawei.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Yang Hongyang <yanghy@cn.fujitsu.com>,
zhanghailiang <zhang.zhanghailiang@huawei.com>
Subject: Re: [Qemu-devel] [RFC PATCH COLO v2 05/13] quorum: implement block driver interfaces for block replication
Date: Wed, 25 Mar 2015 13:50:15 +0100 [thread overview]
Message-ID: <5512AF07.7050709@redhat.com> (raw)
In-Reply-To: <1427276174-9130-6-git-send-email-wency@cn.fujitsu.com>
On 25/03/2015 10:36, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> block/quorum.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 79 insertions(+)
>
> diff --git a/block/quorum.c b/block/quorum.c
> index d087135..eee829d 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -84,6 +84,8 @@ typedef struct BDRVQuorumState {
> */
>
> QuorumReadPattern read_pattern;
> +
> + int colo_index; /* store which child supports block replication */
> } BDRVQuorumState;
>
> typedef struct QuorumAIOCB QuorumAIOCB;
> @@ -1024,6 +1026,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
> }
>
> g_free(opened);
> + s->colo_index = -1;
> goto exit;
>
> close_exit:
> @@ -1114,6 +1117,78 @@ static void quorum_refresh_filename(BlockDriverState *bs)
> bs->full_open_options = opts;
> }
>
> +static void quorum_stop_replication(BlockDriverState *bs, Error **errp);
> +static void quorum_start_replication(BlockDriverState *bs, COLOMode mode,
> + Error **errp)
> +{
> + BDRVQuorumState *s = bs->opaque;
> + int count = 0, i, index;
> + Error *local_err = NULL;
> +
> + /*
> + * TODO: support COLO_SECONDARY_MODE if we allow secondary
> + * QEMU becoming primary QEMU.
> + */
> + if (mode != COLO_MODE_PRIMARY) {
> + error_set(errp, QERR_INVALID_PARAMETER, "mode");
> + return;
> + }
> +
> + if (s->read_pattern != QUORUM_READ_PATTERN_FIFO) {
> + error_set(errp, QERR_INVALID_PARAMETER, "read pattern");
> + return;
> + }
> +
> + for (i = 0; i < s->num_children; i++) {
> + bdrv_start_replication(s->bs[i], mode, &local_err);
> + if (local_err) {
> + error_free(local_err);
> + local_err = NULL;
> + } else {
> + count++;
> + index = i;
> + }
> + }
> +
> + if (count == 0) {
> + /* No child supports block replication */
> + error_set(errp, QERR_UNSUPPORTED);
> + } else if (count > 1) {
> + quorum_stop_replication(bs, NULL);
> + error_setg(errp, "too many children support block replication");
> + } else {
> + s->colo_index = index;
> + }
> +}
> +
> +static void quorum_do_checkpoint(BlockDriverState *bs, Error **errp)
> +{
> + BDRVQuorumState *s = bs->opaque;
> +
> + if (s->colo_index < 0) {
> + error_setg(errp, "Block replication is not started");
> + return;
> + }
> +
> + bdrv_do_checkpoint(s->bs[s->colo_index], errp);
> +}
> +
> +static void quorum_stop_replication(BlockDriverState *bs, Error **errp)
> +{
> + BDRVQuorumState *s = bs->opaque;
> + int i;
> +
> + if (s->colo_index >= 0) {
> + bdrv_stop_replication(s->bs[s->colo_index], errp);
> + s->colo_index = -1;
> + return;
> + }
> +
> + for (i = 0; i < s->num_children; i++) {
> + bdrv_stop_replication(s->bs[i], NULL);
> + }
Why do anything at all if s->colo_index < 0? So, with the for loop
removed (and possibly the if condition changed to "s->colo_index < 0",
similar to quorum_do_checkpoint:
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo
> +}
> +
> static BlockDriver bdrv_quorum = {
> .format_name = "quorum",
> .protocol_name = "quorum",
> @@ -1137,6 +1212,10 @@ static BlockDriver bdrv_quorum = {
>
> .is_filter = true,
> .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter,
> +
> + .bdrv_start_replication = quorum_start_replication,
> + .bdrv_do_checkpoint = quorum_do_checkpoint,
> + .bdrv_stop_replication = quorum_stop_replication,
> };
>
> static void bdrv_quorum_init(void)
>
next prev parent reply other threads:[~2015-03-25 12:50 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 9:36 [Qemu-devel] [RFC PATCH COLO v2 00/13] Block replication for continuous checkpoints Wen Congyang
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 01/13] docs: block replication's description Wen Congyang
2015-03-25 15:38 ` [Qemu-devel] [Qemu-block] " Eric Blake
2015-03-26 8:58 ` Wen Congyang
2015-03-26 10:28 ` Gonglei
2015-03-26 12:30 ` Eric Blake
2015-03-26 12:46 ` Gonglei
2015-03-26 6:31 ` [Qemu-devel] " Fam Zheng
2015-03-26 7:17 ` Wen Congyang
2015-04-03 2:35 ` Wen Congyang
2015-04-03 5:19 ` Fam Zheng
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 02/13] quorum: allow ignoring child errors Wen Congyang
2015-03-25 12:45 ` Paolo Bonzini
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 03/13] NBD client: connect to nbd server later Wen Congyang
2015-03-25 12:46 ` Paolo Bonzini
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 04/13] Add new block driver interfaces to control block replication Wen Congyang
2015-03-25 12:48 ` Paolo Bonzini
2015-03-25 15:43 ` Eric Blake
2015-03-26 7:12 ` Fam Zheng
2015-03-26 7:22 ` Wen Congyang
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 05/13] quorum: implement block driver interfaces for " Wen Congyang
2015-03-25 12:50 ` Paolo Bonzini [this message]
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 06/13] NBD client: " Wen Congyang
2015-03-25 12:50 ` Paolo Bonzini
2015-03-26 7:21 ` Fam Zheng
2015-03-26 7:32 ` Wen Congyang
2015-03-27 1:06 ` Fam Zheng
2015-03-27 1:16 ` Wen Congyang
2015-03-27 7:34 ` [Qemu-devel] Use of QERR_ macros and error classes (was: [RFC PATCH COLO v2 06/13] NBD client: implement block driver interfaces for block replication) Markus Armbruster
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 07/13] allow writing to the backing file Wen Congyang
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 08/13] Allow creating backup jobs when opening BDS Wen Congyang
2015-03-26 7:07 ` Fam Zheng
2015-03-26 7:14 ` Wen Congyang
2015-03-26 7:18 ` Fam Zheng
2015-03-26 7:23 ` Wen Congyang
2015-03-26 13:53 ` Paolo Bonzini
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 09/13] block: Parse "backing_reference" option to reference existing BDS Wen Congyang
2015-03-26 7:31 ` Fam Zheng
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 10/13] Backup: clear all bitmap when doing block checkpoint Wen Congyang
2015-03-25 12:55 ` Paolo Bonzini
2015-03-26 0:59 ` Wen Congyang
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 11/13] qcow2: support colo Wen Congyang
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 12/13] skip nbd_target when starting block replication Wen Congyang
2015-03-26 7:03 ` Fam Zheng
2015-03-26 7:15 ` Wen Congyang
2015-03-25 9:36 ` [Qemu-devel] [RFC PATCH COLO v2 13/13] Don't allow a disk use backing reference target Wen Congyang
2015-03-25 12:56 ` [Qemu-devel] [RFC PATCH COLO v2 00/13] Block replication for continuous checkpoints Paolo Bonzini
2015-03-25 14:24 ` Dr. David Alan Gilbert
2015-03-26 2:34 ` Gonglei
2015-07-01 3:09 ` Michael R. Hines
2015-07-01 4:11 ` Wen Congyang
2015-07-01 19:30 ` Michael R. Hines
2015-07-01 19:37 ` Michael R. Hines
2015-07-02 0:58 ` Wen Congyang
2015-07-02 1:43 ` Wen Congyang
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=5512AF07.7050709@redhat.com \
--to=pbonzini@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=dgilbert@redhat.com \
--cc=eddie.dong@intel.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=laijs@cn.fujitsu.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wency@cn.fujitsu.com \
--cc=yanghy@cn.fujitsu.com \
--cc=yunhong.jiang@intel.com \
--cc=zhang.zhanghailiang@huawei.com \
/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).