From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjPJq-0001IT-Eg for qemu-devel@nongnu.org; Mon, 12 Sep 2016 07:22:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjPJl-0001tW-9r for qemu-devel@nongnu.org; Mon, 12 Sep 2016 07:22:33 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:41636 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjPJk-0001tF-TX for qemu-devel@nongnu.org; Mon, 12 Sep 2016 07:22:29 -0400 References: <1473424308-19812-1-git-send-email-den@openvz.org> <1473424308-19812-2-git-send-email-den@openvz.org> From: Vladimir Sementsov-Ogievskiy Message-ID: <57D68FE0.4050304@virtuozzo.com> Date: Mon, 12 Sep 2016 14:22:08 +0300 MIME-Version: 1.0 In-Reply-To: <1473424308-19812-2-git-send-email-den@openvz.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] block: sync bdrv_co_get_block_status_above() with bdrv_is_allocated_above() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" , qemu-block@nongnu.org Cc: Kevin Wolf , Fam Zheng , Jeff Cody , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi On 09.09.2016 15:31, Denis V. Lunev wrote: > They should work very similar, covering same areas if backing store is > shorter than the image. This change is necessary for the followup patch > switching to bdrv_get_block_status_above() in mirror to avoid assert > in check_block. > > Signed-off-by: Denis V. Lunev > CC: Stefan Hajnoczi > CC: Fam Zheng > CC: Kevin Wolf > CC: Max Reitz > CC: Jeff Cody > --- > block/io.c | 26 ++++++++++++++++++++------ > 1 file changed, 20 insertions(+), 6 deletions(-) > > diff --git a/block/io.c b/block/io.c > index 420944d..0422123 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -1745,14 +1745,28 @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, > > assert(bs != base); > for (p = bs; p != base; p = backing_bs(p)) { > - ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum, file); > - if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) { > - break; > + int sc; > + ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, &sc, file); > + if (ret < 0) { > + return ret; > + } else if (ret & BDRV_BLOCK_ALLOCATED) { > + *pnum = sc; > + return ret; > + } > + > + /* > + * [sector_num, nb_sectors] is unallocated on top but intermediate > + * might have > + * > + * [sector_num+x, nr_sectors] allocated. > + */ this comment is unrelated here, as you reduce nb_sectors (used in bdrv_co_get_block_status() above) in the following "if" > + if (nb_sectors > sc && > + (p == bs || sector_num + sc < p->total_sectors)) { > + nb_sectors = sc; > } > - /* [sector_num, pnum] unallocated on this layer, which could be only > - * the first part of [sector_num, nb_sectors]. */ > - nb_sectors = MIN(nb_sectors, *pnum); > } > + > + *pnum = nb_sectors; > return ret; > } > -- Best regards, Vladimir