From: zwu.kernel@gmail.com
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com,
Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>,
zwu.kernel@gmail.com, stefanha@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH v2 1/2] block: add the support to drain throttled requests
Date: Mon, 12 Mar 2012 14:29:04 +0800 [thread overview]
Message-ID: <1331533744-15802-1-git-send-email-zwu.kernel@gmail.com> (raw)
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
block.c | 21 +++++++++++++++++++++
block_int.h | 1 +
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/block.c b/block.c
index 52ffe14..0825168 100644
--- a/block.c
+++ b/block.c
@@ -853,6 +853,21 @@ 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);
+ } while (!qemu_co_queue_empty(&bs->throttled_reqs));
+
+ qemu_aio_flush();
+
+ assert(QLIST_EMPTY(&bs->tracked_requests));
+ assert(qemu_co_queue_empty(&bs->throttled_reqs));
+}
+
/*
* Wait for pending requests to complete across all BlockDriverStates
*
@@ -863,6 +878,12 @@ void bdrv_drain_all(void)
{
BlockDriverState *bs;
+ QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ do {
+ qemu_co_queue_restart_all(&bs->throttled_reqs);
+ } while (!qemu_co_queue_empty(&bs->throttled_reqs));
+ }
+
qemu_aio_flush();
/* If requests are still pending there is a bug somewhere */
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
next reply other threads:[~2012-03-12 6:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-12 6:29 zwu.kernel [this message]
2012-03-12 7:27 ` [Qemu-devel] [PATCH v2 1/2] block: add the support to drain throttled requests Paolo Bonzini
2012-03-12 8:42 ` Zhi Yong Wu
2012-03-12 8:48 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331533744-15802-1-git-send-email-zwu.kernel@gmail.com \
--to=zwu.kernel@gmail.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
--cc=wuzhy@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.