qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: mreitz@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] qcow2: Fix write_zeroes with partially allocated backing file cluster
Date: Tue, 17 May 2016 22:20:25 +0300	[thread overview]
Message-ID: <573B6EF9.1040406@openvz.org> (raw)
In-Reply-To: <1463503863-19009-3-git-send-email-kwolf@redhat.com>

On 05/17/2016 07:51 PM, Kevin Wolf wrote:
> In order to correctly check whether a given cluster is read as zero, we
> don't only need to check whether bdrv_get_block_status_above() sets
> BDRV_BLOCK_ZERO, but also if all sectors for the whole cluster have the
> same status.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block/qcow2.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index a6012dc..c197ff3 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -2412,7 +2412,7 @@ static bool is_zero_cluster(BlockDriverState *bs, int64_t start)
>       BlockDriverState *file;
>       int64_t res = bdrv_get_block_status_above(bs, NULL, start,
>                                                 s->cluster_sectors, &nr, &file);
> -    return res >= 0 && (res & BDRV_BLOCK_ZERO);
> +    return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == s->cluster_sectors;
>   }
>   
>   static bool is_zero_cluster_top_locked(BlockDriverState *bs, int64_t start)
> @@ -2423,6 +2423,7 @@ static bool is_zero_cluster_top_locked(BlockDriverState *bs, int64_t start)
>       int ret;
>   
>       ret = qcow2_get_cluster_offset(bs, start << BDRV_SECTOR_BITS, &nr, &off);
> +    assert(nr == s->cluster_sectors);
>       return ret == QCOW2_CLUSTER_UNALLOCATED || ret == QCOW2_CLUSTER_ZERO;
>   }
>   
Reviewed-by: Denis V. Lunev <den@openvz.org>

I have had this kludge in the revision one and I have lost them in 
revision 3 :(

  parent reply	other threads:[~2016-05-18  1:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17 16:51 [Qemu-devel] [PATCH 0/3] qcow2: write_zeroes corruption fixes and tests Kevin Wolf
2016-05-17 16:51 ` [Qemu-devel] [PATCH 1/3] qcow2: fix condition in is_zero_cluster Kevin Wolf
2016-05-17 17:25   ` Eric Blake
2016-05-17 16:51 ` [Qemu-devel] [PATCH 2/3] qcow2: Fix write_zeroes with partially allocated backing file cluster Kevin Wolf
2016-05-17 17:22   ` Eric Blake
2016-05-17 19:20   ` Denis V. Lunev [this message]
2016-05-17 16:51 ` [Qemu-devel] [PATCH 3/3] qemu-iotests: Some more write_zeroes tests Kevin Wolf
2016-05-17 20:35   ` Eric Blake
2016-05-18 10:09     ` Kevin Wolf
2016-05-18 12:27     ` [Qemu-devel] [PATCH v2 " Kevin Wolf
2016-05-18 14:12       ` Eric Blake
2016-05-18 14:22         ` 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=573B6EF9.1040406@openvz.org \
    --to=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).