From patchwork Tue Apr 18 01:33:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9684799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 514956037D for ; Tue, 18 Apr 2017 01:36:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41D55205A4 for ; Tue, 18 Apr 2017 01:36:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3503A27D16; Tue, 18 Apr 2017 01:36:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D9A5A205A4 for ; Tue, 18 Apr 2017 01:36:25 +0000 (UTC) Received: from localhost ([::1]:39480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0I49-0005mN-27 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Apr 2017 21:36:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0I28-0005BV-Sw for qemu-devel@nongnu.org; Mon, 17 Apr 2017 21:34:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0I27-0003gE-Qz for qemu-devel@nongnu.org; Mon, 17 Apr 2017 21:34:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40710) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0I24-0003d8-N9; Mon, 17 Apr 2017 21:34:16 -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 ABEA7C04B924; Tue, 18 Apr 2017 01:34:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ABEA7C04B924 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=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ABEA7C04B924 Received: from red.redhat.com (ovpn-121-102.rdu2.redhat.com [10.10.121.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5618253C35; Tue, 18 Apr 2017 01:34:14 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 20:33:33 -0500 Message-Id: <20170418013356.3578-9-eblake@redhat.com> In-Reply-To: <20170418013356.3578-1-eblake@redhat.com> References: <20170418013356.3578-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]); Tue, 18 Apr 2017 01:34:15 +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 08/31] block: Switch BdrvCoGetBlockStatusData to byte-based 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , kwolf@nongnu.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We are gradually converting to byte-based interfaces, as they are easier to reason about than sector-based. Convert another internal type (no semantic change), and rename it to match the corresponding public function rename. Signed-off-by: Eric Blake --- block/io.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/block/io.c b/block/io.c index e804bdd..f7ece8d 100644 --- a/block/io.c +++ b/block/io.c @@ -1680,16 +1680,16 @@ int bdrv_flush_all(void) } -typedef struct BdrvCoGetBlockStatusData { +typedef struct BdrvCoBlockStatusData { BlockDriverState *bs; BlockDriverState *base; BlockDriverState **file; - int64_t sector_num; - int nb_sectors; - int *pnum; + int64_t offset; + int64_t bytes; + int64_t *pnum; int64_t ret; bool done; -} BdrvCoGetBlockStatusData; +} BdrvCoBlockStatusData; /* * Returns the allocation status of the specified sectors. @@ -1850,13 +1850,15 @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, /* Coroutine wrapper for bdrv_get_block_status_above() */ static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) { - BdrvCoGetBlockStatusData *data = opaque; + BdrvCoBlockStatusData *data = opaque; + int n; data->ret = bdrv_co_get_block_status_above(data->bs, data->base, - data->sector_num, - data->nb_sectors, - data->pnum, + data->offset >> BDRV_SECTOR_BITS, + data->bytes >> BDRV_SECTOR_BITS, + &n, data->file); + *data->pnum = n * BDRV_SECTOR_SIZE; data->done = true; } @@ -1872,13 +1874,14 @@ int64_t bdrv_get_block_status_above(BlockDriverState *bs, BlockDriverState **file) { Coroutine *co; - BdrvCoGetBlockStatusData data = { + int64_t n; + BdrvCoBlockStatusData data = { .bs = bs, .base = base, .file = file, - .sector_num = sector_num, - .nb_sectors = nb_sectors, - .pnum = pnum, + .offset = sector_num * BDRV_SECTOR_SIZE, + .bytes = nb_sectors * BDRV_SECTOR_SIZE, + .pnum = &n, .done = false, }; @@ -1891,6 +1894,7 @@ int64_t bdrv_get_block_status_above(BlockDriverState *bs, bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !data.done); } + *pnum = n >> BDRV_SECTOR_BITS; return data.ret; }