From nobody Sun Oct 5 19:25:06 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 1515193727355752.1238247169208; Fri, 5 Jan 2018 15:08:47 -0800 (PST) Received: from localhost ([::1]:34656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXb6U-00043U-Gu for importer@patchew.org; Fri, 05 Jan 2018 18:08:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXawj-0003Hd-TJ for qemu-devel@nongnu.org; Fri, 05 Jan 2018 17:58:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXawi-0000OI-In for qemu-devel@nongnu.org; Fri, 05 Jan 2018 17:58:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47264) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eXawe-0000KO-Dd; Fri, 05 Jan 2018 17:58:36 -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 5750681DE1; Fri, 5 Jan 2018 22:58:35 +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 2FCBC60BE7; Fri, 5 Jan 2018 22:58:33 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 5 Jan 2018 16:57:47 -0600 Message-Id: <20180105225753.30509-15-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:35 +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 14/20] sheepdog: 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, Hitoshi Mitake , jcody@redhat.com, Max Reitz , "open list:Sheepdog" , Liu Yuan 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 sheepdog driver accordingly. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fam Zheng Reviewed-by: Jeff Cody --- v7: rebase to minor spacing changes in master v5-v6: no change v4: update to interface tweak v3: no change v2: rebase to mapping flag --- block/sheepdog.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index f684477328..8a7b688ece 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2987,19 +2987,19 @@ static coroutine_fn int sd_co_pdiscard(BlockDriverS= tate *bs, int64_t offset, return acb.ret; } -static coroutine_fn int64_t -sd_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_se= ctors, - int *pnum, BlockDriverState **file) +static coroutine_fn int +sd_co_block_status(BlockDriverState *bs, bool want_zero, int64_t offset, + int64_t bytes, int64_t *pnum, int64_t *map, + BlockDriverState **file) { BDRVSheepdogState *s =3D bs->opaque; SheepdogInode *inode =3D &s->inode; uint32_t object_size =3D (UINT32_C(1) << inode->block_size_shift); - uint64_t offset =3D sector_num * BDRV_SECTOR_SIZE; unsigned long start =3D offset / object_size, - end =3D DIV_ROUND_UP((sector_num + nb_sectors) * - BDRV_SECTOR_SIZE, object_size); + end =3D DIV_ROUND_UP(offset + bytes, object_size); unsigned long idx; - int64_t ret =3D BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset; + *map =3D offset; + int ret =3D BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; for (idx =3D start; idx < end; idx++) { if (inode->data_vdi_id[idx] =3D=3D 0) { @@ -3016,9 +3016,9 @@ sd_co_get_block_status(BlockDriverState *bs, int64_t = sector_num, int nb_sectors, } } - *pnum =3D (idx - start) * object_size / BDRV_SECTOR_SIZE; - if (*pnum > nb_sectors) { - *pnum =3D nb_sectors; + *pnum =3D (idx - start) * object_size; + if (*pnum > bytes) { + *pnum =3D bytes; } if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) { *file =3D bs; @@ -3096,7 +3096,7 @@ static BlockDriver bdrv_sheepdog =3D { .bdrv_co_writev =3D sd_co_writev, .bdrv_co_flush_to_disk =3D sd_co_flush_to_disk, .bdrv_co_pdiscard =3D sd_co_pdiscard, - .bdrv_co_get_block_status =3D sd_co_get_block_status, + .bdrv_co_block_status =3D sd_co_block_status, .bdrv_snapshot_create =3D sd_snapshot_create, .bdrv_snapshot_goto =3D sd_snapshot_goto, @@ -3132,7 +3132,7 @@ static BlockDriver bdrv_sheepdog_tcp =3D { .bdrv_co_writev =3D sd_co_writev, .bdrv_co_flush_to_disk =3D sd_co_flush_to_disk, .bdrv_co_pdiscard =3D sd_co_pdiscard, - .bdrv_co_get_block_status =3D sd_co_get_block_status, + .bdrv_co_block_status =3D sd_co_block_status, .bdrv_snapshot_create =3D sd_snapshot_create, .bdrv_snapshot_goto =3D sd_snapshot_goto, @@ -3168,7 +3168,7 @@ static BlockDriver bdrv_sheepdog_unix =3D { .bdrv_co_writev =3D sd_co_writev, .bdrv_co_flush_to_disk =3D sd_co_flush_to_disk, .bdrv_co_pdiscard =3D sd_co_pdiscard, - .bdrv_co_get_block_status =3D sd_co_get_block_status, + .bdrv_co_block_status =3D sd_co_block_status, .bdrv_snapshot_create =3D sd_snapshot_create, .bdrv_snapshot_goto =3D sd_snapshot_goto, --=20 2.14.3