block: inline bdrv_replace_child()

bdrv_replace_child() has only one caller, the second argument is
unused. Inline it now. This triggers deletion of some more unused
interfaces.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210428151804.439460-34-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2021-04-28 18:18:01 +03:00 committed by Kevin Wolf
parent 25409807cf
commit 4954aacea0
1 changed files with 18 additions and 83 deletions

101
block.c
View File

@ -2401,42 +2401,6 @@ static int bdrv_list_refresh_perms(GSList *list, BlockReopenQueue *q,
return 0;
}
static void bdrv_node_set_perm(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
BdrvChild *c;
if (!drv) {
return;
}
bdrv_drv_set_perm_commit(bs);
/* Drivers that never have children can omit .bdrv_child_perm() */
if (!drv->bdrv_child_perm) {
assert(QLIST_EMPTY(&bs->children));
return;
}
/* Update all children */
QLIST_FOREACH(c, &bs->children, next) {
bdrv_child_set_perm_commit(c);
}
}
static void bdrv_list_set_perm(GSList *list)
{
for ( ; list; list = list->next) {
bdrv_node_set_perm((BlockDriverState *)list->data);
}
}
static void bdrv_set_perm(BlockDriverState *bs)
{
g_autoptr(GSList) list = bdrv_topological_dfs(NULL, NULL, bs);
return bdrv_list_set_perm(list);
}
void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm,
uint64_t *shared_perm)
{
@ -2776,52 +2740,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
}
}
/*
* Updates @child to change its reference to point to @new_bs, including
* checking and applying the necessary permission updates both to the old node
* and to @new_bs.
*
* NULL is passed as @new_bs for removing the reference before freeing @child.
*
* If @new_bs is not NULL, bdrv_check_perm() must be called beforehand, as this
* function uses bdrv_set_perm() to update the permissions according to the new
* reference that @new_bs gets.
*
* Callers must ensure that child->frozen is false.
*/
static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
{
BlockDriverState *old_bs = child->bs;
/* Asserts that child->frozen == false */
bdrv_replace_child_noperm(child, new_bs);
/*
* Start with the new node's permissions. If @new_bs is a (direct
* or indirect) child of @old_bs, we must complete the permission
* update on @new_bs before we loosen the restrictions on @old_bs.
* Otherwise, bdrv_check_perm() on @old_bs would re-initiate
* updating the permissions of @new_bs, and thus not purely loosen
* restrictions.
*/
if (new_bs) {
bdrv_set_perm(new_bs);
}
if (old_bs) {
/*
* Update permissions for old node. We're just taking a parent away, so
* we're loosening restrictions. Errors of permission update are not
* fatal in this case, ignore them.
*/
bdrv_refresh_perms(old_bs, NULL);
/* When the parent requiring a non-default AioContext is removed, the
* node moves back to the main AioContext */
bdrv_try_set_aio_context(old_bs, qemu_get_aio_context(), NULL);
}
}
static void bdrv_child_free(void *opaque)
{
BdrvChild *c = opaque;
@ -2989,8 +2907,25 @@ static int bdrv_attach_child_noperm(BlockDriverState *parent_bs,
static void bdrv_detach_child(BdrvChild *child)
{
bdrv_replace_child(child, NULL);
BlockDriverState *old_bs = child->bs;
bdrv_replace_child_noperm(child, NULL);
bdrv_remove_empty_child(child);
if (old_bs) {
/*
* Update permissions for old node. We're just taking a parent away, so
* we're loosening restrictions. Errors of permission update are not
* fatal in this case, ignore them.
*/
bdrv_refresh_perms(old_bs, NULL);
/*
* When the parent requiring a non-default AioContext is removed, the
* node moves back to the main AioContext
*/
bdrv_try_set_aio_context(old_bs, qemu_get_aio_context(), NULL);
}
}
/*