block: add the support to drain throttled requests
PATCH v2 1/2 block: add the support to drain throttled requests
From: Zhi Yong Wu <[email protected]>
--- block.c | 21 +++++++++++++++++++++ block_int.h | 1 + 2 files changed, 22 insertions(+), 0 deletions(-)
block.c +21 -0
@@ -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 */
block_int.h +1 -0
@@ -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 _WIN32int is_windows_drive (const char *filename);
Signature · 1 line
1.7.6
Il 12/03/2012 07:29, [email protected] ha scritto:
Quoted 16 lines
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>--- block.c | 21 +++++++++++++++++++++ block_int.h | 1 + 2 files changed, 22 insertions(+), 0 deletions(-)block.c +0
-0@@ -853,6 +853,21 @@ void bdrv_close_all(void) } }
block.c void bdrv_close_all(void) · line 865
Quoted 10 lines
block.c +10
-0+/** +* 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 ();
This doesn't work, qemu_aio_flush can start new I/O.
Paolo
Quoted 17 lines · Paolo Bonzini
Il 12/03/2012 07:29, [email protected] ha scritto:
Quoted 16 lines
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>---
block.c | 21 +++++++++++++++++++++
block_int.h | 1 +2 files changed, 22 insertions(+), 0 deletions(-)block.c +0
-0@@ -853,6 +853,21 @@ void bdrv_close_all(void) } }
Quoted 12 lines
block.c void bdrv_close_all(void) · line 865
Quoted 10 lines
block.c +10
-0+/** +* 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();This doesn't work,
qemu_aio_flushcan start new I/O.
Do you mean that it will start next I/O via the current request's cb? if no, where will it start new I/O?
Quoted 4 lines
Paolo
Signature · 3 lines
Regards, Zhi Yong Wu
Il 12/03/2012 09:42, Zhi Yong Wu ha scritto:
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
This doesn't work,
qemu_aio_flushcan start new I/O.Do you mean that it will start next I/O via the current request's cb?
Yes.
Paolo