block: Ensure correct order when dropping intermediate images
PATCH 1/1 block: Ensure correct order when dropping intermediate images
Given a chain of images like [A] <- [B] <- [C] <- [D] <- [E], where
[E] is the active (topmost) image, if we want to remove [B] and [C] we have to do it before linking [A] and [D].
When [A] is set as the backing image of [D] all its operations are blocked, but removing [B] afterwards would undo those changes, since
[B] would still be connected to [A].
This would result in a situation where the backing image [A] has all its operations unblocked.
--- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block.c +2 -1
@@ -2624,13 +2624,14 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,if (ret) { goto exit; } -bdrv_set_backing_hd (new_top_bs, base_bs); +bdrv_set_backing_hd (new_top_bs,NULL ); QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) {/* so that bdrv_close() does not recursively close the chain */ bdrv_set_backing_hd (intermediate_state->bs,NULL );bdrv_unref (intermediate_state->bs); } +bdrv_set_backing_hd (new_top_bs, base_bs); ret =0 ; exit:
Signature · 1 line
2.1.4
Quoted 10 lines · Alberto Garcia
Given a chain of images like [A] <- [B] <- [C] <- [D] <- [E], where
[E] is the active (topmost) image, if we want to remove [B] and [C] we have to do it before linking [A] and [D].When [A] is set as the backing image of [D] all its operations are blocked, but removing [B] afterwards would undo those changes, since
[B] would still be connected to [A].This would result in a situation where the backing image [A] has all its operations unblocked.
Op blockers are linked to a unique Error object. When B's backing_hd is set to NULL only B->backing_blocker is unblocked but new_top_bs->backing_blocker is still in place. This means operations are still blocked.
How do you reproduce this problem? Do you have a test case that can be added to tests/qemu-iotests/?
Quoted 29 lines
Signed-off-by Alberto Garcia <[email protected]>--- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)block.c +2
-1@@ -2624,13 +2624,14 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,if (ret) { goto exit; } -bdrv_set_backing_hd (new_top_bs, base_bs); +bdrv_set_backing_hd (new_top_bs,NULL ); QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) {/* so that bdrv_close() does not recursively close the chain */ bdrv_set_backing_hd (intermediate_state->bs,NULL );bdrv_unref (intermediate_state->bs); } +bdrv_set_backing_hd (new_top_bs, base_bs); ret =0 ; exit:Signature · 1 line
2.1.4
Quoted 4 lines · Stefan Hajnoczi
Op blockers are linked to a unique Error object. When B's
backing_hdis set to NULL onlyB->backing_blockeris unblocked butnew_top_bs->backing_blockeris still in place. This means operations are still blocked.
You're actually right, sorry for the noise!
Berto