[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-5.0 10/31] block: Unify bdrv_child_cb_detach()
From: |
Max Reitz |
Subject: |
[PATCH for-5.0 10/31] block: Unify bdrv_child_cb_detach() |
Date: |
Wed, 27 Nov 2019 14:16:03 +0100 |
Make bdrv_child_cb_detach() call bdrv_backing_detach() for children with
a COW role (and drop the reverse call from bdrv_backing_detach()), so it
can be used for any child (with a proper role set).
Because so far no child has a proper role set, we need a temporary new
callback for child_backing.detach that ensures bdrv_backing_detach() is
called for all COW children that do not have their role set yet.
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 24a8910047..89214efa36 100644
--- a/block.c
+++ b/block.c
@@ -921,6 +921,7 @@ static void bdrv_child_cb_drained_end(BdrvChild *child,
}
static void bdrv_backing_attach(BdrvChild *c);
+static void bdrv_backing_detach(BdrvChild *c);
static void bdrv_child_cb_attach(BdrvChild *child)
{
@@ -936,6 +937,11 @@ static void bdrv_child_cb_attach(BdrvChild *child)
static void bdrv_child_cb_detach(BdrvChild *child)
{
BlockDriverState *bs = child->opaque;
+
+ if (child->role & BDRV_CHILD_COW) {
+ bdrv_backing_detach(child);
+ }
+
bdrv_unapply_subtree_drain(child, bs);
}
@@ -1159,7 +1165,14 @@ static void bdrv_backing_detach(BdrvChild *c)
bdrv_op_unblock_all(c->bs, parent->backing_blocker);
error_free(parent->backing_blocker);
parent->backing_blocker = NULL;
+}
+/* XXX: Will be removed along with child_backing */
+static void bdrv_child_cb_detach_backing(BdrvChild *c)
+{
+ if (!(c->role & BDRV_CHILD_COW)) {
+ bdrv_backing_detach(c);
+ }
bdrv_child_cb_detach(c);
}
@@ -1207,7 +1220,7 @@ const BdrvChildClass child_backing = {
.parent_is_bds = true,
.get_parent_desc = bdrv_child_get_parent_desc,
.attach = bdrv_child_cb_attach_backing,
- .detach = bdrv_backing_detach,
+ .detach = bdrv_child_cb_detach_backing,
.inherit_options = bdrv_backing_options,
.drained_begin = bdrv_child_cb_drained_begin,
.drained_poll = bdrv_child_cb_drained_poll,
--
2.23.0
- [PATCH for-5.0 01/31] block: Rename BdrvChildRole to BdrvChildClass, (continued)
- [PATCH for-5.0 01/31] block: Rename BdrvChildRole to BdrvChildClass, Max Reitz, 2019/11/27
- [PATCH for-5.0 04/31] block: Pass BdrvChildRole to bdrv_child_perm(), Max Reitz, 2019/11/27
- [PATCH for-5.0 03/31] block: Add BdrvChildRole to BdrvChild, Max Reitz, 2019/11/27
- [PATCH for-5.0 05/31] block: Drop BdrvChildClass.stay_at_node, Max Reitz, 2019/11/27
- [PATCH for-5.0 06/31] block: Keep BDRV_O_NO_IO in *inherited_fmt_options, Max Reitz, 2019/11/27
- [PATCH for-5.0 07/31] block: Pass BdrvChildRole to .inherit_options(), Max Reitz, 2019/11/27
- [PATCH for-5.0 08/31] block: Unify bdrv_*inherited_options(), Max Reitz, 2019/11/27
- [PATCH for-5.0 12/31] block: Distinguish paths in *_format_default_perms, Max Reitz, 2019/11/27
- [PATCH for-5.0 09/31] block: Unify bdrv_child_cb_attach(), Max Reitz, 2019/11/27
- [PATCH for-5.0 11/31] block: Add child_of_bds, Max Reitz, 2019/11/27
- [PATCH for-5.0 10/31] block: Unify bdrv_child_cb_detach(),
Max Reitz <=
- [PATCH for-5.0 15/31] block: Split bdrv_default_perms_for_storage(), Max Reitz, 2019/11/27
- [PATCH for-5.0 13/31] block: Pull out bdrv_default_perms_for_backing(), Max Reitz, 2019/11/27
- [PATCH for-5.0 14/31] block: Pull out bdrv_default_perms_for_storage(), Max Reitz, 2019/11/27
- [PATCH for-5.0 16/31] block: Add bdrv_default_perms(), Max Reitz, 2019/11/27
- [PATCH for-5.0 17/31] raw-format: Split raw_read_options(), Max Reitz, 2019/11/27
- [PATCH for-5.0 19/31] block: Drop child_format, Max Reitz, 2019/11/27
- [PATCH for-5.0 20/31] block: Make backing files child_of_bds children, Max Reitz, 2019/11/27
- [PATCH for-5.0 21/31] block: Drop child_backing, Max Reitz, 2019/11/27
- [PATCH for-5.0 23/31] block: Make filter drivers use child_of_bds, Max Reitz, 2019/11/27
- [PATCH for-5.0 22/31] block: Make format drivers use child_of_bds, Max Reitz, 2019/11/27