From patchwork Mon Mar 12 14:53:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 146123 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 B0D0DB6ED0 for ; Tue, 13 Mar 2012 02:17:57 +1100 (EST) Received: from localhost ([::1]:44467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S76do-0006lV-9a for incoming@patchwork.ozlabs.org; Mon, 12 Mar 2012 10:54:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S76dd-0006kP-8z for qemu-devel@nongnu.org; Mon, 12 Mar 2012 10:54:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S76dS-0000ar-Ge for qemu-devel@nongnu.org; Mon, 12 Mar 2012 10:54:15 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:33524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S76dS-0000Xl-Cz for qemu-devel@nongnu.org; Mon, 12 Mar 2012 10:54:06 -0400 Received: from /spool/local by e5.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 Mar 2012 10:54:00 -0400 Received: from d01dlp02.pok.ibm.com (9.56.224.85) by e5.ny.us.ibm.com (192.168.1.105) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 12 Mar 2012 10:53:34 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id BE5D36E8053 for ; Mon, 12 Mar 2012 10:53:33 -0400 (EDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q2CErV7x171672 for ; Mon, 12 Mar 2012 10:53:32 -0400 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q2CErU2r009665 for ; Mon, 12 Mar 2012 08:53:31 -0600 Received: from us.ibm.com (f15.cn.ibm.com [9.115.118.120] (may be forged)) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q2CErRBv009377; Mon, 12 Mar 2012 08:53:28 -0600 Received: by us.ibm.com (sSMTP sendmail emulation); Mon, 12 Mar 2012 22:53:26 +0800 From: zwu.kernel@gmail.com To: qemu-devel@nongnu.org Date: Mon, 12 Mar 2012 22:53:25 +0800 Message-Id: <1331564005-31070-1-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12031214-5930-0000-0000-00000605F84C X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.145 Cc: kwolf@redhat.com, pbonzini@redhat.com, Zhi Yong Wu , zwu.kernel@gmail.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v3 1/2] block: add the support to drain throttled requests 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: Zhi Yong Wu --- block.c | 21 ++++++++++++++++++++- block_int.h | 1 + 2 files changed, 21 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index 52ffe14..b3cbcc3 100644 --- a/block.c +++ b/block.c @@ -853,6 +853,20 @@ void bdrv_close_all(void) } } +/** + * Complete all pending requests for a block device + */ +void bdrv_drain(BlockDriverState *bs) +{ + do { + qemu_co_queue_restart_all(&bs->throttled_reqs); + qemu_aio_flush(); + } while (!qemu_co_queue_empty(&bs->throttled_reqs)); + + assert(QLIST_EMPTY(&bs->tracked_requests)); + assert(qemu_co_queue_empty(&bs->throttled_reqs)); +} + /* * Wait for pending requests to complete across all BlockDriverStates * @@ -863,7 +877,12 @@ void bdrv_drain_all(void) { BlockDriverState *bs; - qemu_aio_flush(); + QTAILQ_FOREACH(bs, &bdrv_states, list) { + do { + qemu_co_queue_restart_all(&bs->throttled_reqs); + qemu_aio_flush(); + } while (!qemu_co_queue_empty(&bs->throttled_reqs)); + } /* If requests are still pending there is a bug somewhere */ QTAILQ_FOREACH(bs, &bdrv_states, list) { diff --git a/block_int.h b/block_int.h index b460c36..c624399 100644 --- a/block_int.h +++ b/block_int.h @@ -318,6 +318,7 @@ void qemu_aio_release(void *p); void bdrv_set_io_limits(BlockDriverState *bs, BlockIOLimit *io_limits); +void bdrv_drain(BlockDriverState *bs); #ifdef _WIN32 int is_windows_drive(const char *filename);