From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKPND-0003zk-O6 for qemu-devel@nongnu.org; Fri, 13 Sep 2013 05:09:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKPN3-0007L5-Md for qemu-devel@nongnu.org; Fri, 13 Sep 2013 05:09:07 -0400 Received: from ssl.dlhnet.de ([91.198.192.8]:47198 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKPN3-0007L0-G0 for qemu-devel@nongnu.org; Fri, 13 Sep 2013 05:08:57 -0400 Message-ID: <5232D62A.2030506@dlhnet.de> Date: Fri, 13 Sep 2013 11:08:58 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1378481953-23099-1-git-send-email-stefanha@redhat.com> <1378481953-23099-40-git-send-email-stefanha@redhat.com> <5232C61F.4010502@kamp.de> In-Reply-To: <5232C61F.4010502@kamp.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL 39/42] block: look for zero blocks in bs->file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Anthony Liguori , Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi On 13.09.2013 10:00, Peter Lieven wrote: > On 06.09.2013 17:39, Stefan Hajnoczi wrote: >> From: Paolo Bonzini >> >> Reviewed-by: Eric Blake >> Signed-off-by: Paolo Bonzini >> Signed-off-by: Stefan Hajnoczi >> --- >> block.c | 16 +++++++++++++++- >> 1 file changed, 15 insertions(+), 1 deletion(-) >> >> diff --git a/block.c b/block.c >> index 3c39769..a325efc 100644 >> --- a/block.c >> +++ b/block.c >> @@ -3075,7 +3075,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, >> { >> int64_t length; >> int64_t n; >> - int64_t ret; >> + int64_t ret, ret2; >> length = bdrv_getlength(bs); >> if (length < 0) { >> @@ -3117,6 +3117,20 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, >> } >> } >> } >> + >> + if (bs->file && >> + (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && >> + (ret & BDRV_BLOCK_OFFSET_VALID)) { >> + ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS, >> + *pnum, pnum); >> + if (ret2 >= 0) { >> + /* Ignore errors. This is just providing extra information, it >> + * is useful but not necessary. >> + */ >> + ret |= (ret2 & BDRV_BLOCK_ZERO); >> + } >> + } >> + >> return ret; >> } > for allocated blocks in iscsi this actually leads to 2 call outs to iscsi_get_block_status. > > because the raw driver passes the get_block_status request to bs->file. > correct patch? @@ -3119,9 +3167,8 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, } } - if (bs->file && - (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && - (ret & BDRV_BLOCK_OFFSET_VALID)) { + if (bs->file && (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && + (ret & BDRV_BLOCK_OFFSET_VALID) && bs->drv != bdrv_find_format("raw")) { ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS, *pnum, pnum); if (ret2 >= 0) {