From nobody Mon Feb 9 16:12:52 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 15000352423891021.596471781728; Fri, 14 Jul 2017 05:27:22 -0700 (PDT) Received: from localhost ([::1]:37748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVzgl-0007Lb-2C for importer@patchew.org; Fri, 14 Jul 2017 08:27:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVzVs-0004P4-U1 for qemu-devel@nongnu.org; Fri, 14 Jul 2017 08:16:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVzVs-0004RG-0O for qemu-devel@nongnu.org; Fri, 14 Jul 2017 08:16:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVzVn-0004HV-Bq; Fri, 14 Jul 2017 08:15:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 623837C845; Fri, 14 Jul 2017 12:15:58 +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 69ECA6E911; Fri, 14 Jul 2017 12:15:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 623837C845 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 623837C845 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 14 Jul 2017 07:14:55 -0500 Message-Id: <20170714121457.10322-19-eblake@redhat.com> In-Reply-To: <20170714121457.10322-1-eblake@redhat.com> References: <20170714121457.10322-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 14 Jul 2017 12:15:58 +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 v2 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, jsnow@redhat.com, famz@redhat.com, qemu-block@nongnu.org, 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. Drop the now-unused get_sector_offset(). Signed-off-by: Eric Blake --- v2: drop get_sector_offset() [Kevin], rebase to mapping flag --- block/vpc.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 9a6f817..913f25d 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -496,12 +496,6 @@ static inline int64_t get_image_offset(BlockDriverStat= e *bs, uint64_t offset, return block_offset; } -static inline int64_t get_sector_offset(BlockDriverState *bs, - int64_t sector_num, bool write) -{ - return get_image_offset(bs, sector_num * BDRV_SECTOR_SIZE, write); -} - /* * Writes the footer to the end of the image file. This is needed when the * file grows as it overwrites the old footer @@ -689,46 +683,48 @@ 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 int64_t coroutine_fn vpc_co_block_status(BlockDriverState *bs, + bool mapping, + int64_t offset, int64_t by= tes, + int64_t *pnum, + BlockDriverState **file) { BDRVVPCState *s =3D bs->opaque; VHDFooter *footer =3D (VHDFooter*) s->footer_buf; - int64_t start, offset; + int64_t start, image_offset; bool allocated; int n; if (be32_to_cpu(footer->type) =3D=3D VHD_FIXED) { - *pnum =3D nb_sectors; + *pnum =3D bytes; *file =3D bs->file->bs; return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | - (sector_num << BDRV_SECTOR_BITS); + (offset & BDRV_BLOCK_OFFSET_MASK); } - offset =3D get_sector_offset(bs, sector_num, 0); - start =3D offset; - allocated =3D (offset !=3D -1); + image_offset =3D get_image_offset(bs, offset, 0); + start =3D image_offset & BDRV_BLOCK_OFFSET_MASK; + allocated =3D (image_offset !=3D -1); *pnum =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; return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start; } - if (nb_sectors =3D=3D 0) { + if (bytes =3D=3D 0) { break; } - offset =3D get_sector_offset(bs, sector_num, 0); + image_offset =3D get_image_offset(bs, offset, 0); } while (offset =3D=3D -1); return 0; @@ -1074,7 +1070,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.9.4