Skip to content

block: Graph locking part 5 (protect children/parent links)

Kevin Wolf qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest22 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutine contexttests/unit/test-bdrv-drain.c+4 -30 replies
2/22block-coroutine-wrapper: Add no_co_wrapper_bdrv_rdlock functionsinclude/block/block-common.h scripts/block-coroutine-wrapper.py+12 -50 replies
3/22block: Take graph rdlock in bdrv_inactivate_all()block.c+4 -30 replies
4/22block: Mark bdrv_first_blk() and bdrv_is_root_node() GRAPH_RDLOCKblock.c block/block-backend.c block/export/export.c +11 more+53 -130 replies
5/22block: Mark drain related functions GRAPH_RDLOCKblock.c block/io.c include/block/block-io.h +2 more+54 -170 replies
6/22block: Mark bdrv_parent_cb_resize() and callers GRAPH_RDLOCKblock/io.c+9 -30 replies
7/22block: Mark bdrv_snapshot_fallback() and callers GRAPH_RDLOCKblock/snapshot.c blockdev.c include/block/block_int-common.h +2 more+67 -240 replies
8/22block: Take graph rdlock in parts of reopenblock.c include/block/block_int-common.h+43 -270 replies
9/22block: Mark bdrv_get_xdbg_block_graph() and callers GRAPH_RDLOCKblockdev.c include/block/block-global-state.h+3 -10 replies
10/22block: Mark bdrv_refresh_filename() and callers GRAPH_RDLOCKblock.c block/nfs.c block/qapi.c +9 more+101 -470 replies
11/22block: Mark bdrv_primary_child() and callers GRAPH_RDLOCKblock.c block/snapshot.c include/block/block_int-io.h+16 -30 replies
12/22block: Mark bdrv_get_parent_name() and callers GRAPH_RDLOCKblock.c block/backup.c block/parallels.c +14 more+55 -140 replies
13/22block: Mark bdrv_amend_options() and callers GRAPH_RDLOCKblock/crypto.c include/block/block-global-state.h include/block/block_int-common.h +1 more+16 -130 replies
14/22qcow2: Mark qcow2_signal_corruption() and callers GRAPH_RDLOCKblock.c block/block-backend.c block/qcow2-bitmap.c +8 more+250 -1920 replies
15/22qcow2: Mark qcow2_inactivate() and callers GRAPH_RDLOCKblock/qcow2.c+10 -50 replies
16/22qcow2: Mark check_constraints_on_bitmap() GRAPH_RDLOCKblock/qcow2-bitmap.c+3 -60 replies
17/22block: Mark bdrv_op_is_blocked() and callers GRAPH_RDLOCKblock.c block/block-backend.c block/commit.c +4 more+30 -50 replies
18/22block: Mark bdrv_apply_auto_read_only() and callers GRAPH_RDLOCKblock.c block/bochs.c block/cloop.c +7 more+22 -50 replies
19/22block: Mark bdrv_get_specific_info() and callers GRAPH_RDLOCKblock/vmdk.c include/block/block-io.h include/block/block_int-common.h +1 more+10 -80 replies
20/22block: Protect bs->parents with graph_lockinclude/block/block_int-common.h tests/unit/test-block-iothread.c+7 -20 replies
21/22block: Protect bs->children with graph_lockblock.c block/replication.c include/block/block_int-common.h +1 more+10 -30 replies
22/22block: Add assertion for bdrv_graph_wrlock()block/graph-lock.c include/block/graph-lock.h+4 -20 replies

Reviews trailers per patch

None of the 22 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchStefan Hajnoczi
SeriesR-b
1/22
2/22
3/22
4/22
5/22
6/22
7/22
8/22
9/22
10/22
11/22
12/22
13/22
14/22
15/22
16/22
17/22
18/22
19/22
20/22
21/22
22/22

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/22] block: Graph locking part 5 (protect children/parent links)

After all the preparation in previous series, this series reaches an important milestone for the graph locking work: TSA can now verify that all accesses to the children and parent lists of nodes happen under the graph lock.

However, this is not the end of the graph locking work yet. On the one hand, graph locking annotations aren't consistently present on all functions and having an unannotated function in the middle of the call chain means that TSA doesn't check if the locking is consistent (in fact, we know that functions like bdrv_unref() are still called in places where they strictly speaking must not be called).

On the other hand, the graph consists of more than just the children and parent lists. While it might be possible to convince me that the global node lists (graph_bdrv_states/all_bdrv_states) are safe because iothreads shouldn't access them, at least BlockDriverState.file/backing still need proper locking.

