Received: from eggs.gnu.org ([2001:4830:134:3::10]:41317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4Bm0-0008CQ-Gi for qemu-devel@nongnu.org; Tue, 30 Jul 2013 11:23:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4Blp-0005gB-TD for qemu-devel@nongnu.org; Tue, 30 Jul 2013 11:23:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4Blp-0005fr-J4 for qemu-devel@nongnu.org; Tue, 30 Jul 2013 11:23:29 -0400 Date: Tue, 30 Jul 2013 17:23:14 +0200 From: Kevin Wolf Message-ID: <20130730152313.GG2475@dhcp-200-207.str.redhat.com> References: <1374762197-7261-1-git-send-email-pbonzini@redhat.com> <1374762197-7261-13-git-send-email-pbonzini@redhat.com> <20130730144048.GE2475@dhcp-200-207.str.redhat.com> <51F7D89A.3060502@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51F7D89A.3060502@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 12/19] block: return get_block_status data and flags for formats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: pl@kamp.de, qemu-devel@nongnu.org, stefanha@redhat.com Am 30.07.2013 um 17:15 hat Paolo Bonzini geschrieben: > Il 30/07/2013 16:40, Kevin Wolf ha scritto: > > Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben: > >> Reviewed-by: Eric Blake > >> Signed-off-by: Paolo Bonzini > >> --- > >> block/cow.c | 8 +++++++- > >> block/qcow.c | 9 ++++++++- > >> block/qcow2.c | 16 ++++++++++++++-- > >> block/qed.c | 35 ++++++++++++++++++++++++++++------- > >> block/sheepdog.c | 2 +- > >> block/vdi.c | 13 ++++++++++++- > >> block/vmdk.c | 19 ++++++++++++++++++- > >> block/vvfat.c | 11 ++++++----- > >> 8 files changed, 94 insertions(+), 19 deletions(-) > >> > >> diff --git a/block/cow.c b/block/cow.c > >> index e738b96..1e90413 100644 > >> --- a/block/cow.c > >> +++ b/block/cow.c > >> @@ -194,7 +194,13 @@ static int coroutine_fn cow_co_is_allocated(BlockDriverState *bs, > >> static int64_t coroutine_fn cow_co_get_block_status(BlockDriverState *bs, > >> int64_t sector_num, int nb_sectors, int *num_same) > >> { > >> - return cow_co_is_allocated(bs, sector_num, nb_sectors, num_same); > >> + BDRVCowState *s = bs->opaque; > >> + int ret = cow_co_is_allocated(bs, sector_num, nb_sectors, num_same); > >> + int64_t offset = s->cow_sectors_offset + (sector_num << BDRV_SECTOR_BITS); > >> + if (ret < 0) { > >> + return ret; > >> + } > >> + return (ret ? BDRV_BLOCK_DATA : 0) | offset | BDRV_BLOCK_OFFSET_VALID; > >> } > >> > >> static int cow_update_bitmap(BlockDriverState *bs, int64_t sector_num, > >> diff --git a/block/qcow.c b/block/qcow.c > >> index acd1aeb..1a65822 100644 > >> --- a/block/qcow.c > >> +++ b/block/qcow.c > >> @@ -410,7 +410,14 @@ static int64_t coroutine_fn qcow_co_get_block_status(BlockDriverState *bs, > >> if (n > nb_sectors) > >> n = nb_sectors; > >> *pnum = n; > >> - return (cluster_offset != 0); > >> + if (!cluster_offset) { > >> + return 0; > > > > If you take your comment in patch 11 serious, you should return > > bs->backing_hd ? 0 : BDRV_BLOCK_ZERO instead. (I think it would be > > useful behaviour, too, because knowing that a sector is zero enables > > optimisations in several places.) > > > > Of course, this is something that could be done in the block.c > > implementation of bdrv_co_get_block_status() instead of each single > > driver. > > And it is, in patch 15 ("block: use bdrv_has_zero_init to return > BDRV_BLOCK_ZERO"). :) Should I reorder the patches? No, I don't mind. I did look at the final state, but I missed it because I expected something with bs->backing_hd instead of bdrv_has_zero_init() and didn't remember that the former is already included in the latter. Kevin