From nobody Mon Feb 9 06:49:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560378202; cv=none; d=zoho.com; s=zohoarc; b=SHa9dgIHi671uORTTZzprEhA8YsNFpSC1KUXTSnvQaRdccLkE77i+eIZSX9NaWPkqAAh42FMSCiJeT/YvBBXflxAouWSUkIHmLRGpNu1YHATBXlrivpV14CaCkh1EGdoQJJY3BV/l7vkE35NLim9nKeL3mlJyqkpc3lCnqnPLfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560378202; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=s7TSZqyAxd1uKHN9P8llmemmcc+h+/g8mMtRp9/5Jks=; b=J+PwIwFdU/uEbubR/xNK3kh1foALNpOijUcOAENi9ok6aL26O75DBI1/vgSIb08tIAVrk7s1w7wklaXGyKuyIeHkRpF9gpIw8Oab5LRC/TTQCT2EmyKCAk5jqipjZg719J60ZLweZFsKpg7UBNjvqfnntJb034sCekRwmbrIR8A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560378202068849.863190255574; Wed, 12 Jun 2019 15:23:22 -0700 (PDT) Received: from localhost ([::1]:35466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBeK-000075-Tb for importer@patchew.org; Wed, 12 Jun 2019 18:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45570) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBS8-0007dc-O7 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:10:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbBS7-0007hh-Kc for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:10:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbBS5-0007fY-2p; Wed, 12 Jun 2019 18:10:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 398762EF170; Wed, 12 Jun 2019 22:10:40 +0000 (UTC) Received: from localhost (unknown [10.40.205.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC0CD6014E; Wed, 12 Jun 2019 22:10:39 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 13 Jun 2019 00:09:35 +0200 Message-Id: <20190612221004.2317-14-mreitz@redhat.com> In-Reply-To: <20190612221004.2317-1-mreitz@redhat.com> References: <20190612221004.2317-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 12 Jun 2019 22:10:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 13/42] block: Use CAFs in block status functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Use the child access functions in the block status inquiry functions as appropriate. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/block/io.c b/block/io.c index 73ade04834..53aabf86b5 100644 --- a/block/io.c +++ b/block/io.c @@ -2150,11 +2150,12 @@ static int coroutine_fn bdrv_co_block_status(BlockD= riverState *bs, if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { ret |=3D BDRV_BLOCK_ALLOCATED; } else if (want_zero) { + BlockDriverState *cow_bs =3D bdrv_filtered_cow_bs(bs); + if (bdrv_unallocated_blocks_are_zero(bs)) { ret |=3D BDRV_BLOCK_ZERO; - } else if (bs->backing) { - BlockDriverState *bs2 =3D bs->backing->bs; - int64_t size2 =3D bdrv_getlength(bs2); + } else if (cow_bs) { + int64_t size2 =3D bdrv_getlength(cow_bs); =20 if (size2 >=3D 0 && offset >=3D size2) { ret |=3D BDRV_BLOCK_ZERO; @@ -2220,7 +2221,7 @@ static int coroutine_fn bdrv_co_block_status_above(Bl= ockDriverState *bs, bool first =3D true; =20 assert(bs !=3D base); - for (p =3D bs; p !=3D base; p =3D backing_bs(p)) { + for (p =3D bs; p !=3D base; p =3D bdrv_filtered_bs(p)) { ret =3D bdrv_co_block_status(p, want_zero, offset, bytes, pnum, ma= p, file); if (ret < 0) { @@ -2306,7 +2307,7 @@ int bdrv_block_status_above(BlockDriverState *bs, Blo= ckDriverState *base, int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) { - return bdrv_block_status_above(bs, backing_bs(bs), + return bdrv_block_status_above(bs, bdrv_filtered_bs(bs), offset, bytes, pnum, map, file); } =20 @@ -2316,9 +2317,9 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *= bs, int64_t offset, int ret; int64_t dummy; =20 - ret =3D bdrv_common_block_status_above(bs, backing_bs(bs), false, offs= et, - bytes, pnum ? pnum : &dummy, NULL, - NULL); + ret =3D bdrv_common_block_status_above(bs, bdrv_filtered_bs(bs), false, + offset, bytes, pnum ? pnum : &dum= my, + NULL, NULL); if (ret < 0) { return ret; } @@ -2372,7 +2373,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, n =3D pnum_inter; } =20 - intermediate =3D backing_bs(intermediate); + intermediate =3D bdrv_filtered_bs(intermediate); } =20 *pnum =3D n; --=20 2.21.0