qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: use drained section around bdrv_snapshot_delete
Date: Thu, 17 Dec 2015 09:55:55 +0800	[thread overview]
Message-ID: <20151217015555.GD20007@ad.usersys.redhat.com> (raw)
In-Reply-To: <1450290827-30508-3-git-send-email-pbonzini@redhat.com>

On Wed, 12/16 19:33, Paolo Bonzini wrote:
> Do not use bdrv_drain, since by itself it does not guarantee
> anything.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/snapshot.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/block/snapshot.c b/block/snapshot.c
> index 6e9fa8d..2d86b88 100644
> --- a/block/snapshot.c
> +++ b/block/snapshot.c
> @@ -229,6 +229,8 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
>                           Error **errp)
>  {
>      BlockDriver *drv = bs->drv;
> +    int ret;
> +
>      if (!drv) {
>          error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
>          return -ENOMEDIUM;
> @@ -239,18 +241,21 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
>      }
>  
>      /* drain all pending i/o before deleting snapshot */
> -    bdrv_drain(bs);
> +    bdrv_drained_begin(bs);
>  
>      if (drv->bdrv_snapshot_delete) {
> -        return drv->bdrv_snapshot_delete(bs, snapshot_id, name, errp);
> +        ret = drv->bdrv_snapshot_delete(bs, snapshot_id, name, errp);
> +    } else if (bs->file) {
> +        ret = bdrv_snapshot_delete(bs->file->bs, snapshot_id, name, errp);
> +    } else {
> +        error_setg(errp, "Block format '%s' used by device '%s' "
> +                   "does not support internal snapshot deletion",
> +                   drv->format_name, bdrv_get_device_name(bs));
> +        ret = -ENOTSUP;
>      }
> -    if (bs->file) {
> -        return bdrv_snapshot_delete(bs->file->bs, snapshot_id, name, errp);
> -    }
> -    error_setg(errp, "Block format '%s' used by device '%s' "
> -               "does not support internal snapshot deletion",
> -               drv->format_name, bdrv_get_device_name(bs));
> -    return -ENOTSUP;
> +
> +    bdrv_drained_end(bs);
> +    return ret;
>  }
>  
>  int bdrv_snapshot_delete_by_id_or_name(BlockDriverState *bs,
> -- 
> 2.5.0
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>

  reply	other threads:[~2015-12-17  1:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16 18:33 [Qemu-devel] [PATCH] block: use drained section around bdrv_snapshot_delete Paolo Bonzini
2015-12-17  1:55 ` Fam Zheng [this message]
2015-12-18 12:11   ` Kevin Wolf

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=20151217015555.GD20007@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).