From nobody Sun Oct 5 19:07:12 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 1507835449844377.34782968918967; Thu, 12 Oct 2017 12:10:49 -0700 (PDT) Received: from localhost ([::1]:46890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2isU-00030x-TY for importer@patchew.org; Thu, 12 Oct 2017 15:10:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2im3-0006CU-Va for qemu-devel@nongnu.org; Thu, 12 Oct 2017 15:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2im2-0001wC-Vs for qemu-devel@nongnu.org; Thu, 12 Oct 2017 15:04:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2ily-0001sN-17; Thu, 12 Oct 2017 15:03:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0827BC047B99; Thu, 12 Oct 2017 19:03:57 +0000 (UTC) Received: from red.redhat.com (ovpn-122-223.rdu2.redhat.com [10.10.122.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B8A260841; Thu, 12 Oct 2017 19:03:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0827BC047B99 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: Thu, 12 Oct 2017 13:59:05 -0500 Message-Id: <20171012185916.22776-10-eblake@redhat.com> In-Reply-To: <20171012185916.22776-1-eblake@redhat.com> References: <20171012185916.22776-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 12 Oct 2017 19:03:57 +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 09/20] parallels: 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, famz@redhat.com, qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , "Denis V. Lunev" , 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 moving away from sector-based interfaces, towards byte-based. Update the parallels driver accordingly. Note that the internal function block_status() is still sector-based, because it is still in use by other sector-based functions; but that's okay because request_alignment is 512 as a result of those functions. For now, no optimizations are added based on the mapping hint. Signed-off-by: Eric Blake --- v4: rebase to interface tweak, R-b dropped v3: no change v2: rebase to mapping parameter; it is ignored, so R-b kept --- block/parallels.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 2b6c6e5709..4a086f29e9 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -278,23 +278,31 @@ static coroutine_fn int parallels_co_flush_to_os(Bloc= kDriverState *bs) } -static int64_t coroutine_fn parallels_co_get_block_status(BlockDriverState= *bs, - int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **= file) +static int coroutine_fn parallels_co_block_status(BlockDriverState *bs, + bool want_zero, + int64_t offset, + int64_t bytes, + int64_t *pnum, + int64_t *map, + BlockDriverState **file) { BDRVParallelsState *s =3D bs->opaque; - int64_t offset; + int count; + assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); qemu_co_mutex_lock(&s->lock); - offset =3D block_status(s, sector_num, nb_sectors, pnum); + offset =3D block_status(s, offset >> BDRV_SECTOR_BITS, + bytes >> BDRV_SECTOR_BITS, &count); qemu_co_mutex_unlock(&s->lock); if (offset < 0) { return 0; } + *pnum =3D count * BDRV_SECTOR_SIZE; + *map =3D offset; *file =3D bs->file->bs; - return (offset << BDRV_SECTOR_BITS) | - BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; + return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; } static coroutine_fn int parallels_co_writev(BlockDriverState *bs, @@ -781,7 +789,7 @@ static BlockDriver bdrv_parallels =3D { .bdrv_open =3D parallels_open, .bdrv_close =3D parallels_close, .bdrv_child_perm =3D bdrv_format_default_perms, - .bdrv_co_get_block_status =3D parallels_co_get_block_status, + .bdrv_co_block_status =3D parallels_co_block_status, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, .bdrv_co_flush_to_os =3D parallels_co_flush_to_os, .bdrv_co_readv =3D parallels_co_readv, --=20 2.13.6