[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 28/30] block: Activate recursively even for already active nodes
From: |
Kevin Wolf |
Subject: |
[PULL 28/30] block: Activate recursively even for already active nodes |
Date: |
Thu, 19 Dec 2019 18:24:39 +0100 |
bdrv_invalidate_cache_all() assumes that all nodes in a given subtree
are either active or inactive when it starts. Therefore, as soon as it
arrives at an already active node, it stops.
However, this assumption is wrong. For example, it's possible to take a
snapshot of an inactive node, which results in an active overlay over an
inactive backing file. The active overlay is probably also the root node
of an inactive BlockBackend (blk->disable_perm == true).
In this case, bdrv_invalidate_cache_all() does not need to do anything
to activate the overlay node, but it still needs to recurse into the
children and the parents to make sure that after returning success,
really everything is activated.
Cc: address@hidden
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block.c | 50 ++++++++++++++++++++++++--------------------------
1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/block.c b/block.c
index 73029fad64..1b6f7c86e8 100644
--- a/block.c
+++ b/block.c
@@ -5335,10 +5335,6 @@ static void coroutine_fn
bdrv_co_invalidate_cache(BlockDriverState *bs,
return;
}
- if (!(bs->open_flags & BDRV_O_INACTIVE)) {
- return;
- }
-
QLIST_FOREACH(child, &bs->children, next) {
bdrv_co_invalidate_cache(child->bs, &local_err);
if (local_err) {
@@ -5360,34 +5356,36 @@ static void coroutine_fn
bdrv_co_invalidate_cache(BlockDriverState *bs,
* just keep the extended permissions for the next time that an activation
* of the image is tried.
*/
- bs->open_flags &= ~BDRV_O_INACTIVE;
- bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
- ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, &local_err);
- if (ret < 0) {
- bs->open_flags |= BDRV_O_INACTIVE;
- error_propagate(errp, local_err);
- return;
- }
- bdrv_set_perm(bs, perm, shared_perm);
-
- if (bs->drv->bdrv_co_invalidate_cache) {
- bs->drv->bdrv_co_invalidate_cache(bs, &local_err);
- if (local_err) {
+ if (bs->open_flags & BDRV_O_INACTIVE) {
+ bs->open_flags &= ~BDRV_O_INACTIVE;
+ bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
+ ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL,
&local_err);
+ if (ret < 0) {
bs->open_flags |= BDRV_O_INACTIVE;
error_propagate(errp, local_err);
return;
}
- }
+ bdrv_set_perm(bs, perm, shared_perm);
- FOR_EACH_DIRTY_BITMAP(bs, bm) {
- bdrv_dirty_bitmap_skip_store(bm, false);
- }
+ if (bs->drv->bdrv_co_invalidate_cache) {
+ bs->drv->bdrv_co_invalidate_cache(bs, &local_err);
+ if (local_err) {
+ bs->open_flags |= BDRV_O_INACTIVE;
+ error_propagate(errp, local_err);
+ return;
+ }
+ }
- ret = refresh_total_sectors(bs, bs->total_sectors);
- if (ret < 0) {
- bs->open_flags |= BDRV_O_INACTIVE;
- error_setg_errno(errp, -ret, "Could not refresh total sector count");
- return;
+ FOR_EACH_DIRTY_BITMAP(bs, bm) {
+ bdrv_dirty_bitmap_skip_store(bm, false);
+ }
+
+ ret = refresh_total_sectors(bs, bs->total_sectors);
+ if (ret < 0) {
+ bs->open_flags |= BDRV_O_INACTIVE;
+ error_setg_errno(errp, -ret, "Could not refresh total sector
count");
+ return;
+ }
}
QLIST_FOREACH(parent, &bs->parents, next_parent) {
--
2.20.1
- [PULL 19/30] iotests: 255: Drop blockdev_create(), (continued)
- [PULL 19/30] iotests: 255: Drop blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 21/30] iotests: 210: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 22/30] iotests: 212: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 23/30] iotests: 213: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 20/30] iotests: 206: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 25/30] iotests: 266: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 24/30] iotests: 237: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 30/30] iotests: Test external snapshot with VM state, Kevin Wolf, 2019/12/19
- [PULL 27/30] iotests: 211: Remove duplication with VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 29/30] hmp: Allow using qdev ID for qemu-io command, Kevin Wolf, 2019/12/19
- [PULL 28/30] block: Activate recursively even for already active nodes,
Kevin Wolf <=
- [PULL 26/30] iotests: 207: Remove duplication with VM.blockdev_create(), Kevin Wolf, 2019/12/19