From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgXMv-0005OI-QV for qemu-devel@nongnu.org; Tue, 21 Oct 2014 07:12:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgXMq-0005oI-Ld for qemu-devel@nongnu.org; Tue, 21 Oct 2014 07:12:49 -0400 Sender: Paolo Bonzini Message-ID: <54463F9B.1030108@redhat.com> Date: Tue, 21 Oct 2014 13:12:27 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <201410211637596311287@sangfor.com> In-Reply-To: <201410211637596311287@sangfor.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 > --- > 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