From: Wen Congyang <wency@cn.fujitsu.com>
To: qemu devel <qemu-devel@nongnu.org>, Fam Zheng <famz@redhat.com>,
Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, qemu block <qemu-block@nongnu.org>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
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: [Qemu-devel] [PATCH COLO v3 02/14] quorum: allow ignoring child errors
Date: Fri, 3 Apr 2015 18:01:08 +0800 [thread overview]
Message-ID: <1428055280-12015-3-git-send-email-wency@cn.fujitsu.com> (raw)
In-Reply-To: <1428055280-12015-1-git-send-email-wency@cn.fujitsu.com>
If the child is not ready, read/write/getlength/flush will
return -errno. It is not critical error, and can be ignored:
1. read/write:
Just not report the error event.
2. getlength:
just ignore it. If all children's getlength return -errno,
and be ignored, return -EIO.
3. flush:
Just ignore it. If all children's getlength return -errno,
and be ignored, return 0.
Usage: children.x.ignore-errors=true
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 | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 57 insertions(+), 7 deletions(-)
diff --git a/block/quorum.c b/block/quorum.c
index 437b122..ca4f970 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -30,6 +30,7 @@
#define QUORUM_OPT_BLKVERIFY "blkverify"
#define QUORUM_OPT_REWRITE "rewrite-corrupted"
#define QUORUM_OPT_READ_PATTERN "read-pattern"
+#define QUORUM_CHILDREN_OPT_IGNORE_ERRORS "ignore-errors"
/* This union holds a vote hash value */
typedef union QuorumVoteValue {
@@ -65,6 +66,7 @@ typedef struct QuorumVotes {
/* the following structure holds the state of one quorum instance */
typedef struct BDRVQuorumState {
BlockDriverState **bs; /* children BlockDriverStates */
+ bool *ignore_errors; /* ignore children's error? */
int num_children; /* children count */
int threshold; /* if less than threshold children reads gave the
* same result a quorum error occurs.
@@ -97,6 +99,7 @@ typedef struct QuorumChildRequest {
uint8_t *buf;
int ret;
QuorumAIOCB *parent;
+ int index;
} QuorumChildRequest;
/* Quorum will use the following structure to track progress of each read/write
@@ -209,6 +212,7 @@ static QuorumAIOCB *quorum_aio_get(BDRVQuorumState *s,
acb->qcrs[i].buf = NULL;
acb->qcrs[i].ret = 0;
acb->qcrs[i].parent = acb;
+ acb->qcrs[i].index = i;
}
return acb;
@@ -305,7 +309,7 @@ static void quorum_aio_cb(void *opaque, int ret)
acb->count++;
if (ret == 0) {
acb->success_count++;
- } else {
+ } else if (!s->ignore_errors[sacb->index]) {
quorum_report_bad(acb, sacb->aiocb->bs->node_name, ret);
}
assert(acb->count <= s->num_children);
@@ -720,19 +724,31 @@ static BlockAIOCB *quorum_aio_writev(BlockDriverState *bs,
static int64_t quorum_getlength(BlockDriverState *bs)
{
BDRVQuorumState *s = bs->opaque;
- int64_t result;
+ int64_t result = -EIO;
int i;
/* check that all file have the same length */
- result = bdrv_getlength(s->bs[0]);
- if (result < 0) {
- return result;
- }
- for (i = 1; i < s->num_children; i++) {
+ for (i = 0; i < s->num_children; i++) {
int64_t value = bdrv_getlength(s->bs[i]);
+
if (value < 0) {
return value;
}
+
+ if (value == 0 && s->ignore_errors[i]) {
+ /*
+ * If the child is not ready, it cannot return -errno,
+ * otherwise refresh_total_sectors() will fail when
+ * we open the child.
+ */
+ continue;
+ }
+
+ if (result == -EIO) {
+ result = value;
+ continue;
+ }
+
if (value != result) {
return -EIO;
}
@@ -770,6 +786,9 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs)
for (i = 0; i < s->num_children; i++) {
result = bdrv_co_flush(s->bs[i]);
+ if (result < 0 && s->ignore_errors[i]) {
+ result = 0;
+ }
result_value.l = result;
quorum_count_vote(&error_votes, &result_value, i);
}
@@ -844,6 +863,19 @@ static QemuOptsList quorum_runtime_opts = {
},
};
+static QemuOptsList quorum_children_common_opts = {
+ .name = "quorum children",
+ .head = QTAILQ_HEAD_INITIALIZER(quorum_children_common_opts.head),
+ .desc = {
+ {
+ .name = QUORUM_CHILDREN_OPT_IGNORE_ERRORS,
+ .type = QEMU_OPT_BOOL,
+ .help = "ignore child I/O error",
+ },
+ { /* end of list */ }
+ },
+};
+
static int parse_read_pattern(const char *opt)
{
int i;
@@ -939,11 +971,14 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
/* allocate the children BlockDriverState array */
s->bs = g_new0(BlockDriverState *, s->num_children);
opened = g_new0(bool, s->num_children);
+ s->ignore_errors = g_new0(bool, s->num_children);
for (i = 0, lentry = qlist_first(list); lentry;
lentry = qlist_next(lentry), i++) {
QDict *d;
QString *string;
+ QemuOpts *children_opts = NULL;
+ bool value;
switch (qobject_type(lentry->value))
{
@@ -951,6 +986,20 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
case QTYPE_QDICT:
d = qobject_to_qdict(lentry->value);
QINCREF(d);
+
+ children_opts = qemu_opts_create(&quorum_children_common_opts,
+ NULL, 0, &error_abort);
+ qemu_opts_absorb_qdict(children_opts, d, &local_err);
+ if (local_err) {
+ ret = -EINVAL;
+ qemu_opts_del(children_opts);
+ goto close_exit;
+ }
+ value = qemu_opt_get_bool(children_opts,
+ QUORUM_CHILDREN_OPT_IGNORE_ERRORS,
+ false);
+ s->ignore_errors[i] = value;
+ qemu_opts_del(children_opts);
ret = bdrv_open(&s->bs[i], NULL, NULL, d, flags, NULL,
&local_err);
break;
@@ -1008,6 +1057,7 @@ static void quorum_close(BlockDriverState *bs)
}
g_free(s->bs);
+ g_free(s->ignore_errors);
}
static void quorum_detach_aio_context(BlockDriverState *bs)
--
2.1.0
next prev parent reply other threads:[~2015-04-03 9:58 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 10:01 [Qemu-devel] [PATCH COLO v3 00/14] Block replication for continuous checkpoints Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 01/14] docs: block replication's description Wen Congyang
2015-04-20 15:30 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-21 1:25 ` Wen Congyang
2015-04-21 15:28 ` Paolo Bonzini
2015-04-22 9:18 ` Stefan Hajnoczi
2015-04-22 9:28 ` Wen Congyang
2015-04-23 9:55 ` Stefan Hajnoczi
2015-04-23 10:11 ` Wen Congyang
2015-04-22 9:31 ` Kevin Wolf
2015-04-22 10:12 ` [Qemu-devel] " Paolo Bonzini
2015-04-23 9:00 ` Kevin Wolf
2015-04-23 9:14 ` Wen Congyang
2015-04-23 10:05 ` Paolo Bonzini
2015-04-23 10:17 ` Kevin Wolf
2015-04-23 10:33 ` Paolo Bonzini
2015-04-23 10:40 ` Kevin Wolf
2015-04-23 10:44 ` Paolo Bonzini
2015-04-23 11:35 ` Wen Congyang
2015-04-23 11:36 ` Kevin Wolf
2015-04-23 11:53 ` Paolo Bonzini
2015-04-23 12:05 ` Dr. David Alan Gilbert
2015-04-23 12:11 ` Paolo Bonzini
2015-04-23 12:19 ` Dr. David Alan Gilbert
2015-04-23 12:23 ` Paolo Bonzini
2015-04-24 2:01 ` Fam Zheng
2015-04-24 2:16 ` Wen Congyang
2015-04-24 7:47 ` Paolo Bonzini
2015-04-24 7:55 ` Wen Congyang
2015-04-24 8:58 ` Dr. David Alan Gilbert
2015-04-24 9:04 ` Paolo Bonzini
2015-04-24 9:38 ` Wen Congyang
2015-04-24 9:36 ` Paolo Bonzini
2015-04-24 9:53 ` Wen Congyang
2015-04-24 10:03 ` Paolo Bonzini
2015-04-27 9:37 ` Stefan Hajnoczi
2015-04-29 8:29 ` Paolo Bonzini
2015-04-29 8:37 ` Gonglei
2015-04-30 14:56 ` Stefan Hajnoczi
2015-05-05 15:23 ` Dr. David Alan Gilbert
2015-05-06 2:26 ` Dong, Eddie
2015-05-06 2:49 ` Fam Zheng
2015-05-08 8:42 ` Stefan Hajnoczi
2015-05-08 9:34 ` Dr. David Alan Gilbert
2015-05-08 9:39 ` Kevin Wolf
2015-05-08 9:55 ` Dr. David Alan Gilbert
2015-04-23 9:26 ` Paolo Bonzini
2015-04-23 9:37 ` Kevin Wolf
2015-04-23 9:41 ` Wen Congyang
2015-04-22 9:29 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-22 9:42 ` Wen Congyang
2015-04-22 10:39 ` [Qemu-devel] " Dr. David Alan Gilbert
2015-04-03 10:01 ` Wen Congyang [this message]
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 03/14] NBD client: connect to nbd server later Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 04/14] Add new block driver interfaces to control block replication Wen Congyang
2015-04-22 12:56 ` Eric Blake
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 05/14] quorum: implement block driver interfaces for " Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 06/14] NBD client: " Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 07/14] allow writing to the backing file Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 08/14] Allow creating backup jobs when opening BDS Wen Congyang
2015-04-03 11:06 ` Paolo Bonzini
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 09/14] block: Parse "backing_reference" option to reference existing BDS Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 10/14] util/hbitmap: Add an API to reset all set bits in hbitmap Wen Congyang
2015-04-03 11:05 ` Paolo Bonzini
2015-05-01 16:47 ` [Qemu-devel] [Qemu-block] " John Snow
2015-05-07 2:20 ` Wen Congyang
2015-05-07 18:32 ` John Snow
2015-05-08 0:59 ` Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 11/14] Backup: clear all bitmap when doing block checkpoint Wen Congyang
2015-04-03 11:09 ` Paolo Bonzini
2015-04-07 1:45 ` Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 12/14] qcow2: support colo Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 13/14] skip nbd_target when starting block replication Wen Congyang
2015-04-03 10:01 ` [Qemu-devel] [PATCH COLO v3 14/14] Don't allow a disk use backing reference target 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=1428055280-12015-3-git-send-email-wency@cn.fujitsu.com \
--to=wency@cn.fujitsu.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=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).