block: Use bdrv_recurse_can_replace()
Let check_to_replace_node() use the more specialized bdrv_recurse_can_replace() instead of bdrv_recurse_is_first_non_filter(), which is too restrictive (or, in the case of quorum, sometimes not restrictive enough). Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200218103454.296704-10-mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
a3ed794b36
commit
810803a87c
18
block.c
18
block.c
|
@ -6272,6 +6272,17 @@ bool bdrv_recurse_can_replace(BlockDriverState *bs,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether the given @node_name can be replaced by a node that
|
||||||
|
* has the same data as @parent_bs. If so, return @node_name's BDS;
|
||||||
|
* NULL otherwise.
|
||||||
|
*
|
||||||
|
* @node_name must be a (recursive) *child of @parent_bs (or this
|
||||||
|
* function will return NULL).
|
||||||
|
*
|
||||||
|
* The result (whether the node can be replaced or not) is only valid
|
||||||
|
* for as long as no graph or permission changes occur.
|
||||||
|
*/
|
||||||
BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs,
|
BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs,
|
||||||
const char *node_name, Error **errp)
|
const char *node_name, Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -6296,8 +6307,11 @@ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs,
|
||||||
* Another benefit is that this tests exclude backing files which are
|
* Another benefit is that this tests exclude backing files which are
|
||||||
* blocked by the backing blockers.
|
* blocked by the backing blockers.
|
||||||
*/
|
*/
|
||||||
if (!bdrv_recurse_is_first_non_filter(parent_bs, to_replace_bs)) {
|
if (!bdrv_recurse_can_replace(parent_bs, to_replace_bs)) {
|
||||||
error_setg(errp, "Only top most non filter can be replaced");
|
error_setg(errp, "Cannot replace '%s' by a node mirrored from '%s', "
|
||||||
|
"because it cannot be guaranteed that doing so would not "
|
||||||
|
"lead to an abrupt change of visible data",
|
||||||
|
node_name, parent_bs->node_name);
|
||||||
to_replace_bs = NULL;
|
to_replace_bs = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue