From nobody Sun Feb 8 20:59:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499961429454286.5858104249796; Thu, 13 Jul 2017 08:57:09 -0700 (PDT) Received: from localhost ([::1]:60849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVgUG-0006jV-44 for importer@patchew.org; Thu, 13 Jul 2017 11:57:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVgLL-0004yv-1B for qemu-devel@nongnu.org; Thu, 13 Jul 2017 11:47:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVgLJ-0005tv-8K for qemu-devel@nongnu.org; Thu, 13 Jul 2017 11:47:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVgLE-0005qZ-VY; Thu, 13 Jul 2017 11:47:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAF316C09; Thu, 13 Jul 2017 15:47:47 +0000 (UTC) Received: from red.redhat.com (ovpn-121-60.rdu2.redhat.com [10.10.121.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 444366FABA; Thu, 13 Jul 2017 15:47:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAF316C09 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DAF316C09 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 13 Jul 2017 10:46:58 -0500 Message-Id: <20170713154711.32374-11-eblake@redhat.com> In-Reply-To: <20170713154711.32374-1-eblake@redhat.com> References: <20170713154711.32374-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 13 Jul 2017 15:47:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 10/23] block: Switch bdrv_common_block_status_above() to byte-based X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, el13635@mail.ntua.gr, Max Reitz , Stefan Hajnoczi , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We are gradually converting to byte-based interfaces, as they are easier to reason about than sector-based. Convert another internal function (no semantic change). Signed-off-by: Eric Blake Reviewed-by: Fam Zheng --- v3: rebase to allocation/mapping sense change, simple enough to keep R-b v2: new patch --- block/io.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/block/io.c b/block/io.c index 68d383d..b639e10 100644 --- a/block/io.c +++ b/block/io.c @@ -1938,19 +1938,18 @@ static void coroutine_fn bdrv_get_block_status_abov= e_co_entry(void *opaque) static int64_t bdrv_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, bool mapping, - int64_t sector_num, - int nb_sectors, int *pnum, + int64_t offset, + int64_t bytes, int64_t *pnum, BlockDriverState **file) { Coroutine *co; - int64_t n; BdrvCoBlockStatusData data =3D { .bs =3D bs, .base =3D base, .file =3D file, - .offset =3D sector_num * BDRV_SECTOR_SIZE, - .bytes =3D nb_sectors * BDRV_SECTOR_SIZE, - .pnum =3D &n, + .offset =3D offset, + .bytes =3D bytes, + .pnum =3D pnum, .mapping =3D mapping, .done =3D false, }; @@ -1964,8 +1963,6 @@ static int64_t bdrv_common_block_status_above(BlockDr= iverState *bs, bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !data.done); } - assert(data.ret < 0 || QEMU_IS_ALIGNED(n, BDRV_SECTOR_SIZE)); - *pnum =3D n >> BDRV_SECTOR_BITS; return data.ret; } @@ -1975,8 +1972,19 @@ int64_t bdrv_get_block_status_above(BlockDriverState= *bs, int nb_sectors, int *pnum, BlockDriverState **file) { - return bdrv_common_block_status_above(bs, base, true, sector_num, - nb_sectors, pnum, file); + int64_t ret; + int64_t n; + + ret =3D bdrv_common_block_status_above(bs, base, true, + sector_num * BDRV_SECTOR_SIZE, + nb_sectors * BDRV_SECTOR_SIZE, + &n, file); + if (ret < 0) { + return ret; + } + assert(QEMU_IS_ALIGNED(n, BDRV_SECTOR_SIZE)); + *pnum =3D n >> BDRV_SECTOR_BITS; + return ret; } int64_t bdrv_block_status(BlockDriverState *bs, @@ -2001,20 +2009,13 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState= *bs, int64_t offset, int64_t bytes, int64_t *pnum) { int64_t ret; - int psectors; + int64_t dummy; - assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); - assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE) && bytes < INT_MAX); - ret =3D bdrv_common_block_status_above(bs, backing_bs(bs), false, - offset >> BDRV_SECTOR_BITS, - bytes >> BDRV_SECTOR_BITS, &psect= ors, - NULL); + ret =3D bdrv_common_block_status_above(bs, backing_bs(bs), false, offs= et, + bytes, pnum ? pnum : &dummy, NULL= ); if (ret < 0) { return ret; } - if (pnum) { - *pnum =3D psectors * BDRV_SECTOR_SIZE; - } return !!(ret & BDRV_BLOCK_ALLOCATED); } --=20 2.9.4