[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 15/45] block: refactor bdrv_remove_file_or_backing_child to bd
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v5 15/45] block: refactor bdrv_remove_file_or_backing_child to bdrv_remove_child |
Date: |
Thu, 31 Mar 2022 00:28:32 +0300 |
Now the function can remove any child, so give it more common name.
Drop assertions and drop bs argument which becomes unused. Function
would be reused in a further commit.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
---
block.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/block.c b/block.c
index 6b43e101a1..ea5687edc8 100644
--- a/block.c
+++ b/block.c
@@ -92,9 +92,7 @@ static bool bdrv_recurse_has_child(BlockDriverState *bs,
static void bdrv_replace_child_noperm(BdrvChild *child,
BlockDriverState *new_bs);
-static void bdrv_remove_file_or_backing_child(BlockDriverState *bs,
- BdrvChild *child,
- Transaction *tran);
+static void bdrv_remove_child(BdrvChild *child, Transaction *tran);
static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs,
Transaction *tran);
@@ -3347,7 +3345,7 @@ static int
bdrv_set_file_or_backing_noperm(BlockDriverState *parent_bs,
if (child) {
bdrv_unset_inherits_from(parent_bs, child, tran);
- bdrv_remove_file_or_backing_child(parent_bs, child, tran);
+ bdrv_remove_child(child, tran);
}
if (!child_bs) {
@@ -5031,26 +5029,22 @@ static bool should_update_child(BdrvChild *c,
BlockDriverState *to)
return ret;
}
-static void bdrv_remove_filter_or_cow_child_commit(void *opaque)
+static void bdrv_remove_child_commit(void *opaque)
{
GLOBAL_STATE_CODE();
bdrv_child_free(opaque);
}
-static TransactionActionDrv bdrv_remove_filter_or_cow_child_drv = {
- .commit = bdrv_remove_filter_or_cow_child_commit,
+static TransactionActionDrv bdrv_remove_child_drv = {
+ .commit = bdrv_remove_child_commit,
};
/*
* A function to remove backing or file child of @bs.
* Function doesn't update permissions, caller is responsible for this.
*/
-static void bdrv_remove_file_or_backing_child(BlockDriverState *bs,
- BdrvChild *child,
- Transaction *tran)
+static void bdrv_remove_child(BdrvChild *child, Transaction *tran)
{
- assert(child == bs->backing || child == bs->file);
-
if (!child) {
return;
}
@@ -5059,7 +5053,7 @@ static void
bdrv_remove_file_or_backing_child(BlockDriverState *bs,
bdrv_replace_child_tran(child, NULL, tran);
}
- tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, child);
+ tran_add(tran, &bdrv_remove_child_drv, child);
}
/*
@@ -5070,7 +5064,7 @@ static void
bdrv_remove_file_or_backing_child(BlockDriverState *bs,
static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs,
Transaction *tran)
{
- bdrv_remove_file_or_backing_child(bs, bdrv_filter_or_cow_child(bs), tran);
+ bdrv_remove_child(bdrv_filter_or_cow_child(bs), tran);
}
static int bdrv_replace_node_noperm(BlockDriverState *from,
--
2.35.1
- [PATCH v5 25/45] blockdev: qmp_transaction: refactor loop to classic for, (continued)
- [PATCH v5 25/45] blockdev: qmp_transaction: refactor loop to classic for, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 29/45] block: introduce BDRV_O_NOPERM flag, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 35/45] block: make bdrv_find_child() function public, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 36/45] block: bdrv_replace_child_bs(): move to external transaction, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 32/45] iotests: add blockdev-add-transaction, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 39/45] block: bdrv_get_xdbg_block_graph(): report export ids, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 44/45] block: bdrv_open_inherit: create BlockBackend only when necessary, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 07/45] block: document connection between child roles and bs->backing/bs->file, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 10/45] Revert "block: Let replace_child_tran keep indirect pointer", Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 14/45] block/snapshot: drop indirection around bdrv_snapshot_fallback_ptr, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 15/45] block: refactor bdrv_remove_file_or_backing_child to bdrv_remove_child,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v5 20/45] block: make permission update functions public, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 24/45] blockdev: transactions: rename some things, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 27/45] blockdev: qmp_transaction: drop extra generic layer, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 28/45] qapi: block: add blockdev-del transaction action, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 30/45] block: bdrv_insert_node(): use BDRV_O_NOPERM, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 31/45] qapi: block: add blockdev-add transaction action, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 33/45] block-backend: blk_root(): drop const specifier on return type, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 34/45] block/export: add blk_by_export_id(), Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 37/45] qapi: add x-blockdev-replace command, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 38/45] qapi: add x-blockdev-replace transaction action, Vladimir Sementsov-Ogievskiy, 2022/03/30