From nobody Sun Oct 5 19:25:04 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515193921818256.37203206303604; Fri, 5 Jan 2018 15:12:01 -0800 (PST) Received: from localhost ([::1]:34687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXb9c-0007EY-R6 for importer@patchew.org; Fri, 05 Jan 2018 18:12:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXawt-0003Rz-Qt for qemu-devel@nongnu.org; Fri, 05 Jan 2018 17:58:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXaws-0000YS-NW for qemu-devel@nongnu.org; Fri, 05 Jan 2018 17:58:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47330) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eXawp-0000VH-Lx; Fri, 05 Jan 2018 17:58:47 -0500 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 B7FD48535D; Fri, 5 Jan 2018 22:58:46 +0000 (UTC) Received: from red.redhat.com (ovpn-124-124.rdu2.redhat.com [10.10.124.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5525660BE7; Fri, 5 Jan 2018 22:58:43 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 5 Jan 2018 16:57:51 -0600 Message-Id: <20180105225753.30509-19-eblake@redhat.com> In-Reply-To: <20180105225753.30509-1-eblake@redhat.com> References: <20180105225753.30509-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.25]); Fri, 05 Jan 2018 22:58:46 +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 v7 18/20] vpc: Switch to .bdrv_co_block_status() 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, vsementsov@virtuozzo.com, famz@redhat.com, qemu-block@nongnu.org, jcody@redhat.com, Max Reitz 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 moving away from sector-based interfaces, towards byte-based. Update the vpc driver accordingly. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fam Zheng --- v7: tweak commit message and type of 'n' [Fam] v6: no change v5: fix incorrect rounding in 'map' and bad loop condition [Vladimir] v4: rebase to interface tweak v3: rebase to master v2: drop get_sector_offset() [Kevin], rebase to mapping flag --- block/vpc.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 1576d7b595..97011febd3 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -705,53 +705,54 @@ fail: return ret; } -static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **= file) +static int coroutine_fn vpc_co_block_status(BlockDriverState *bs, + bool want_zero, + int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file) { BDRVVPCState *s =3D bs->opaque; VHDFooter *footer =3D (VHDFooter*) s->footer_buf; - int64_t start, offset; + int64_t image_offset; bool allocated; - int64_t ret; - int n; + int ret; + int64_t n; if (be32_to_cpu(footer->type) =3D=3D VHD_FIXED) { - *pnum =3D nb_sectors; + *pnum =3D bytes; + *map =3D offset; *file =3D bs->file->bs; - return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | - (sector_num << BDRV_SECTOR_BITS); + return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID; } qemu_co_mutex_lock(&s->lock); - offset =3D get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false,= NULL); - start =3D offset; - allocated =3D (offset !=3D -1); + image_offset =3D get_image_offset(bs, offset, false, NULL); + allocated =3D (image_offset !=3D -1); *pnum =3D 0; ret =3D 0; do { /* All sectors in a block are contiguous (without using the bitmap= ) */ - n =3D ROUND_UP(sector_num + 1, s->block_size / BDRV_SECTOR_SIZE) - - sector_num; - n =3D MIN(n, nb_sectors); + n =3D ROUND_UP(offset + 1, s->block_size) - offset; + n =3D MIN(n, bytes); *pnum +=3D n; - sector_num +=3D n; - nb_sectors -=3D n; + offset +=3D n; + bytes -=3D n; /* *pnum can't be greater than one block for allocated * sectors since there is always a bitmap in between. */ if (allocated) { *file =3D bs->file->bs; - ret =3D BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start; + *map =3D image_offset; + ret =3D BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; break; } - if (nb_sectors =3D=3D 0) { + if (bytes =3D=3D 0) { break; } - offset =3D get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, fa= lse, - NULL); - } while (offset =3D=3D -1); + image_offset =3D get_image_offset(bs, offset, false, NULL); + } while (image_offset =3D=3D -1); qemu_co_mutex_unlock(&s->lock); return ret; @@ -1097,7 +1098,7 @@ static BlockDriver bdrv_vpc =3D { .bdrv_co_preadv =3D vpc_co_preadv, .bdrv_co_pwritev =3D vpc_co_pwritev, - .bdrv_co_get_block_status =3D vpc_co_get_block_status, + .bdrv_co_block_status =3D vpc_co_block_status, .bdrv_get_info =3D vpc_get_info, --=20 2.14.3