From nobody Sun Oct 5 19:25:07 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 1515193804385460.63962691993936; Fri, 5 Jan 2018 15:10:04 -0800 (PST) Received: from localhost ([::1]:34667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXb7j-0005K8-HO for importer@patchew.org; Fri, 05 Jan 2018 18:10:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXawZ-00037u-NU for qemu-devel@nongnu.org; Fri, 05 Jan 2018 17:58:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXawV-0000ET-Ql for qemu-devel@nongnu.org; Fri, 05 Jan 2018 17:58:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39632) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eXawQ-0000AK-IN; Fri, 05 Jan 2018 17:58:22 -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 97298356C3; Fri, 5 Jan 2018 22:58:21 +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 B85B160BE7; Fri, 5 Jan 2018 22:58:17 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 5 Jan 2018 16:57:41 -0600 Message-Id: <20180105225753.30509-9-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.30]); Fri, 05 Jan 2018 22:58:21 +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 08/20] null: 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 null driver accordingly. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fam Zheng --- v6-v7: no change v5: minor fix to type of 'ret' v4: rebase to interface tweak v3: no change v2: rebase to mapping parameter --- block/null.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/block/null.c b/block/null.c index 0cdabaa440..2c16935f3c 100644 --- a/block/null.c +++ b/block/null.c @@ -222,22 +222,23 @@ static int null_reopen_prepare(BDRVReopenState *reope= n_state, return 0; } -static int64_t coroutine_fn null_co_get_block_status(BlockDriverState *bs, - int64_t sector_num, - int nb_sectors, int *= pnum, - BlockDriverState **fi= le) +static int coroutine_fn null_co_block_status(BlockDriverState *bs, + bool want_zero, int64_t offse= t, + int64_t bytes, int64_t *pnum, + int64_t *map, + BlockDriverState **file) { BDRVNullState *s =3D bs->opaque; - off_t start =3D sector_num * BDRV_SECTOR_SIZE; + int ret =3D BDRV_BLOCK_OFFSET_VALID; - *pnum =3D nb_sectors; + *pnum =3D bytes; + *map =3D offset; *file =3D bs; if (s->read_zeroes) { - return BDRV_BLOCK_OFFSET_VALID | start | BDRV_BLOCK_ZERO; - } else { - return BDRV_BLOCK_OFFSET_VALID | start; + ret |=3D BDRV_BLOCK_ZERO; } + return ret; } static void null_refresh_filename(BlockDriverState *bs, QDict *opts) @@ -269,7 +270,7 @@ static BlockDriver bdrv_null_co =3D { .bdrv_co_flush_to_disk =3D null_co_flush, .bdrv_reopen_prepare =3D null_reopen_prepare, - .bdrv_co_get_block_status =3D null_co_get_block_status, + .bdrv_co_block_status =3D null_co_block_status, .bdrv_refresh_filename =3D null_refresh_filename, }; @@ -289,7 +290,7 @@ static BlockDriver bdrv_null_aio =3D { .bdrv_aio_flush =3D null_aio_flush, .bdrv_reopen_prepare =3D null_reopen_prepare, - .bdrv_co_get_block_status =3D null_co_get_block_status, + .bdrv_co_block_status =3D null_co_block_status, .bdrv_refresh_filename =3D null_refresh_filename, }; --=20 2.14.3