[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 24/26] block: Protect bs->parents with graph_lock
From: |
Kevin Wolf |
Subject: |
[PULL 24/26] block: Protect bs->parents with graph_lock |
Date: |
Thu, 12 Oct 2023 18:22:22 +0200 |
Almost all functions that access the parent link already take the graph
lock now. Add locking to the remaining user in a test case and finally
annotate the struct field itself as protected by the graph lock.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230929145157.45443-21-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block_int-common.h | 4 ++--
tests/unit/test-block-iothread.c | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 024262b5a2..0e37acd976 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -1043,7 +1043,7 @@ struct BdrvChild {
bool quiesced_parent;
QLIST_ENTRY(BdrvChild) next;
- QLIST_ENTRY(BdrvChild) next_parent;
+ QLIST_ENTRY(BdrvChild GRAPH_RDLOCK_PTR) next_parent;
};
/*
@@ -1180,7 +1180,7 @@ struct BlockDriverState {
BdrvChild *backing;
BdrvChild *file;
- QLIST_HEAD(, BdrvChild) parents;
+ QLIST_HEAD(, BdrvChild GRAPH_RDLOCK_PTR) parents;
QDict *options;
QDict *explicit_options;
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
index 151049bda5..9b15d2768c 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
@@ -471,11 +471,16 @@ static void test_sync_op(const void *opaque)
BlockDriverState *bs;
BdrvChild *c;
+ GLOBAL_STATE_CODE();
+
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
bs = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
bs->total_sectors = 65536 / BDRV_SECTOR_SIZE;
blk_insert_bs(blk, bs, &error_abort);
+
+ bdrv_graph_rdlock_main_loop();
c = QLIST_FIRST(&bs->parents);
+ bdrv_graph_rdunlock_main_loop();
blk_set_aio_context(blk, ctx, &error_abort);
aio_context_acquire(ctx);
--
2.41.0
- [PULL 09/26] block: Mark drain related functions GRAPH_RDLOCK, (continued)
- [PULL 09/26] block: Mark drain related functions GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 05/26] test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutine context, Kevin Wolf, 2023/10/12
- [PULL 13/26] block: Mark bdrv_get_xdbg_block_graph() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 19/26] qcow2: Mark qcow2_inactivate() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 12/26] block: Take graph rdlock in parts of reopen, Kevin Wolf, 2023/10/12
- [PULL 10/26] block: Mark bdrv_parent_cb_resize() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 01/26] block: rename the bdrv_co_block_status static function, Kevin Wolf, 2023/10/12
- [PULL 18/26] qcow2: Mark qcow2_signal_corruption() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 04/26] block: convert more bdrv_is_allocated* and bdrv_block_status* calls to coroutine versions, Kevin Wolf, 2023/10/12
- [PULL 22/26] block: Mark bdrv_apply_auto_read_only() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 24/26] block: Protect bs->parents with graph_lock,
Kevin Wolf <=
- [PULL 16/26] block: Mark bdrv_get_parent_name() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 25/26] block: Protect bs->children with graph_lock, Kevin Wolf, 2023/10/12
- [PULL 23/26] block: Mark bdrv_get_specific_info() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 26/26] block: Add assertion for bdrv_graph_wrlock(), Kevin Wolf, 2023/10/12
- [PULL 15/26] block: Mark bdrv_primary_child() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 21/26] block: Mark bdrv_op_is_blocked() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 08/26] block: Mark bdrv_first_blk() and bdrv_is_root_node() GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 20/26] qcow2: Mark check_constraints_on_bitmap() GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- Re: [PULL 00/26] Block layer patches, Stefan Hajnoczi, 2023/10/16