qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org,
	mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH V3 2/7] qcow2: free allocated cluster on fail in qcow2_write_snapshots()
Date: Wed, 2 Oct 2013 14:07:29 +0200	[thread overview]
Message-ID: <20131002120729.GA12200@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1378695482-29805-3-git-send-email-xiawenc@linux.vnet.ibm.com>

On Mon, Sep 09, 2013 at 10:57:57AM +0800, Wenchao Xia wrote:
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  block/qcow2-snapshot.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
> index 40393b2..9e2d695 100644
> --- a/block/qcow2-snapshot.c
> +++ b/block/qcow2-snapshot.c
> @@ -186,7 +186,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
>      }
>      ret = bdrv_flush(bs);
>      if (ret < 0) {
> -        return ret;
> +        goto fail;
>      }
>  
>      /* The snapshot list position has not yet been updated, so these clusters
> @@ -194,7 +194,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
>      ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, offset,
>                                          s->snapshots_size);
>      if (ret < 0) {
> -        return ret;
> +        goto fail;
>      }
>  
>  
> @@ -278,6 +278,9 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
>      return 0;
>  
>  fail:
> +    /* free the new snapshot table */
> +    qcow2_free_clusters(bs, snapshots_offset, snapshots_size,
> +                        QCOW2_DISCARD_ALWAYS);

It is safer to skip qcow2_free_clusters() when the final
bdrv_pwrite_sync() fails.  We don't know if the header was updated on
disk.  If it was updated, then freeing the clusters may allow them to be
reallocated later (this will cause corruption).

  parent reply	other threads:[~2013-10-02 12:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09  2:57 [Qemu-devel] [PATCH V3 0/7] qcow2: rollback the modification on fail in snapshot creation Wenchao Xia
2013-09-09  2:57 ` [Qemu-devel] [PATCH V3 1/7] qcow2: restore nb_snapshots when " Wenchao Xia
2013-09-30 17:20   ` Eric Blake
2013-10-02 12:26   ` Stefan Hajnoczi
2013-09-09  2:57 ` [Qemu-devel] [PATCH V3 2/7] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Wenchao Xia
2013-09-30 21:16   ` Eric Blake
2013-10-02 12:07   ` Stefan Hajnoczi [this message]
2013-09-09  2:57 ` [Qemu-devel] [PATCH V3 3/7] qcow2: cancel the modification on fail in qcow2_snapshot_create() Wenchao Xia
2013-09-30 21:24   ` Eric Blake
2013-09-09  2:57 ` [Qemu-devel] [PATCH V3 4/7] blkdebug: add debug events for snapshot Wenchao Xia
2013-09-30 21:26   ` Eric Blake
2013-09-09  2:58 ` [Qemu-devel] [PATCH V3 5/7] qcow2: use " Wenchao Xia
2013-09-30 21:41   ` Eric Blake
2013-09-09  2:58 ` [Qemu-devel] [PATCH V3 6/7] qcow2: print message for error path in snapshot creation Wenchao Xia
2013-09-30 22:08   ` Eric Blake
2013-10-02 12:23     ` Stefan Hajnoczi
2013-10-14  7:39       ` Wenchao Xia
2013-09-09  2:58 ` [Qemu-devel] [PATCH V3 7/7] qemu-iotests: add test for qcow2 snapshot Wenchao Xia
2013-09-30 22:28   ` Eric Blake
2013-10-14  7:48     ` Wenchao Xia
2013-09-24  3:36 ` [Qemu-devel] [PATCH V3 0/7] qcow2: rollback the modification on fail in snapshot creation Wenchao Xia
2013-10-02 12:28 ` Stefan Hajnoczi
2013-10-14  7:38   ` Wenchao Xia

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=20131002120729.GA12200@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xiawenc@linux.vnet.ibm.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).