aboutsummaryrefslogtreecommitdiff
path: root/block/quorum.c
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2018-10-18 11:59:03 +0300
committerKevin Wolf <kwolf@redhat.com>2018-11-05 15:09:54 +0100
commit808b27d464287666821483257289b1a3379264b2 (patch)
tree1d9cecb2bec37f73be67a9b7226f2090773d6be1 /block/quorum.c
parent82c4c85978da41294fbd1d621fec373a4be6788f (diff)
quorum: Forbid adding children in blkverify mode
The blkverify mode of Quorum only works when the number of children is exactly two, so any attempt to add a new one must return an error. quorum_del_child() on the other hand doesn't need any additional check because decreasing the number of children would make it go under the vote threshold. Signed-off-by: Alberto Garcia <berto@igalia.com> Reported-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/quorum.c')
-rw-r--r--block/quorum.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/block/quorum.c b/block/quorum.c
index 6188ff6666..16b3c8067c 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -992,6 +992,11 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
char indexstr[32];
int ret;
+ if (s->is_blkverify) {
+ error_setg(errp, "Cannot add a child to a quorum in blkverify mode");
+ return;
+ }
+
assert(s->num_children <= INT_MAX / sizeof(BdrvChild *));
if (s->num_children == INT_MAX / sizeof(BdrvChild *) ||
s->next_child_index == UINT_MAX) {
@@ -1046,6 +1051,9 @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child,
return;
}
+ /* We know now that num_children > threshold, so blkverify must be false */
+ assert(!s->is_blkverify);
+
bdrv_drained_begin(bs);
/* We can safely remove this child now */