[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/18] block: wrlock in bdrv_replace_child_noperm
From: |
Kevin Wolf |
Subject: |
[PATCH 11/18] block: wrlock in bdrv_replace_child_noperm |
Date: |
Wed, 7 Dec 2022 14:18:31 +0100 |
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Protect the main function where graph is modified.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 44d59362d6..df52c6b012 100644
--- a/block.c
+++ b/block.c
@@ -2836,8 +2836,6 @@ uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission
qapi_perm)
*
* If @new_bs is non-NULL, the parent of @child must already be drained through
* @child.
- *
- * This function does not poll.
*/
static void bdrv_replace_child_noperm(BdrvChild *child,
BlockDriverState *new_bs)
@@ -2875,23 +2873,24 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
assert(bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs));
}
+ /* TODO Pull this up into the callers to avoid polling here */
+ bdrv_graph_wrlock();
if (old_bs) {
if (child->klass->detach) {
child->klass->detach(child);
}
- assert_bdrv_graph_writable(old_bs);
QLIST_REMOVE(child, next_parent);
}
child->bs = new_bs;
if (new_bs) {
- assert_bdrv_graph_writable(new_bs);
QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
if (child->klass->attach) {
child->klass->attach(child);
}
}
+ bdrv_graph_wrunlock();
/*
* If the parent was drained through this BdrvChild previously, but new_bs
--
2.38.1
- [PATCH 00/18] block: Introduce a block graph rwlock, Kevin Wolf, 2022/12/07
- [PATCH 01/18] block: Factor out bdrv_drain_all_begin_nopoll(), Kevin Wolf, 2022/12/07
- [PATCH 02/18] graph-lock: Introduce a lock to protect block graph operations, Kevin Wolf, 2022/12/07
- [PATCH 03/18] graph-lock: Implement guard macros, Kevin Wolf, 2022/12/07
- [PATCH 04/18] async: Register/unregister aiocontext in graph lock list, Kevin Wolf, 2022/12/07
- [PATCH 05/18] Import clang-tsa.h, Kevin Wolf, 2022/12/07
- [PATCH 07/18] clang-tsa: Add macros for shared locks, Kevin Wolf, 2022/12/07
- [PATCH 08/18] configure: Enable -Wthread-safety if present, Kevin Wolf, 2022/12/07
- [PATCH 10/18] block: Fix locking in external_snapshot_prepare(), Kevin Wolf, 2022/12/07
- [PATCH 12/18] block: remove unnecessary assert_bdrv_graph_writable(), Kevin Wolf, 2022/12/07
- [PATCH 11/18] block: wrlock in bdrv_replace_child_noperm,
Kevin Wolf <=
- [PATCH 06/18] clang-tsa: Add TSA_ASSERT() macro, Kevin Wolf, 2022/12/07
- [PATCH 14/18] graph-lock: TSA annotations for lock/unlock functions, Kevin Wolf, 2022/12/07
- [PATCH 13/18] block: assert that graph read and writes are performed correctly, Kevin Wolf, 2022/12/07
- [PATCH 16/18] block-coroutine-wrapper.py: introduce annotations that take the graph rdlock, Kevin Wolf, 2022/12/07
- [PATCH 15/18] Mark assert_bdrv_graph_readable/writable() GRAPH_RD/WRLOCK, Kevin Wolf, 2022/12/07
- [PATCH 17/18] block: use co_wrapper_mixed_bdrv_rdlock in functions taking the rdlock, Kevin Wolf, 2022/12/07
- [PATCH 18/18] block: GRAPH_RDLOCK for functions only called by co_wrappers, Kevin Wolf, 2022/12/07
- [PATCH 09/18] test-bdrv-drain: Fix incorrrect drain assumptions, Kevin Wolf, 2022/12/07
- Re: [PATCH 00/18] block: Introduce a block graph rwlock, Emanuele Giuseppe Esposito, 2022/12/07