block: add the support to drain throttled requests
PATCH v3 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, 21 insertions(+), 1 deletions(-)
block.c +20 -1
@@ -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) {
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 15:53, [email protected] ha scritto:
block.c void bdrv_drain_all(void) · line 885
Quoted 7 lines
block.c +6
-1-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)); + }
Even this is not enough. Block device 2 could start a throttled request on block device 1. I'm sending a related series, I'll include yours in mine.
Paolo
Quoted 10 lines · Paolo Bonzini
Il 12/03/2012 15:53, [email protected] ha scritto:
Quoted 7 lines
- 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));
+ }Even this is not enough. Block device 2 could start a throttled request
I think that this should be allowed here. It does not affect the final result. All throttled requests for all disks are drained.
Quoted 4 lines
on block device 1. I'm sending a related series, I'll include yours in mine.
Paolo
Signature · 3 lines
Regards, Zhi Yong Wu
Il 12/03/2012 16:25, Zhi Yong Wu ha scritto:
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
block.c +6
-1-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)); + }
Quoted 5 lines
Quoted 2 lines
Even this is not enough. Block device 2 could start a throttled request on block device 1.
I think that this should be allowed here. It does not affect the final result. All throttled requests for all disks are drained.
Unfortunately, that depends on the order of block devices. It needs to be something like this:
do {
qemu_aio_flush();
busy = false;
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);This means that bdrv_drain() cannot be implemented. The device models can "drain themselves", but for example monitor commands must still rely on bdrv_drain_all().
Paolo