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>
This commit is contained in:
parent
82c4c85978
commit
808b27d464
@ -992,6 +992,11 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
|
|||||||
char indexstr[32];
|
char indexstr[32];
|
||||||
int ret;
|
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 *));
|
assert(s->num_children <= INT_MAX / sizeof(BdrvChild *));
|
||||||
if (s->num_children == INT_MAX / sizeof(BdrvChild *) ||
|
if (s->num_children == INT_MAX / sizeof(BdrvChild *) ||
|
||||||
s->next_child_index == UINT_MAX) {
|
s->next_child_index == UINT_MAX) {
|
||||||
@ -1046,6 +1051,9 @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We know now that num_children > threshold, so blkverify must be false */
|
||||||
|
assert(!s->is_blkverify);
|
||||||
|
|
||||||
bdrv_drained_begin(bs);
|
bdrv_drained_begin(bs);
|
||||||
|
|
||||||
/* We can safely remove this child now */
|
/* We can safely remove this child now */
|
||||||
|
Loading…
Reference in New Issue
Block a user