[PATCH] backup-top: Begin drain earlier

Max Reitz posted 1 patch 4 years, 4 months ago
Test asan failed
Test checkpatch failed
Test FreeBSD failed
Test docker-mingw@fedora failed
Test docker-clang@ubuntu failed
Test docker-quick@centos7 failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20191219182638.104621-1-mreitz@redhat.com
Maintainers: Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
block/backup-top.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] backup-top: Begin drain earlier
Posted by Max Reitz 4 years, 4 months ago
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.)

Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/backup-top.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/backup-top.c b/block/backup-top.c
index 7cdb1f8eba..818d3f26b4 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -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);
-- 
2.23.0


Re: [PATCH] backup-top: Begin drain earlier
Posted by Vladimir Sementsov-Ogievskiy 4 years, 4 months ago
19.12.2019 21:26, Max Reitz wrote:
> 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.)
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Good catch

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

> ---
>   block/backup-top.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/backup-top.c b/block/backup-top.c
> index 7cdb1f8eba..818d3f26b4 100644
> --- a/block/backup-top.c
> +++ b/block/backup-top.c
> @@ -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);
> 


-- 
Best regards,
Vladimir