From nobody Mon Feb 9 12:25:50 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 1505318986136713.2064403957944; Wed, 13 Sep 2017 09:09:46 -0700 (PDT) Received: from localhost ([::1]:43374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsAET-0007S8-6k for importer@patchew.org; Wed, 13 Sep 2017 12:09:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsA9P-0001eg-St for qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:04:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsA9O-0006Ct-Tx for qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:04:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsA9J-00068t-6b; Wed, 13 Sep 2017 12:04:25 -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 3C432C047B7F; Wed, 13 Sep 2017 16:04:24 +0000 (UTC) Received: from red.redhat.com (ovpn-120-201.rdu2.redhat.com [10.10.120.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01CD55C47C; Wed, 13 Sep 2017 16:04:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C432C047B7F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eblake@redhat.com From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 11:03:20 -0500 Message-Id: <20170913160333.23622-11-eblake@redhat.com> In-Reply-To: <20170913160333.23622-1-eblake@redhat.com> References: <20170913160333.23622-1-eblake@redhat.com> 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.31]); Wed, 13 Sep 2017 16:04:24 +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 v4 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, 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 Reviewed-by: John Snow --- 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 0adfbb8e70..bc0e3fd0e2 100644 --- a/block/io.c +++ b/block/io.c @@ -1962,19 +1962,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, }; @@ -1988,8 +1987,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; } @@ -1999,8 +1996,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, @@ -2025,20 +2033,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.13.5