From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8dik-0002tH-O1 for qemu-devel@nongnu.org; Wed, 10 May 2017 22:20:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8dij-000581-Td for qemu-devel@nongnu.org; Wed, 10 May 2017 22:20:50 -0400 From: Eric Blake Date: Wed, 10 May 2017 21:20:19 -0500 Message-Id: <20170511022036.32225-4-eblake@redhat.com> In-Reply-To: <20170511022036.32225-1-eblake@redhat.com> References: <20170511022036.32225-1-eblake@redhat.com> Subject: [Qemu-devel] [PATCH v2 03/20] stream: Switch stream_populate() to byte-based List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, jsnow@redhat.com, Jeff Cody , Kevin Wolf , Max Reitz We are gradually converting to byte-based interfaces, as they are easier to reason about than sector-based. Start by converting an internal function (no semantic change). Signed-off-by: Eric Blake Reviewed-by: John Snow --- v2: no change --- block/stream.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/stream.c b/block/stream.c index 3134ec5..5acef6d 100644 --- a/block/stream.c +++ b/block/stream.c @@ -41,20 +41,20 @@ typedef struct StreamBlockJob { } StreamBlockJob; static int coroutine_fn stream_populate(BlockBackend *blk, - int64_t sector_num, int nb_sectors, + int64_t offset, uint64_t bytes, void *buf) { struct iovec iov = { .iov_base = buf, - .iov_len = nb_sectors * BDRV_SECTOR_SIZE, + .iov_len = bytes, }; QEMUIOVector qiov; + assert(bytes < SIZE_MAX); qemu_iovec_init_external(&qiov, &iov, 1); /* Copy-on-read the unallocated clusters */ - return blk_co_preadv(blk, sector_num * BDRV_SECTOR_SIZE, qiov.size, &qiov, - BDRV_REQ_COPY_ON_READ); + return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_READ); } typedef struct { @@ -171,7 +171,8 @@ static void coroutine_fn stream_run(void *opaque) trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE, ret); if (copy) { - ret = stream_populate(blk, sector_num, n, buf); + ret = stream_populate(blk, sector_num * BDRV_SECTOR_SIZE, + n * BDRV_SECTOR_SIZE, buf); } if (ret < 0) { BlockErrorAction action = -- 2.9.3