From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDXXk-0006ck-NQ for qemu-devel@nongnu.org; Fri, 30 Mar 2012 04:50:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDXXc-0005kW-6y for qemu-devel@nongnu.org; Fri, 30 Mar 2012 04:50:48 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:42720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDXXc-0005k1-2p for qemu-devel@nongnu.org; Fri, 30 Mar 2012 04:50:40 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 30 Mar 2012 04:50:36 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 4E51C6E8049 for ; Fri, 30 Mar 2012 04:50:33 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q2U8oWdI3502100 for ; Fri, 30 Mar 2012 04:50:32 -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 q2UELPYK016612 for ; Fri, 30 Mar 2012 10:21:25 -0400 From: zwu.kernel@gmail.com Date: Fri, 30 Mar 2012 16:50:27 +0800 Message-Id: <1333097427-20912-1-git-send-email-zwu.kernel@gmail.com> Subject: [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, wuzhy@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com From: Zhi Yong Wu Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu --- block.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 1fbf4dd..6de6f89 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,21 @@ 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. + * When all sync I/O drivers are converted to async I/O, it will be restored + * to the original state. + */ + 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 */ -- 1.7.6