[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 1/2] block: add the support to drain throttled re
From: |
zwu . kernel |
Subject: |
[Qemu-devel] [PATCH v3 1/2] block: add the support to drain throttled requests |
Date: |
Mon, 12 Mar 2012 22:53:25 +0800 |
From: Zhi Yong Wu <address@hidden>
Signed-off-by: Zhi Yong Wu <address@hidden>
---
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
- [Qemu-devel] [PATCH v3 1/2] block: add the support to drain throttled requests,
zwu . kernel <=