From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From: zwu.kernel@gmail.com Date: Mon, 12 Mar 2012 22:53:25 +0800 Message-Id: <1331564005-31070-1-git-send-email-zwu.kernel@gmail.com> Subject: [Qemu-devel] [PATCH v3 1/2] block: add the support to drain throttled requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, Zhi Yong Wu , zwu.kernel@gmail.com, stefanha@linux.vnet.ibm.com 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); -- 1.7.6