Public bug reported:

  I found the vm disk corruption after snapshot deletion sometimes(the 
probability is very low, I'm afraid i can't reproduce it). And I found there is 
a patch for it as follow, but I'm not sure whether the patch repaired the bug. 
  Drain disk before snapshot deletion can't guarantee anything, there is still 
pending IO in snapshot-deletion process. Anyone can help?

author  Zhang Haoyu <zhan...@sangfor.com>       2014-10-21 16:38:01 +0800
committer       Stefan Hajnoczi <stefa...@redhat.com>   2014-11-03 09:48:42 
+0000
commit  3432a1929ee18e08787ce35476abd74f2c93a17c (patch)
tree    13a81c0a46707d91622f1593ccf7b926935371fd /block/snapshot.c
parent  573742a5431a99ceaba6968ae269cee247727cce (diff)
snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency 
problem
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 <zhan...@sangfor.com>
Reviewed-by: Paolo Bonzini <pbonz...@redhat.com>
Message-id: 201410211637596311...@sangfor.com
Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>
Diffstat (limited to 'block/snapshot.c')
-rw-r--r--      block/snapshot.c        4       
1 files changed, 4 insertions, 0 deletions
diff --git a/block/snapshot.c b/block/snapshot.c
index 85c52ff..698e1a1 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);
     }

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1709025

Title:
  Disk corrupted after snapshot deletion

Status in QEMU:
  New

Bug description:
    I found the vm disk corruption after snapshot deletion sometimes(the 
probability is very low, I'm afraid i can't reproduce it). And I found there is 
a patch for it as follow, but I'm not sure whether the patch repaired the bug. 
    Drain disk before snapshot deletion can't guarantee anything, there is 
still pending IO in snapshot-deletion process. Anyone can help?

  author        Zhang Haoyu <zhan...@sangfor.com>       2014-10-21 16:38:01 
+0800
  committer     Stefan Hajnoczi <stefa...@redhat.com>   2014-11-03 09:48:42 
+0000
  commit        3432a1929ee18e08787ce35476abd74f2c93a17c (patch)
  tree  13a81c0a46707d91622f1593ccf7b926935371fd /block/snapshot.c
  parent        573742a5431a99ceaba6968ae269cee247727cce (diff)
  snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency 
problem
  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 <zhan...@sangfor.com>
  Reviewed-by: Paolo Bonzini <pbonz...@redhat.com>
  Message-id: 201410211637596311...@sangfor.com
  Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>
  Diffstat (limited to 'block/snapshot.c')
  -rw-r--r--    block/snapshot.c        4       
  1 files changed, 4 insertions, 0 deletions
  diff --git a/block/snapshot.c b/block/snapshot.c
  index 85c52ff..698e1a1 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);
       }

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1709025/+subscriptions

Reply via email to