[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 03/10] block: Move recursion to bdrv_set_aio_context
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH 03/10] block: Move recursion to bdrv_set_aio_context() |
Date: |
Mon, 6 May 2019 19:17:58 +0200 |
Instead of having two recursions, in bdrv_attach_aio_context() and in
bdrv_detach_aio_context(), just having one recursion is enough. Said
functions are only about a single node now.
It is important that the recursion doesn't happen between detaching and
attaching a context to the current node because the nested call will
drain the node, and draining with a NULL context would segfault.
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/block.c b/block.c
index 00332c1eb4..e36c72e297 100644
--- a/block.c
+++ b/block.c
@@ -5680,7 +5680,6 @@ static void
bdrv_do_remove_aio_context_notifier(BdrvAioNotifier *ban)
static void bdrv_detach_aio_context(BlockDriverState *bs)
{
BdrvAioNotifier *baf, *baf_tmp;
- BdrvChild *child;
assert(!bs->walking_aio_notifiers);
bs->walking_aio_notifiers = true;
@@ -5699,9 +5698,6 @@ static void bdrv_detach_aio_context(BlockDriverState *bs)
if (bs->drv && bs->drv->bdrv_detach_aio_context) {
bs->drv->bdrv_detach_aio_context(bs);
}
- QLIST_FOREACH(child, &bs->children, next) {
- bdrv_detach_aio_context(child->bs);
- }
if (bs->quiesce_counter) {
aio_enable_external(bs->aio_context);
@@ -5713,7 +5709,6 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
AioContext *new_context)
{
BdrvAioNotifier *ban, *ban_tmp;
- BdrvChild *child;
if (bs->quiesce_counter) {
aio_disable_external(new_context);
@@ -5721,9 +5716,6 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
bs->aio_context = new_context;
- QLIST_FOREACH(child, &bs->children, next) {
- bdrv_attach_aio_context(child->bs, new_context);
- }
if (bs->drv && bs->drv->bdrv_attach_aio_context) {
bs->drv->bdrv_attach_aio_context(bs, new_context);
}
@@ -5745,11 +5737,18 @@ static void bdrv_attach_aio_context(BlockDriverState
*bs,
* the same as the current context of bs). */
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
{
+ BdrvChild *child;
+
if (bdrv_get_aio_context(bs) == new_context) {
return;
}
bdrv_drained_begin(bs);
+
+ QLIST_FOREACH(child, &bs->children, next) {
+ bdrv_set_aio_context(child->bs, new_context);
+ }
+
bdrv_detach_aio_context(bs);
/* This function executes in the old AioContext so acquire the new one in
--
2.20.1
- [Qemu-block] [PATCH 00/10] block: AioContext management, part 1, Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 01/10] block: Add bdrv_try_set_aio_context(), Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 02/10] block: Make bdrv_attach/detach_aio_context() static, Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 03/10] block: Move recursion to bdrv_set_aio_context(),
Kevin Wolf <=
- [Qemu-block] [PATCH 04/10] block: Propagate AioContext change to parents, Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 05/10] test-block-iothread: Test AioContext propagation through the tree, Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 06/10] block: Implement .(can_)set_aio_ctx for BlockBackend, Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 07/10] block: Add blk_set_allow_aio_context_change(), Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 09/10] blockjob: Remove AioContext notifiers, Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 08/10] blockjob: Propagate AioContext change to all job nodes, Kevin Wolf, 2019/05/06
- [Qemu-block] [PATCH 10/10] test-block-iothread: Test AioContext propagation for block jobs, Kevin Wolf, 2019/05/06
- Re: [Qemu-block] [PATCH 00/10] block: AioContext management, part 1, Kevin Wolf, 2019/05/20