From: Paolo Bonzini <pbonzini@redhat.com>
To: Zhang Haoyu <zhanghy@sangfor.com>, qemu-devel <qemu-devel@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-stable <qemu-stable@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH bugfix] snapshot: add bdrv_drain_all() to bdrv_snapshot_delete() to avoid concurrency problem
Date: Tue, 21 Oct 2014 13:12:27 +0200 [thread overview]
Message-ID: <54463F9B.1030108@redhat.com> (raw)
In-Reply-To: <201410211637596311287@sangfor.com>
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>
next prev parent reply other threads:[~2014-10-21 11:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2014-10-28 15:18 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54463F9B.1030108@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=stefanha@redhat.com \
--cc=zhanghy@sangfor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).