[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 11/21] parallels: Mark parallels_inactivate GRAPH_RDLOCK, guar
From: |
Alexander Ivanov |
Subject: |
[PATCH v3 11/21] parallels: Mark parallels_inactivate GRAPH_RDLOCK, guard parallels_close |
Date: |
Fri, 27 Oct 2023 09:46:26 +0200 |
Add GRAPH_RDLOCK annotation to declare parallels_inactivate() have to hold
a reader lock for the graph because it calls
bdrv_get_device_or_node_name(), which accesses the parents list of a node.
Assert we are in the main thread in parallels_close() and guard the code
with GRAPH_RDLOCK_GUARD_MAINLOOP().
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
block/parallels.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index 2d82e8ff6a..4c2cb09e43 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -1465,7 +1465,7 @@ fail:
return ret;
}
-static int parallels_inactivate(BlockDriverState *bs)
+static int GRAPH_RDLOCK parallels_inactivate(BlockDriverState *bs)
{
BDRVParallelsState *s = bs->opaque;
Error *err = NULL;
@@ -1491,10 +1491,13 @@ static int parallels_inactivate(BlockDriverState *bs)
return ret;
}
-static void parallels_close(BlockDriverState *bs)
+static void GRAPH_UNLOCKED parallels_close(BlockDriverState *bs)
{
BDRVParallelsState *s = bs->opaque;
+ GLOBAL_STATE_CODE();
+ GRAPH_RDLOCK_GUARD_MAINLOOP();
+
if ((bs->open_flags & BDRV_O_RDWR) && !(bs->open_flags & BDRV_O_INACTIVE))
{
parallels_inactivate(bs);
}
--
2.34.1
- [PATCH v3 17/21] parallels: Check unused clusters in parallels_check_leak(), (continued)
- [PATCH v3 17/21] parallels: Check unused clusters in parallels_check_leak(), Alexander Ivanov, 2023/10/27
- [PATCH v3 20/21] tests: Turned on 256, 299, 304 and block-status-cache for parallels format, Alexander Ivanov, 2023/10/27
- [PATCH v3 04/21] parallels: Add parallels_mark_unused() helper, Alexander Ivanov, 2023/10/27
- [PATCH v3 15/21] parallels: Reverse a conditional in parallels_check_leak() to reduce indents, Alexander Ivanov, 2023/10/27
- [PATCH v3 08/21] parallels: Add a note about used bitmap in parallels_check_duplicate(), Alexander Ivanov, 2023/10/27
- [PATCH v3 19/21] tests: Add parallels images support to test 165, Alexander Ivanov, 2023/10/27
- [PATCH v3 07/21] parallels: Recreate used bitmap in parallels_check_leak(), Alexander Ivanov, 2023/10/27
- [PATCH v3 16/21] parallels: Truncate images on the last used cluster, Alexander Ivanov, 2023/10/27
- [PATCH v3 12/21] parallels: Let image extensions work in RW mode, Alexander Ivanov, 2023/10/27
- [PATCH v3 06/21] parallels: Set data_end value in parallels_check_leak(), Alexander Ivanov, 2023/10/27
- [PATCH v3 11/21] parallels: Mark parallels_inactivate GRAPH_RDLOCK, guard parallels_close,
Alexander Ivanov <=