block: get rid of bdrv_io_unplugged_begin/end
PATCH 1/1 block: get rid of bdrv_io_unplugged_begin/end
bdrv_io_plug and bdrv_io_unplug are only called (via their BlockBackend equivalents) after starting asynchronous I/O. bdrv_drain is not going to be called while they are running, because---even if a coroutine runs for some reason---it will only drain in the next iteration of the event loop through bdrv_co_yield_to_drain.
So this mechanism is unnecessary, get rid of it.
--- block/io.c | 41 ++--------------------------------------- include/block/block.h | 2 -- include/block/block_int.h | 3 +-- 3 files changed, 3 insertions(+), 43 deletions(-)
block/io.c +2 -39
@@ -228,9 +228,7 @@ void bdrv_drained_begin(BlockDriverState *bs)bdrv_parent_drained_begin (bs); } -bdrv_io_unplugged_begin (bs);bdrv_drain_recurse (bs); -bdrv_io_unplugged_end (bs); }void bdrv_drained_end (BlockDriverState *bs)
@@ -302,7 +300,6 @@ void bdrv_drain_all_begin(void)aio_context_acquire (aio_context);bdrv_parent_drained_begin (bs); -bdrv_io_unplugged_begin (bs);aio_disable_external (aio_context);aio_context_release (aio_context);
@@ -347,7 +344,6 @@ void bdrv_drain_all_end(void)aio_context_acquire (aio_context);aio_enable_external (aio_context); -bdrv_io_unplugged_end (bs);bdrv_parent_drained_end (bs);aio_context_release (aio_context); }
@@ -2650,7 +2646,7 @@ void bdrv_io_plug(BlockDriverState *bs)bdrv_io_plug (child->bs); } -if (bs->io_plugged++ ==0 && bs->io_plug_disabled ==0 ) { +if (bs->io_plugged++ ==0 ) {BlockDriver *drv = bs->drv;if (drv && drv->bdrv_io_plug) { drv->bdrv_io_plug (bs);
@@ -2663,7 +2659,7 @@ void bdrv_io_unplug(BlockDriverState *bs)BdrvChild *child;assert (bs->io_plugged); -if (--bs->io_plugged ==0 && bs->io_plug_disabled ==0 ) { +if (--bs->io_plugged ==0 ) {BlockDriver *drv = bs->drv;if (drv && drv->bdrv_io_unplug) { drv->bdrv_io_unplug (bs);
@@ -2674,36 +2670,3 @@ void bdrv_io_unplug(BlockDriverState *bs)bdrv_io_unplug (child->bs); } } - -void bdrv_io_unplugged_begin (BlockDriverState *bs) -{ -BdrvChild *child; - -if (bs->io_plug_disabled++ ==0 && bs->io_plugged >0 ) { -BlockDriver *drv = bs->drv; -if (drv && drv->bdrv_io_unplug) { - drv->bdrv_io_unplug (bs); - } - } - - QLIST_FOREACH(child, &bs->children, next) { -bdrv_io_unplugged_begin (child->bs); - } -} - -void bdrv_io_unplugged_end (BlockDriverState *bs) -{ -BdrvChild *child; - -assert (bs->io_plug_disabled); - QLIST_FOREACH(child, &bs->children, next) { -bdrv_io_unplugged_end (child->bs); - } - -if (--bs->io_plug_disabled ==0 && bs->io_plugged >0 ) { -BlockDriver *drv = bs->drv; -if (drv && drv->bdrv_io_plug) { - drv->bdrv_io_plug (bs); - } - } -}
include/block/block.h +0 -2
@@ -526,8 +526,6 @@ int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo);void bdrv_io_plug (BlockDriverState *bs);void bdrv_io_unplug (BlockDriverState *bs); -void bdrv_io_unplugged_begin (BlockDriverState *bs); -void bdrv_io_unplugged_end (BlockDriverState *bs);/** * bdrv_drained_begin:
include/block/block_int.h +1 -2
@@ -526,9 +526,8 @@ struct BlockDriverState {uint64_t write_threshold_offset;NotifierWithReturn write_threshold_notifier; -/* counters for nested bdrv_io_plug and bdrv_io_unplugged_begin */ +/* counter for nested bdrv_io_plug */ unsigned io_plugged; -unsigned io_plug_disabled;int quiesce_counter; };
Signature · 1 line
2.9.3
Quoted 120 lines · Paolo Bonzini
bdrv_io_plugandbdrv_io_unplugare only called (via their BlockBackend equivalents) after starting asynchronous I/O.bdrv_drainis not going to be called while they are running, because---even if a coroutine runs for some reason---it will only drain in the next iteration of the event loop throughbdrv_co_yield_to_drain.So this mechanism is unnecessary, get rid of it.
Signed-off-by Paolo Bonzini <[email protected]>--- block/io.c | 41 ++--------------------------------------- include/block/block.h | 2 -- include/block/block_int.h | 3 +-- 3 files changed, 3 insertions(+), 43 deletions(-)block/io.c +2
-39@@ -228,9 +228,7 @@ void bdrv_drained_begin(BlockDriverState *bs)bdrv_parent_drained_begin (bs); } -bdrv_io_unplugged_begin (bs);bdrv_drain_recurse (bs); -bdrv_io_unplugged_end (bs); }void bdrv_drained_end (BlockDriverState *bs)@@ -302,7 +300,6 @@ void bdrv_drain_all_begin(void)aio_context_acquire (aio_context);bdrv_parent_drained_begin (bs); -bdrv_io_unplugged_begin (bs);aio_disable_external (aio_context);aio_context_release (aio_context);@@ -347,7 +344,6 @@ void bdrv_drain_all_end(void)aio_context_acquire (aio_context);aio_enable_external (aio_context); -bdrv_io_unplugged_end (bs);bdrv_parent_drained_end (bs);aio_context_release (aio_context); }@@ -2650,7 +2646,7 @@ void bdrv_io_plug(BlockDriverState *bs)bdrv_io_plug (child->bs); } -if (bs->io_plugged++ ==0 && bs->io_plug_disabled ==0 ) { +if (bs->io_plugged++ ==0 ) {BlockDriver *drv = bs->drv;if (drv && drv->bdrv_io_plug) { drv->bdrv_io_plug (bs);@@ -2663,7 +2659,7 @@ void bdrv_io_unplug(BlockDriverState *bs)BdrvChild *child;assert (bs->io_plugged); -if (--bs->io_plugged ==0 && bs->io_plug_disabled ==0 ) { +if (--bs->io_plugged ==0 ) {BlockDriver *drv = bs->drv;if (drv && drv->bdrv_io_unplug) { drv->bdrv_io_unplug (bs);@@ -2674,36 +2670,3 @@ void bdrv_io_unplug(BlockDriverState *bs)bdrv_io_unplug (child->bs); } } - -void bdrv_io_unplugged_begin (BlockDriverState *bs) -{ -BdrvChild *child; - -if (bs->io_plug_disabled++ ==0 && bs->io_plugged >0 ) { -BlockDriver *drv = bs->drv; -if (drv && drv->bdrv_io_unplug) { - drv->bdrv_io_unplug (bs); - } - } - - QLIST_FOREACH(child, &bs->children, next) { -bdrv_io_unplugged_begin (child->bs); - } -} - -void bdrv_io_unplugged_end (BlockDriverState *bs) -{ -BdrvChild *child; - -assert (bs->io_plug_disabled); - QLIST_FOREACH(child, &bs->children, next) { -bdrv_io_unplugged_end (child->bs); - } - -if (--bs->io_plug_disabled ==0 && bs->io_plugged >0 ) { -BlockDriver *drv = bs->drv; -if (drv && drv->bdrv_io_plug) { - drv->bdrv_io_plug (bs); - } - } -}include/block/block.h +0
-2@@ -526,8 +526,6 @@ int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo);void bdrv_io_plug (BlockDriverState *bs);void bdrv_io_unplug (BlockDriverState *bs); -void bdrv_io_unplugged_begin (BlockDriverState *bs); -void bdrv_io_unplugged_end (BlockDriverState *bs);/** * bdrv_drained_begin: include/block/block_int.h +0
-0
include/block/block_int.h struct BlockDriverState { · line 533
Quoted 10 lines
include/block/block_int.h +1
-2@@ -526,9 +526,8 @@ struct BlockDriverState {uint64_t write_threshold_offset;NotifierWithReturn write_threshold_notifier; -/* counters for nested bdrv_io_plug and bdrv_io_unplugged_begin */ +/* counter for nested bdrv_io_plug */ unsigned io_plugged; -unsigned io_plug_disabled;int quiesce_counter; };
Ping?
Paolo
Stefan Hajnoczi
AppliedQuoted 7 lines · Paolo Bonzini
bdrv_io_plugandbdrv_io_unplugare only called (via their BlockBackend equivalents) after starting asynchronous I/O.bdrv_drainis not going to be called while they are running, because---even if a coroutine runs for some reason---it will only drain in the next iteration of the event loop throughbdrv_co_yield_to_drain.
Quoted 8 lines
So this mechanism is unnecessary, get rid of it.
Signed-off-by Paolo Bonzini <[email protected]>--- block/io.c | 41 ++--------------------------------------- include/block/block.h | 2 -- include/block/block_int.h | 3 +-- 3 files changed, 3 insertions(+), 43 deletions(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan