[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 4/6] block: Inactivate parents before children
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH 4/6] block: Inactivate parents before children |
Date: |
Thu, 4 May 2017 18:52:39 +0200 |
The proper order for inactivating block nodes is that first the parents
get inactivated and then the children. If we do things in this order, we
can assert that we didn't accidentally leave a parent activated when one
of its child nodes is inactive.
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index c3e7ebd..773bd64 100644
--- a/block.c
+++ b/block.c
@@ -762,6 +762,13 @@ static void bdrv_child_cb_drained_end(BdrvChild *child)
bdrv_drained_end(bs);
}
+static int bdrv_child_cb_inactivate(BdrvChild *child)
+{
+ BlockDriverState *bs = child->opaque;
+ assert(bs->open_flags & BDRV_O_INACTIVE);
+ return 0;
+}
+
/*
* Returns the options and flags that a temporary snapshot should get, based on
* the originally requested flags (the originally requested image will have
@@ -822,6 +829,7 @@ const BdrvChildRole child_file = {
.inherit_options = bdrv_inherited_options,
.drained_begin = bdrv_child_cb_drained_begin,
.drained_end = bdrv_child_cb_drained_end,
+ .inactivate = bdrv_child_cb_inactivate,
};
/*
@@ -843,6 +851,7 @@ const BdrvChildRole child_format = {
.inherit_options = bdrv_inherited_fmt_options,
.drained_begin = bdrv_child_cb_drained_begin,
.drained_end = bdrv_child_cb_drained_end,
+ .inactivate = bdrv_child_cb_inactivate,
};
static void bdrv_backing_attach(BdrvChild *c)
@@ -928,6 +937,7 @@ const BdrvChildRole child_backing = {
.inherit_options = bdrv_backing_options,
.drained_begin = bdrv_child_cb_drained_begin,
.drained_end = bdrv_child_cb_drained_end,
+ .inactivate = bdrv_child_cb_inactivate,
};
static int bdrv_open_flags(BlockDriverState *bs, int flags)
@@ -4038,13 +4048,6 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs,
}
}
- QLIST_FOREACH(child, &bs->children, next) {
- ret = bdrv_inactivate_recurse(child->bs, setting_flag);
- if (ret < 0) {
- return ret;
- }
- }
-
if (setting_flag) {
bs->open_flags |= BDRV_O_INACTIVE;
@@ -4058,6 +4061,14 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs,
}
}
}
+
+ QLIST_FOREACH(child, &bs->children, next) {
+ ret = bdrv_inactivate_recurse(child->bs, setting_flag);
+ if (ret < 0) {
+ return ret;
+ }
+ }
+
return 0;
}
--
1.8.3.1
- [Qemu-block] [PATCH 0/6] block: Fix op blockers for inactive images, Kevin Wolf, 2017/05/04
- [Qemu-block] [PATCH 1/6] migration: Unify block node activation error handling, Kevin Wolf, 2017/05/04
- [Qemu-block] [PATCH 2/6] block: New BdrvChildRole.activate() for blk_resume_after_migration(), Kevin Wolf, 2017/05/04
- [Qemu-block] [PATCH 3/6] block: Drop permissions when migration completes, Kevin Wolf, 2017/05/04
- [Qemu-block] [PATCH 4/6] block: Inactivate parents before children,
Kevin Wolf <=
- [Qemu-block] [PATCH 5/6] block: Fix write/resize permissions for inactive images, Kevin Wolf, 2017/05/04
- [Qemu-block] [PATCH 6/6] file-posix: Remove .bdrv_inactivate/invalidate_cache, Kevin Wolf, 2017/05/04
- Re: [Qemu-block] [PATCH 0/6] block: Fix op blockers for inactive images, Kevin Wolf, 2017/05/09