Skip to content

block: Re-enable the graph lock

Kevin Wolf qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest11 patches 3 repliesIn review
  2. v111 patches 1 replySuperseded

Changes in v2 from the cover letter

- Fixed patch 2 to actually lock the correct AioContext even if the device doesn't support iothreads
- Improved the commit message for patch 7 [Eric]
- Fixed mismerge in patch 11 (v1 incorrectly left an #if 0 around)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11iotests: Test active commit with iothread and background I/Otests/qemu-iotests/tests/iothreads-commit-active tests/qemu-iotests/tests/iothreads-commit-active.out+108 -00 replies
2/11qdev-properties-system: Lock AioContext for blk_insert_bs()hw/core/qdev-properties-system.c+6 -20 replies
3/11test-block-iothread: Lock AioContext for blk_insert_bs()tests/unit/test-block-iothread.c+6 -10 replies
4/11block: Fix AioContext locking in bdrv_open_child()block.c+11 -20 replies
5/11block: Fix AioContext locking in bdrv_attach_child_common()block.c+20 -10 replies
6/11block: Fix AioContext locking in bdrv_reopen_parse_file_or_backing()block.c+33 -20 replies
7/11block: Fix AioContext locking in bdrv_open_inherit()block.c+24 -10 replies
8/11block: Fix AioContext locking in bdrv_open_backing_file()block.c+5 -00 replies
9/11blockjob: Fix AioContext locking in block_job_add_bdrv()blockjob.c+12 -50 replies
10/11graph-lock: Unlock the AioContext while pollingblock.c block/graph-lock.c include/block/graph-lock.h+28 -50 replies
11/11Revert "graph-lock: Disable locking for now"block/graph-lock.c+0 -252 replies

Reviews trailers per patch

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

PatchStefan Hajnoczi
SeriesR-b
1/11
2/11
3/11
4/11
5/11
6/11
7/11
8/11
9/11
10/11
11/11

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

Read the v2 thread

Cover letter [PATCH v2 00/11] block: Re-enable the graph lock

This series fixes the deadlock that was observed before commit ad128dff ('graph-lock: Disable locking for now'), which just disabled the graph lock completely as a workaround to get 8.0.1 stable.

In theory the problem is simple: We can't poll while still holding the lock of a different AioContext. So bdrv_graph_wrlock() just needs to drop that lock before it polls. However, there are a number of callers that don't even hold the AioContext lock they are supposed to hold, so temporarily unlocking tries to unlock a mutex that isn't locked, resulting in assertion failures.

Therefore, much of this series is just for fixing AioContext locking correctness. It is only the last two patches that actually fix the deadlock and reenable the graph locking.

v2:
- Fixed patch 2 to actually lock the correct AioContext even if the device doesn't support iothreads
- Improved the commit message for patch 7 [Eric]
- Fixed mismerge in patch 11 (v1 incorrectly left an #if 0 around)

Kevin Wolf (11):
iotests: Test active commit with iothread and background I/O
qdev-properties-system: Lock AioContext for blk_insert_bs()
test-block-iothread: Lock AioContext for blk_insert_bs()
block: Fix AioContext locking in bdrv_open_child()
block: Fix AioContext locking in bdrv_attach_child_common()
block: Fix AioContext locking in bdrv_reopen_parse_file_or_backing()
block: Fix AioContext locking in bdrv_open_inherit()
block: Fix AioContext locking in bdrv_open_backing_file()
blockjob: Fix AioContext locking in block_job_add_bdrv()
graph-lock: Unlock the AioContext while polling
Revert "graph-lock: Disable locking for now"

 include/block/graph-lock.h                    |   6 +-
 block.c                                       | 103 ++++++++++++++++--
 block/graph-lock.c                            |  42 ++++---
 blockjob.c                                    |  17 ++-
 hw/core/qdev-properties-system.c              |   8 +-
 tests/unit/test-block-iothread.c              |   7 +-
 .../tests/iothreads-commit-active             |  85 +++++++++++++++
 .../tests/iothreads-commit-active.out         |  23 ++++
 8 files changed, 250 insertions(+), 41 deletions(-)
 create mode 100755 tests/qemu-iotests/tests/iothreads-commit-active
 create mode 100644 tests/qemu-iotests/tests/iothreads-commit-active.out
Signature · 1 line
2.40.1