Skip to contentSkip to conversation

backup-top: Begin drain earlier

PATCH In review Max Reitz 2 participants 2 messages Dec 19, 2019 – Dec 20, 2019 Block layer

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 backup-top: Begin drain earlier

When dropping backup-top, we need to drain the node before freeing the BlockCopyState. Otherwise, requests may still be in flight and then the assertion in shres_destroy() will fail.

(This becomes visible in intermittent failure of 056.)

---
 block/backup-top.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/backup-top.c +2 -2
index 7cdb1f8eba..818d3f26b4 100644
@@ -257,12 +257,12 @@ void bdrv_backup_top_drop(BlockDriverState *bs)
     BDRVBackupTopState *s = bs->opaque;
     AioContext *aio_context = bdrv_get_aio_context(bs);
 
-    block_copy_state_free(s->bcs);
-
     aio_context_acquire(aio_context);
 
     bdrv_drained_begin(bs);
 
+    block_copy_state_free(s->bcs);
+
     s->active = false;
     bdrv_child_refresh_perms(bs, bs->backing, &error_abort);
     bdrv_replace_node(bs, backing_bs(bs), &error_abort);
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Max Reitz

When dropping backup-top, we need to drain the node before freeing the BlockCopyState. Otherwise, requests may still be in flight and then the assertion in shres_destroy() will fail.

(This becomes visible in intermittent failure of 056.)

Good catch

Quoted 24 lines
---
  block/backup-top.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
block/backup-top.c +2 -2
index 7cdb1f8eba..818d3f26b4 100644
@@ -257,12 +257,12 @@ void bdrv_backup_top_drop(BlockDriverState *bs)
      BDRVBackupTopState *s = bs->opaque;
      AioContext *aio_context = bdrv_get_aio_context(bs);
 
-    block_copy_state_free(s->bcs);
-
      aio_context_acquire(aio_context);
 
      bdrv_drained_begin(bs);
 
+    block_copy_state_free(s->bcs);
+
      s->active = false;
      bdrv_child_refresh_perms(bs, bs->backing, &error_abort);
      bdrv_replace_node(bs, backing_bs(bs), &error_abort);
Signature · 2 lines
Best regards,
Vladimir