summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorWen Congyang <wency@cn.fujitsu.com>2015-07-03 14:45:06 +0800
committerMax Reitz <mreitz@redhat.com>2015-09-04 21:00:32 +0200
commit834cb2ada5db197a11c99142d50222945d196fc0 (patch)
treecb92ccf3ac78e8fbc4599aedca2f5aa1b07d2576 /block
parent909c260c71d1bee7018e17034580ffd0743508db (diff)
downloadqemu-834cb2ada5db197a11c99142d50222945d196fc0.tar.gz
qemu-834cb2ada5db197a11c99142d50222945d196fc0.tar.bz2
qemu-834cb2ada5db197a11c99142d50222945d196fc0.zip
quorum: validate vote threshold against num_children even if read-pattern is fifo
We need to use threshold to check if too many write operation fails. If threshold is larger than num children, we always get write error event even if all write operations success. Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> Message-id: 55962F72.3060003@cn.fujitsu.com Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/quorum.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/block/quorum.c b/block/quorum.c
index 2f6c45f760..8fe53b4272 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -889,6 +889,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
}
s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
+ /* and validate it against s->num_children */
+ ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+ if (ret < 0) {
+ goto exit;
+ }
+
ret = parse_read_pattern(qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN));
if (ret < 0) {
error_setg(&local_err, "Please set read-pattern as fifo or quorum");
@@ -897,12 +903,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
s->read_pattern = ret;
if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
- /* and validate it against s->num_children */
- ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
- if (ret < 0) {
- goto exit;
- }
-
/* is the driver in blkverify mode */
if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
s->num_children == 2 && s->threshold == 2) {