[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 44/51] block: wrlock in bdrv_replace_child_noperm
From: |
Kevin Wolf |
Subject: |
[PULL 44/51] block: wrlock in bdrv_replace_child_noperm |
Date: |
Wed, 14 Dec 2022 14:44:46 +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>
Message-Id: <20221207131838.239125-12-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@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
- [PULL 22/51] nbd/server.c: add coroutine_fn annotations, (continued)
- [PULL 22/51] nbd/server.c: add coroutine_fn annotations, Kevin Wolf, 2022/12/14
- [PULL 31/51] block-coroutine-wrapper.py: support also basic return types, Kevin Wolf, 2022/12/14
- [PULL 36/51] graph-lock: Implement guard macros, Kevin Wolf, 2022/12/14
- [PULL 25/51] block: avoid duplicating filename string in bdrv_create, Kevin Wolf, 2022/12/14
- [PULL 29/51] block-coroutine-wrapper.py: introduce co_wrapper, Kevin Wolf, 2022/12/14
- [PULL 27/51] block: bdrv_create_file is a coroutine_fn, Kevin Wolf, 2022/12/14
- [PULL 32/51] block: convert bdrv_create to co_wrapper, Kevin Wolf, 2022/12/14
- [PULL 34/51] block: Factor out bdrv_drain_all_begin_nopoll(), Kevin Wolf, 2022/12/14
- [PULL 41/51] configure: Enable -Wthread-safety if present, Kevin Wolf, 2022/12/14
- [PULL 38/51] Import clang-tsa.h, Kevin Wolf, 2022/12/14
- [PULL 44/51] block: wrlock in bdrv_replace_child_noperm,
Kevin Wolf <=
- [PULL 40/51] clang-tsa: Add macros for shared locks, Kevin Wolf, 2022/12/14
- [PULL 37/51] async: Register/unregister aiocontext in graph lock list, Kevin Wolf, 2022/12/14
- [PULL 45/51] block: remove unnecessary assert_bdrv_graph_writable(), Kevin Wolf, 2022/12/14
- [PULL 49/51] block-coroutine-wrapper.py: introduce annotations that take the graph rdlock, Kevin Wolf, 2022/12/14
- [PULL 16/51] block: Remove ignore_bds_parents parameter from drain_begin/end., Kevin Wolf, 2022/12/14
- [PULL 48/51] Mark assert_bdrv_graph_readable/writable() GRAPH_RD/WRLOCK, Kevin Wolf, 2022/12/14
- [PULL 24/51] block/vmdk: add coroutine_fn annotations, Kevin Wolf, 2022/12/14
- [PULL 28/51] block: rename generated_co_wrapper in co_wrapper_mixed, Kevin Wolf, 2022/12/14
- [PULL 39/51] clang-tsa: Add TSA_ASSERT() macro, Kevin Wolf, 2022/12/14
- [PULL 35/51] graph-lock: Introduce a lock to protect block graph operations, Kevin Wolf, 2022/12/14