From nobody Tue Apr 15 09:54:05 2025 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509024712740470.11283220229905; Thu, 26 Oct 2017 06:31:52 -0700 (PDT) Received: from localhost ([::1]:52927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7iG5-0002q8-Ad for importer@patchew.org; Thu, 26 Oct 2017 09:31:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7i3M-0000bQ-Kn for qemu-devel@nongnu.org; Thu, 26 Oct 2017 09:18:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7i3G-00023H-Gy for qemu-devel@nongnu.org; Thu, 26 Oct 2017 09:18:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24259) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e7i36-0001sV-Gm; Thu, 26 Oct 2017 09:18:16 -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 929D7C064294; Thu, 26 Oct 2017 13:18:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A6967F5FD; Thu, 26 Oct 2017 13:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 929D7C064294 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=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 26 Oct 2017 15:17:19 +0200 Message-Id: <20171026131741.5059-14-kwolf@redhat.com> In-Reply-To: <20171026131741.5059-1-kwolf@redhat.com> References: <20171026131741.5059-1-kwolf@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.31]); Thu, 26 Oct 2017 13:18:15 +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] [PULL 13/35] 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, qemu-devel@nongnu.org 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" From: Eric Blake 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 Signed-off-by: Kevin Wolf --- block/io.c | 68 ++++++++++++++++++++++------------------------------------= ---- 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/block/io.c b/block/io.c index 3a9a4c5db9..61b3477cd1 100644 --- a/block/io.c +++ b/block/io.c @@ -1976,33 +1976,26 @@ early_out: return ret; } =20 -static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverStat= e *bs, - BlockDriverState *base, - bool want_zero, - int64_t sector_num, - int nb_sectors, - int *pnum, - BlockDriverState **file) +static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs, + BlockDriverState *base, + bool want_zero, + int64_t offset, + int64_t bytes, + int64_t *pnum, + int64_t *map, + BlockDriverState **file) { BlockDriverState *p; - int64_t ret =3D 0; + int ret =3D 0; bool first =3D true; - int64_t map =3D 0; =20 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, want_zero, - sector_num * BDRV_SECTOR_SIZE, - nb_sectors * BDRV_SECTOR_SIZE, &count, - &map, file); + ret =3D bdrv_co_block_status(p, want_zero, offset, bytes, pnum, ma= p, + file); if (ret < 0) { break; } - assert(QEMU_IS_ALIGNED(count | map, BDRV_SECTOR_SIZE)); - ret |=3D map; - *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 @@ -2010,47 +2003,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; } =20 /* 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 =3D 0; - int64_t ret; =20 - ret =3D bdrv_co_get_block_status_above(data->bs, data->base, - data->want_zero, - data->offset >> BDRV_SECTOR_BITS, - data->bytes >> BDRV_SECTOR_BITS, - &n, - data->file); - if (ret < 0) { - assert(INT_MIN <=3D ret); - data->ret =3D ret; - } else { - *data->pnum =3D n * BDRV_SECTOR_SIZE; - *data->map =3D ret & BDRV_BLOCK_OFFSET_MASK; - data->ret =3D ret & ~BDRV_BLOCK_OFFSET_MASK; - } + data->ret =3D bdrv_co_block_status_above(data->bs, data->base, + data->want_zero, + data->offset, data->bytes, + data->pnum, data->map, data->fi= le); data->done =3D true; } =20 /* - * 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 int bdrv_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, @@ -2074,10 +2055,9 @@ static int bdrv_common_block_status_above(BlockDrive= rState *bs, =20 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.6