From: Zhang Haoyu <zhan...@sangfor.com> 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> (cherry picked from commit 3432a1929ee18e08787ce35476abd74f2c93a17c) Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com> --- block/snapshot.c | 4 ++++ 1 file changed, 4 insertions(+) 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); } -- 1.9.1