From patchwork Mon Dec 15 08:27:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 421027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A720A1400D2 for ; Mon, 15 Dec 2014 20:19:55 +1100 (AEDT) Received: from localhost ([::1]:38634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Ron-0006D6-RR for incoming@patchwork.ozlabs.org; Mon, 15 Dec 2014 04:19:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Rg5-000833-M5 for qemu-devel@nongnu.org; Mon, 15 Dec 2014 04:10:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0Rg1-0005eI-7K for qemu-devel@nongnu.org; Mon, 15 Dec 2014 04:10:53 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:27462 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Rg0-0004kT-1i for qemu-devel@nongnu.org; Mon, 15 Dec 2014 04:10:48 -0500 Received: from hades.sw.ru ([10.30.8.132]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id sBF8RAUK012492; Mon, 15 Dec 2014 12:27:26 +0400 (MSK) From: "Denis V. Lunev" To: Date: Mon, 15 Dec 2014 11:27:53 +0300 Message-Id: <1418632081-20667-9-git-send-email-den@openvz.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418632081-20667-1-git-send-email-den@openvz.org> References: <1418632081-20667-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: Kevin Wolf , Roman Kagan , Jeff Cody , qemu-devel@nongnu.org, Stefan Hajnoczi , "Denis V. Lunev" Subject: [Qemu-devel] [PATCH 08/16] block/parallels: switch to bdrv_read X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Roman Kagan Switch the .bdrv_read method implementation from using bdrv_pread() to bdrv_read() on the underlying file, since the latter is subject to i/o throttling while the former is not. Besides, since bdrv_read() operates in sectors rather than bytes, adjust the helper functions to do so too. Signed-off-by: Roman Kagan Signed-off-by: Denis V. Lunev CC: Jeff Cody CC: Kevin Wolf CC: Stefan Hajnoczi --- block/parallels.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 5fcede8..de4f39f 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -364,9 +364,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } -static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num) +static int64_t seek_to_sector(BDRVParallelsState *s, int64_t sector_num) { - BDRVParallelsState *s = bs->opaque; uint32_t index, offset; index = sector_num / s->tracks; @@ -375,8 +374,7 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num) /* not allocated */ if ((index >= s->catalog_size) || (s->catalog_bitmap[index] == 0)) return -1; - return - ((uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset) * 512; + return (uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset; } static int parallels_read(BlockDriverState *bs, int64_t sector_num, @@ -387,16 +385,18 @@ static int parallels_read(BlockDriverState *bs, int64_t sector_num, sector_num += s->padding; while (nb_sectors > 0) { - int64_t position = seek_to_sector(bs, sector_num); + int64_t position = seek_to_sector(s, sector_num); if (position >= 0) { - if (bdrv_pread(bs->file, position, buf, 512) != 512) - return -1; + int ret = bdrv_read(bs->file, position, buf, 1); + if (ret < 0) { + return ret; + } } else { - memset(buf, 0, 512); + memset(buf, 0, BDRV_SECTOR_SIZE); } nb_sectors--; sector_num++; - buf += 512; + buf += BDRV_SECTOR_SIZE; } return 0; }