qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem
@ 2014-10-21  8:38 Zhang Haoyu
  2014-10-21 11:12 ` Paolo Bonzini
  2014-10-28 15:18 ` Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: Zhang Haoyu @ 2014-10-21  8:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, qemu-stable, Stefan Hajnoczi, Max Reitz

If there are still pending i/o while deleting snapshot,
because deleting snapshot is done in non-coroutine context, and
the pending i/o read/write (bdrv_co_do_rw) is done in coroutine context,
so it's possible to cause concurrency problem between above two operations.
Add bdrv_drain_all() to bdrv_snapshot_delete() to avoid this problem.

Signed-off-by: Zhang Haoyu <zhanghy@sangfor.com>
---
 block/snapshot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/snapshot.c b/block/snapshot.c
index 85c52ff..ebc386a 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -236,6 +236,10 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
         error_setg(errp, "snapshot_id and name are both NULL");
         return -EINVAL;
     }
+
+    /* drain all pending i/o before deleting snapshot */
+    bdrv_drain_all();
+
     if (drv->bdrv_snapshot_delete) {
         return drv->bdrv_snapshot_delete(bs, snapshot_id, name, errp);
     }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem
  2014-10-21  8:38 [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem Zhang Haoyu
@ 2014-10-21 11:12 ` Paolo Bonzini
  2014-10-28 15:18 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2014-10-21 11:12 UTC (permalink / raw)
  To: Zhang Haoyu, qemu-devel
  Cc: Kevin Wolf, qemu-stable, Stefan Hajnoczi, Max Reitz



On 10/21/2014 10:38 AM, Zhang Haoyu wrote:
> If there are still pending i/o while deleting snapshot,
> because deleting snapshot is done in non-coroutine context, and
> the pending i/o read/write (bdrv_co_do_rw) is done in coroutine context,
> so it's possible to cause concurrency problem between above two operations.
> Add bdrv_drain_all() to bdrv_snapshot_delete() to avoid this problem.
>
> Signed-off-by: Zhang Haoyu <zhanghy@sangfor.com>
> ---
>   block/snapshot.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/block/snapshot.c b/block/snapshot.c
> index 85c52ff..ebc386a 100644
> --- a/block/snapshot.c
> +++ b/block/snapshot.c
> @@ -236,6 +236,10 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
>           error_setg(errp, "snapshot_id and name are both NULL");
>           return -EINVAL;
>       }
> +
> +    /* drain all pending i/o before deleting snapshot */
> +    bdrv_drain_all();
> +
>       if (drv->bdrv_snapshot_delete) {
>           return drv->bdrv_snapshot_delete(bs, snapshot_id, name, errp);
>       }
>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem
  2014-10-21  8:38 [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem Zhang Haoyu
  2014-10-21 11:12 ` Paolo Bonzini
@ 2014-10-28 15:18 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2014-10-28 15:18 UTC (permalink / raw)
  To: Zhang Haoyu
  Cc: Kevin Wolf, Max Reitz, qemu-devel, Stefan Hajnoczi, qemu-stable

[-- Attachment #1: Type: text/plain, Size: 640 bytes --]

On Tue, Oct 21, 2014 at 04:38:01PM +0800, Zhang Haoyu wrote:
> If there are still pending i/o while deleting snapshot,
> because deleting snapshot is done in non-coroutine context, and
> the pending i/o read/write (bdrv_co_do_rw) is done in coroutine context,
> so it's possible to cause concurrency problem between above two operations.
> Add bdrv_drain_all() to bdrv_snapshot_delete() to avoid this problem.
> 
> Signed-off-by: Zhang Haoyu <zhanghy@sangfor.com>
> ---
>  block/snapshot.c | 4 ++++
>  1 file changed, 4 insertions(+)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-28 15:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21  8:38 [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem Zhang Haoyu
2014-10-21 11:12 ` Paolo Bonzini
2014-10-28 15:18 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).