From: zwu.kernel@gmail.com Subject: [PATCH 1/2] block: add the support to drain throttled requests Date: Tue, 27 Mar 2012 12:34:39 +0800 Message-ID: <1332822879-31524-1-git-send-email-zwu.kernel@gmail.com> Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com, kvm@vger.kernel.org, zwu.kernel@gmail.com, Zhi Yong Wu , pbonzini@redhat.com To: qemu-devel@nongnu.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org From: Zhi Yong Wu Signed-off-by: Zhi Yong Wu --- block.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index b88ee90..1fbf4dd 100644 --- a/block.c +++ b/block.c @@ -862,8 +862,22 @@ void bdrv_close_all(void) void bdrv_drain_all(void) { BlockDriverState *bs; + bool busy; - qemu_aio_flush(); + do { + busy = false; + qemu_aio_flush(); + + /* FIXME: We do not have timer support here, so this is effectively + * a busy wait. + */ + QTAILQ_FOREACH(bs, &bdrv_states, list) { + if (!qemu_co_queue_empty(&bs->throttled_reqs)) { + qemu_co_queue_restart_all(&bs->throttled_reqs); + busy = true; + } + } + } while (busy); /* If requests are still pending there is a bug somewhere */ QTAILQ_FOREACH(bs, &bdrv_states, list) { -- 1.7.6