From patchwork Mon Feb 20 04:50:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 142108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 812A0B6FB4 for ; Mon, 20 Feb 2012 15:50:58 +1100 (EST) Received: from localhost ([::1]:45333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzLDC-0007JP-LX for incoming@patchwork.ozlabs.org; Sun, 19 Feb 2012 23:50:54 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzLD5-0007JJ-8Q for qemu-devel@nongnu.org; Sun, 19 Feb 2012 23:50:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzLD4-0007Mc-6H for qemu-devel@nongnu.org; Sun, 19 Feb 2012 23:50:47 -0500 Received: from e37.co.us.ibm.com ([32.97.110.158]:45800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzLD3-0007MW-Vr for qemu-devel@nongnu.org; Sun, 19 Feb 2012 23:50:46 -0500 Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 19 Feb 2012 21:50:44 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 19 Feb 2012 21:50:42 -0700 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id AE8C63E40036 for ; Sun, 19 Feb 2012 21:50:41 -0700 (MST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q1K4odtS140464 for ; Sun, 19 Feb 2012 21:50:40 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q1K4odid013750 for ; Sun, 19 Feb 2012 21:50:39 -0700 Received: from us.ibm.com (f15.cn.ibm.com [9.115.118.120] (may be forged)) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q1K4oZQZ012963; Sun, 19 Feb 2012 21:50:36 -0700 Received: by us.ibm.com (sSMTP sendmail emulation); Mon, 20 Feb 2012 12:50:31 +0800 From: zwu.kernel@gmail.com To: qemu-devel@nongnu.org Date: Mon, 20 Feb 2012 12:50:30 +0800 Message-Id: <1329713430-9209-1-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12022004-7408-0000-0000-000002CC0C5E X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.158 Cc: kwolf@redhat.com, chris@arachsys.com, Zhi Yong Wu , stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue 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 If one guest has multiple disks with enabling I/O throttling function separately, when draining activities are done, some requests maybe are in the throttled queue; So we need to restart them at first. Moreover, when only one disk need to be drained such as hotplug out, if another disk still has some requests in its throttled queue, these request should not be effected. Signed-off-by: Zhi Yong Wu --- block.c | 29 ++++++++++++++++++++++------- block_int.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index ae297bb..f78df78 100644 --- a/block.c +++ b/block.c @@ -853,25 +853,40 @@ void bdrv_close_all(void) } } -/* - * Wait for pending requests to complete across all BlockDriverStates - * - * This function does not flush data to disk, use bdrv_flush_all() for that - * after calling this function. - */ -void bdrv_drain_all(void) +void bdrv_drain_request(BlockDriverState *throttled_bs) { BlockDriverState *bs; + QTAILQ_FOREACH(bs, &bdrv_states, list) { + if (throttled_bs && throttled_bs != bs) { + continue; + } + qemu_co_queue_restart_all(&bs->throttled_reqs); + } + qemu_aio_flush(); /* If requests are still pending there is a bug somewhere */ QTAILQ_FOREACH(bs, &bdrv_states, list) { assert(QLIST_EMPTY(&bs->tracked_requests)); + if (throttled_bs && throttled_bs != bs) { + continue; + } assert(qemu_co_queue_empty(&bs->throttled_reqs)); } } +/* + * Wait for pending requests to complete across all BlockDriverStates + * + * This function does not flush data to disk, use bdrv_flush_all() for that + * after calling this function. + */ +void bdrv_drain_all(void) +{ + bdrv_drain_request(NULL); +} + /* make a BlockDriverState anonymous by removing from bdrv_state list. Also, NULL terminate the device_name to prevent double remove */ void bdrv_make_anon(BlockDriverState *bs) diff --git a/block_int.h b/block_int.h index 7946cf6..1311288 100644 --- a/block_int.h +++ b/block_int.h @@ -323,6 +323,7 @@ void qemu_aio_release(void *p); void bdrv_set_io_limits(BlockDriverState *bs, BlockIOLimit *io_limits); +void bdrv_drain_request(BlockDriverState *bs); #ifdef _WIN32 int is_windows_drive(const char *filename);