There may be other fields in BlockDriverState that need to be covered by the lock, too. For example, Stefan said that he would look into annotating BlockLimits accesses to be protected by the graph lock, too.

Emanuele Giuseppe Esposito (1):
block: Mark drain related functions GRAPH_RDLOCK

Kevin Wolf (21):
test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutine context
block-coroutine-wrapper: Add no_co_wrapper_bdrv_rdlock functions
block: Take graph rdlock in bdrv_inactivate_all()
block: Mark bdrv_first_blk() and bdrv_is_root_node() GRAPH_RDLOCK
block: Mark bdrv_parent_cb_resize() and callers GRAPH_RDLOCK
block: Mark bdrv_snapshot_fallback() and callers GRAPH_RDLOCK
block: Take graph rdlock in parts of reopen
block: Mark bdrv_get_xdbg_block_graph() and callers GRAPH_RDLOCK
block: Mark bdrv_refresh_filename() and callers GRAPH_RDLOCK
block: Mark bdrv_primary_child() and callers GRAPH_RDLOCK
block: Mark bdrv_get_parent_name() and callers GRAPH_RDLOCK
block: Mark bdrv_amend_options() and callers GRAPH_RDLOCK
qcow2: Mark qcow2_signal_corruption() and callers GRAPH_RDLOCK
qcow2: Mark qcow2_inactivate() and callers GRAPH_RDLOCK
qcow2: Mark check_constraints_on_bitmap() GRAPH_RDLOCK
block: Mark bdrv_op_is_blocked() and callers GRAPH_RDLOCK
block: Mark bdrv_apply_auto_read_only() and callers GRAPH_RDLOCK
block: Mark bdrv_get_specific_info() and callers GRAPH_RDLOCK
block: Protect bs->parents with graph_lock
block: Protect bs->children with graph_lock
block: Add assertion for bdrv_graph_wrlock()

 block/qcow2.h                               | 187 ++++++++++++--------
 block/vhdx.h                                |   5 +-
 include/block/block-common.h                |   7 +-
 include/block/block-global-state.h          |  34 ++--
 include/block/block-io.h                    |  42 +++--
 include/block/block_int-common.h            |  69 ++++----
 include/block/block_int-io.h                |   7 +-
 include/block/graph-lock.h                  |   3 +-
 include/block/qapi.h                        |  23 ++-
 include/block/snapshot.h                    |  24 +--
 include/sysemu/block-backend-global-state.h |   4 +-
 block.c                                     | 120 +++++++++----
 block/backup.c                              |   1 +
 block/block-backend.c                       |   9 +-
 block/bochs.c                               |   2 +
 block/cloop.c                               |   2 +
 block/commit.c                              |   1 +
 block/crypto.c                              |   4 +-
 block/curl.c                                |   2 +
 block/dmg.c                                 |   2 +
 block/export/export.c                       |   4 +
 block/gluster.c                             |   2 +
 block/graph-lock.c                          |   3 +-
 block/io.c                                  |  45 ++++-
 block/iscsi.c                               |   2 +
 block/monitor/block-hmp-cmds.c              |   5 +
 block/nbd.c                                 |   3 +-
 block/nfs.c                                 |   2 +-
 block/parallels.c                           |   3 +
 block/qapi-sysemu.c                         |  11 +-
 block/qapi.c                                |  11 +-
 block/qcow.c                                |   3 +
 block/qcow2-bitmap.c                        |  38 ++--
 block/qcow2-cache.c                         |  11 +-
 block/qcow2-cluster.c                       |  62 +++----
 block/qcow2-refcount.c                      |  80 +++++----
 block/qcow2.c                               |  72 +++++---
 block/quorum.c                              |   4 +-
 block/raw-format.c                          |   2 +
 block/rbd.c                                 |   4 +
 block/replication.c                         |  21 ++-
 block/snapshot.c                            |  54 +++++-
 block/vdi.c                                 |   3 +
 block/vhdx.c                                |   4 +
 block/vmdk.c                                |  53 +++---
 block/vpc.c                                 |   3 +
 block/vvfat.c                               |   2 +
 blockdev.c                                  |  44 +++++
 blockjob.c                                  |   1 +
 migration/block.c                           |   2 +
 migration/migration-hmp-cmds.c              |   2 +
 qemu-img.c                                  |  16 ++
 qemu-io-cmds.c                              |   3 +
 tests/unit/test-bdrv-drain.c                |  15 +-
 tests/unit/test-block-iothread.c            |   8 +
 scripts/block-coroutine-wrapper.py          |  10 +-
 56 files changed, 769 insertions(+), 387 deletions(-)
Signature · 1 line
2.41.0