From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S79tL-0005qn-Bk for qemu-devel@nongnu.org; Mon, 12 Mar 2012 14:23:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S79tJ-0001iM-Iz for qemu-devel@nongnu.org; Mon, 12 Mar 2012 14:22:42 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:60335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S79tJ-0001hK-5j for qemu-devel@nongnu.org; Mon, 12 Mar 2012 14:22:41 -0400 Received: by mail-ey0-f173.google.com with SMTP id f11so1620836eaa.4 for ; Mon, 12 Mar 2012 11:22:40 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 12 Mar 2012 19:22:28 +0100 Message-Id: <1331576548-23067-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1331576548-23067-1-git-send-email-pbonzini@redhat.com> References: <1331576548-23067-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 7/7] 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: Zhi Yong Wu From: Zhi Yong Wu Signed-off-by: Zhi Yong Wu [ Iterate until all block devices have processed all requests, add comments. - Paolo ] Signed-off-by: Paolo Bonzini --- block.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index dac62a1..0d769a6 100644 --- a/block.c +++ b/block.c @@ -858,12 +858,31 @@ void bdrv_close_all(void) * * This function does not flush data to disk, use bdrv_flush_all() for that * after calling this function. + * + * Note that completion of an asynchronous I/O operation can trigger any + * number of other I/O operations on other devices---for example a coroutine + * can be arbitrarily complex and a constant flow of I/O to multiple devices + * can come until the coroutine is complete. Because of this, it is not + * possible to drain a single device's I/O queue. */ void bdrv_drain_all(void) { BlockDriverState *bs; + bool busy; - qemu_aio_flush(); + do { + busy = qemu_aio_wait(); + + /* 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.7.6