From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2qU0-00059h-Qc for qemu-devel@nongnu.org; Tue, 17 May 2016 21:41:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2kXk-0006XJ-0a for qemu-devel@nongnu.org; Tue, 17 May 2016 15:20:39 -0400 Received: from mail-db5eur01on0131.outbound.protection.outlook.com ([104.47.2.131]:58048 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2kXj-0006Wt-8M for qemu-devel@nongnu.org; Tue, 17 May 2016 15:20:35 -0400 References: <1463503863-19009-1-git-send-email-kwolf@redhat.com> <1463503863-19009-3-git-send-email-kwolf@redhat.com> From: "Denis V. Lunev" Message-ID: <573B6EF9.1040406@openvz.org> Date: Tue, 17 May 2016 22:20:25 +0300 MIME-Version: 1.0 In-Reply-To: <1463503863-19009-3-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/3] qcow2: Fix write_zeroes with partially allocated backing file cluster List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org 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 > --- > 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 I have had this kludge in the revision one and I have lost them in revision 3 :(