Skip to contentSkip to conversation

commit: get the overlay node before manipulating the backing chain

PATCH Applied Alberto Garcia 2 participants 2 messages Aug 22, 2016 – Aug 24, 2016 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commit: get the overlay node before manipulating the backing chain

The 'block-commit' command has a 'top' parameter to specify the topmost node from which the data is going to be copied.

[E] <- [D] <- [C] <- [B] <- [A]

In this case if [C] is the top node then this is the result:

[E] <- [B] <- [A]

[B] must be modified so its backing image string points to [E] instead of [C]. commit_start() takes care of reopening [B] in read-write mode, and commit_complete() puts it back in read-only mode once the operation has finished.

In order to find [B] (the overlay node) we look for the node that has
[C] (the top node) as its backing image. However in commit_complete() we're doing it after [C] has been removed from the chain, so [B] is never found and remains in read-write mode.

This patch gets the overlay node before the backing chain is manipulated.

---
 block/commit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/commit.c +1 -2
index 553e18d..a02539b 100644
@@ -83,7 +83,7 @@ static void commit_complete(BlockJob *job, void *opaque)
     BlockDriverState *active = s->active;
     BlockDriverState *top = blk_bs(s->top);
     BlockDriverState *base = blk_bs(s->base);
-    BlockDriverState *overlay_bs;
+    BlockDriverState *overlay_bs = bdrv_find_overlay(active, top);
     int ret = data->ret;
 
     if (!block_job_is_cancelled(&s->common) && ret == 0) {
@@ -97,7 +97,6 @@ static void commit_complete(BlockJob *job, void *opaque)
     if (s->base_flags != bdrv_get_flags(base)) {
         bdrv_reopen(base, s->base_flags, NULL);
     }
-    overlay_bs = bdrv_find_overlay(active, top);
     if (overlay_bs && s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {
         bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL);
     }
Signature · 1 line
2.8.1
Applied
#1 lore raw
Quoted 14 lines · Alberto Garcia

The 'block-commit' command has a 'top' parameter to specify the topmost node from which the data is going to be copied.

   [E] <- [D] <- [C] <- [B] <- [A]

In this case if [C] is the top node then this is the result:

   [E] <- [B] <- [A]

[B] must be modified so its backing image string points to [E] instead of [C]. commit_start() takes care of reopening [B] in read-write mode, and commit_complete() puts it back in read-only mode once the operation has finished.

Quoted 4 lines

In order to find [B] (the overlay node) we look for the node that has
[C] (the top node) as its backing image. However in commit_complete() we're doing it after [C] has been removed from the chain, so [B] is never found and remains in read-write mode.

That's... Unfortunate.

Quoted 7 lines

This patch gets the overlay node before the backing chain is manipulated.

---
 block/commit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Thanks, applied to my block-next tree:

https://github.com/XanClic/qemu/commits/block-next

Max