bdrv_delete() is the only caller of bdrv_close(). Let's merge them to simplify further commits.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> --- block.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/block.c b/block.c index 82fbf81a3c..71a5aec24c 100644 --- a/block.c +++ b/block.c @@ -4785,12 +4785,19 @@ static void bdrv_reopen_abort(BDRVReopenState *reopen_state) } -static void bdrv_close(BlockDriverState *bs) +static void bdrv_delete(BlockDriverState *bs) { BdrvAioNotifier *ban, *ban_next; BdrvChild *child, *next; assert(!bs->refcnt); + assert(bdrv_op_blocker_is_empty(bs)); + + /* remove from list, if necessary */ + if (bs->node_name[0] != '\0') { + QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list); + } + QTAILQ_REMOVE(&all_bdrv_states, bs, bs_list); bdrv_drained_begin(bs); /* complete I/O */ bdrv_flush(bs); @@ -4844,6 +4851,8 @@ static void bdrv_close(BlockDriverState *bs) if (bs->quiesce_counter) { bdrv_drain_all_end_quiesce(bs); } + + g_free(bs); } void bdrv_close_all(void) @@ -5164,22 +5173,6 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs, return ret; } -static void bdrv_delete(BlockDriverState *bs) -{ - assert(bdrv_op_blocker_is_empty(bs)); - assert(!bs->refcnt); - - /* remove from list, if necessary */ - if (bs->node_name[0] != '\0') { - QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list); - } - QTAILQ_REMOVE(&all_bdrv_states, bs, bs_list); - - bdrv_close(bs); - - g_free(bs); -} - /* * Replace @bs by newly created block node. -- 2.31.1