[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/22] block: Take graph rdlock in bdrv_inactivate_all()
From: |
Kevin Wolf |
Subject: |
[PATCH 03/22] block: Take graph rdlock in bdrv_inactivate_all() |
Date: |
Fri, 29 Sep 2023 16:51:38 +0200 |
The function reads the parents list, so it needs to hold the graph lock.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index e7f349b25c..73fd386076 100644
--- a/block.c
+++ b/block.c
@@ -6975,7 +6975,8 @@ void bdrv_activate_all(Error **errp)
}
}
-static bool bdrv_has_bds_parent(BlockDriverState *bs, bool only_active)
+static bool GRAPH_RDLOCK
+bdrv_has_bds_parent(BlockDriverState *bs, bool only_active)
{
BdrvChild *parent;
GLOBAL_STATE_CODE();
@@ -6992,14 +6993,13 @@ static bool bdrv_has_bds_parent(BlockDriverState *bs,
bool only_active)
return false;
}
-static int bdrv_inactivate_recurse(BlockDriverState *bs)
+static int GRAPH_RDLOCK bdrv_inactivate_recurse(BlockDriverState *bs)
{
BdrvChild *child, *parent;
int ret;
uint64_t cumulative_perms, cumulative_shared_perms;
GLOBAL_STATE_CODE();
- GRAPH_RDLOCK_GUARD_MAINLOOP();
if (!bs->drv) {
return -ENOMEDIUM;
@@ -7065,6 +7065,7 @@ int bdrv_inactivate_all(void)
GSList *aio_ctxs = NULL, *ctx;
GLOBAL_STATE_CODE();
+ GRAPH_RDLOCK_GUARD_MAINLOOP();
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *aio_context = bdrv_get_aio_context(bs);
--
2.41.0
- [PATCH 00/22] block: Graph locking part 5 (protect children/parent links), Kevin Wolf, 2023/09/29
- [PATCH 03/22] block: Take graph rdlock in bdrv_inactivate_all(),
Kevin Wolf <=
- [PATCH 02/22] block-coroutine-wrapper: Add no_co_wrapper_bdrv_rdlock functions, Kevin Wolf, 2023/09/29
- [PATCH 01/22] test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutine context, Kevin Wolf, 2023/09/29
- [PATCH 04/22] block: Mark bdrv_first_blk() and bdrv_is_root_node() GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 06/22] block: Mark bdrv_parent_cb_resize() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 05/22] block: Mark drain related functions GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 09/22] block: Mark bdrv_get_xdbg_block_graph() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 08/22] block: Take graph rdlock in parts of reopen, Kevin Wolf, 2023/09/29
- [PATCH 10/22] block: Mark bdrv_refresh_filename() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 11/22] block: Mark bdrv_primary_child() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 12/22] block: Mark bdrv_get_parent_name() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29