[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context
From: |
Sergio Lopez |
Subject: |
[PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore() |
Date: |
Mon, 14 Dec 2020 18:05:17 +0100 |
While processing the parents of a BDS, one of the parents may process
the child that's doing the tail recursion, which leads to a BDS being
processed twice. This is especially problematic for the aio_notifiers,
as they might attempt to work on both the old and the new AIO
contexts.
To avoid this, add the BDS pointer to the ignore list, and check the
child BDS pointer while iterating over the children.
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
block.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index f1cedac362..bc8a66ab6e 100644
--- a/block.c
+++ b/block.c
@@ -6465,12 +6465,17 @@ void bdrv_set_aio_context_ignore(BlockDriverState *bs,
bdrv_drained_begin(bs);
QLIST_FOREACH(child, &bs->children, next) {
- if (g_slist_find(*ignore, child)) {
+ if (g_slist_find(*ignore, child) || g_slist_find(*ignore, child->bs)) {
continue;
}
*ignore = g_slist_prepend(*ignore, child);
bdrv_set_aio_context_ignore(child->bs, new_context, ignore);
}
+ /*
+ * Add a reference to this BS to the ignore list, so its
+ * parents won't attempt to process it again.
+ */
+ *ignore = g_slist_prepend(*ignore, bs);
QLIST_FOREACH(child, &bs->parents, next_parent) {
if (g_slist_find(*ignore, child)) {
continue;
--
2.26.2
- [PATCH v2 0/4] nbd/server: Quiesce coroutines on context switch, Sergio Lopez, 2020/12/14
- [PATCH v2 1/4] block: Honor blk_set_aio_context() context requirements, Sergio Lopez, 2020/12/14
- [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(),
Sergio Lopez <=
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Kevin Wolf, 2020/12/15
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Sergio Lopez, 2020/12/15
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Kevin Wolf, 2020/12/15
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Sergio Lopez, 2020/12/15
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Kevin Wolf, 2020/12/16
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Sergio Lopez, 2020/12/16
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Kevin Wolf, 2020/12/16
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Sergio Lopez, 2020/12/17
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Kevin Wolf, 2020/12/17
- Re: [PATCH v2 2/4] block: Avoid processing BDS twice in bdrv_set_aio_context_ignore(), Vladimir Sementsov-Ogievskiy, 2020/12/17