From patchwork Mon Apr 2 10:59:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 150110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2CC2AB6F9A for ; Mon, 2 Apr 2012 21:01:12 +1000 (EST) Received: from localhost ([::1]:60903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEf0W-0000VW-8b for incoming@patchwork.ozlabs.org; Mon, 02 Apr 2012 07:01:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEezo-0000U3-EC for qemu-devel@nongnu.org; Mon, 02 Apr 2012 07:01:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEezD-0005al-Qw for qemu-devel@nongnu.org; Mon, 02 Apr 2012 07:00:23 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:53902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEezD-0005XE-K8 for qemu-devel@nongnu.org; Mon, 02 Apr 2012 06:59:47 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Apr 2012 04:59:44 -0600 Received: from d01dlp03.pok.ibm.com (9.56.224.17) by e39.co.us.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 2 Apr 2012 04:59:41 -0600 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 4B712C9005A for ; Mon, 2 Apr 2012 06:59:40 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q32AxesX3203322 for ; Mon, 2 Apr 2012 06:59:40 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q32GUWkf023251 for ; Mon, 2 Apr 2012 12:30:33 -0400 Received: from us.ibm.com (f15.cn.ibm.com [9.115.118.120] (may be forged)) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q32GUT0s023089; Mon, 2 Apr 2012 12:30:30 -0400 Received: by us.ibm.com (sSMTP sendmail emulation); Mon, 2 Apr 2012 18:59:35 +0800 From: zwu.kernel@gmail.com To: qemu-devel@nongnu.org Date: Mon, 2 Apr 2012 18:59:34 +0800 Message-Id: <1333364374-32645-1-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12040210-4242-0000-0000-00000138F7FF X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.160 Cc: kwolf@redhat.com, Zhi Yong Wu , stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v4 2/2] block: disable I/O throttling on sync api 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: Zhi Yong Wu Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu Reviewed-by: Stefan Hajnoczi --- block.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 1fbf4dd..058ef17 100644 --- a/block.c +++ b/block.c @@ -1477,6 +1477,17 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, qemu_iovec_init_external(&qiov, &iov, 1); + /** + * In sync call context, when the vcpu is blocked, this throttling timer + * will not fire; so the I/O throttling function has to be disabled here + * if it has been enabled. + */ + if (bs->io_limits_enabled) { + fprintf(stderr, "Disabling I/O throttling on '%s' due " + "to synchronous I/O.\n", bdrv_get_device_name(bs)); + bdrv_io_limits_disable(bs); + } + if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_rw_co_entry(&rwco); @@ -1983,10 +1994,19 @@ static int guess_disk_lchs(BlockDriverState *bs, struct partition *p; uint32_t nr_sects; uint64_t nb_sectors; + bool enabled; bdrv_get_geometry(bs, &nb_sectors); + /** + * The function will be invoked during startup not only in sync I/O mode, + * but also in async I/O mode. So the I/O throttling function has to + * be disabled temporarily here, not permanently. + */ + enabled = bs->io_limits_enabled; + bs->io_limits_enabled = false; ret = bdrv_read(bs, 0, buf, 1); + bs->io_limits_enabled = enabled; if (ret < 0) return -1; /* test msdos magic */