From nobody Mon Feb 9 09:16:10 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 1505318816535832.8673048141812; Wed, 13 Sep 2017 09:06:56 -0700 (PDT) Received: from localhost ([::1]:43332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsABj-0003us-Kr for importer@patchew.org; Wed, 13 Sep 2017 12:06:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsA9Q-0001fX-QM for qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:04:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsA9P-0006DQ-OV for qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:04:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsA9K-00069x-UV; Wed, 13 Sep 2017 12:04:27 -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 00F9585542; Wed, 13 Sep 2017 16:04:26 +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 7DE965C6D2; Wed, 13 Sep 2017 16:04:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 00F9585542 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.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:21 -0500 Message-Id: <20170913160333.23622-12-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.28]); Wed, 13 Sep 2017 16:04:26 +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 11/23] block: Switch bdrv_co_get_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 type (no semantic change), and rename it to match the corresponding public function rename. 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: rebase to earlier changes --- block/io.c | 48 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/block/io.c b/block/io.c index bc0e3fd0e2..409cfe0938 100644 --- a/block/io.c +++ b/block/io.c @@ -1893,12 +1893,12 @@ out: return ret; } -static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverStat= e *bs, +static int64_t coroutine_fn bdrv_co_block_status_above(BlockDriverState *b= s, BlockDriverState *base, bool mapping, - int64_t sector_num, - int nb_sectors, - int *pnum, + int64_t offset, + int64_t bytes, + int64_t *pnum, BlockDriverState **file) { BlockDriverState *p; @@ -1907,17 +1907,10 @@ static int64_t coroutine_fn bdrv_co_get_block_statu= s_above(BlockDriverState *bs, assert(bs !=3D base); for (p =3D bs; p !=3D base; p =3D backing_bs(p)) { - int64_t count; - - ret =3D bdrv_co_block_status(p, mapping, - sector_num * BDRV_SECTOR_SIZE, - nb_sectors * BDRV_SECTOR_SIZE, &count, - file); + ret =3D bdrv_co_block_status(p, mapping, offset, bytes, pnum, file= ); if (ret < 0) { break; } - assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)); - *pnum =3D count >> BDRV_SECTOR_BITS; if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) { /* * Reading beyond the end of the file continues to read @@ -1925,39 +1918,35 @@ static int64_t coroutine_fn bdrv_co_get_block_statu= s_above(BlockDriverState *bs, * unallocated length we learned from an earlier * iteration. */ - *pnum =3D nb_sectors; + *pnum =3D bytes; } if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) { break; } - /* [sector_num, pnum] unallocated on this layer, which could be on= ly - * the first part of [sector_num, nb_sectors]. */ - nb_sectors =3D MIN(nb_sectors, *pnum); + /* [offset, pnum] unallocated on this layer, which could be only + * the first part of [offset, bytes]. */ + bytes =3D MIN(bytes, *pnum); first =3D false; } return ret; } /* Coroutine wrapper for bdrv_get_block_status_above() */ -static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) +static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque) { BdrvCoBlockStatusData *data =3D opaque; - int n; - data->ret =3D bdrv_co_get_block_status_above(data->bs, data->base, - data->mapping, - data->offset >> BDRV_SECTOR= _BITS, - data->bytes >> BDRV_SECTOR_= BITS, - &n, - data->file); - *data->pnum =3D n * BDRV_SECTOR_SIZE; + data->ret =3D bdrv_co_block_status_above(data->bs, data->base, + data->mapping, + data->offset, data->bytes, + data->pnum, data->file); data->done =3D true; } /* - * Synchronous wrapper around bdrv_co_get_block_status_above(). + * Synchronous wrapper around bdrv_co_block_status_above(). * - * See bdrv_co_get_block_status_above() for details. + * See bdrv_co_block_status_above() for details. */ static int64_t bdrv_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, @@ -1980,10 +1969,9 @@ static int64_t bdrv_common_block_status_above(BlockD= riverState *bs, if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ - bdrv_get_block_status_above_co_entry(&data); + bdrv_block_status_above_co_entry(&data); } else { - co =3D qemu_coroutine_create(bdrv_get_block_status_above_co_entry, - &data); + co =3D qemu_coroutine_create(bdrv_block_status_above_co_entry, &da= ta); bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !data.done); } --=20 2.13.5