Skip to content

block: Honour graph read lock even in the main thread

Kevin Wolf qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8block: Call .bdrv_co_create(_opts) unlockedblock.c block/create.c block/crypto.c +11 more+78 -703 replies
2/8block/export: Fix null pointer dereference in error pathblock/export/export.c+4 -23 replies
3/8qcow2: Unlock the graph in qcow2_do_open() where necessaryblock/qcow2.c+6 -01 reply
4/8qemu-img: Take graph lock more selectivelyqemu-img.c+3 -21 reply
5/8test-bdrv-drain: Take graph lock more selectivelytests/unit/test-bdrv-drain.c+2 -21 reply
6/8test-bdrv-drain: Call bdrv_co_unref() in coroutine contexttests/unit/test-bdrv-drain.c+1 -11 reply
7/8blockjob: Adhere to rate limit even when reentered earlyblock/commit.c block/mirror.c block/stream.c +2 more+44 -291 reply
8/8graph-lock: Honour read locks even in the main threadblock/graph-lock.c+0 -101 reply

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/8R-b
2/8R-b T-b
3/8R-b
4/8R-b
5/8R-b
6/8R-b
7/8R-b
8/8R-b

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 0/8] block: Honour graph read lock even in the main thread

Fiona asked why it's correct that bdrv_graph_co_rd_lock/unlock() do nothing if qemu_in_main_thread() returns true. As far as I can tell, it's not correct. The coroutine can yield while it believes to have the lock, and then the main loop can call some code that takes a write lock without waiting for the coroutine to finish.

So this series - or more specifically the last patch - fixes this problem by enabling the locking even in the main thread. The patches before this are fixes for bugs that we hadn't discovered while they were only triggered with iothreads, and which are necessary so that all test cases still pass after the final patch.

Kevin Wolf (8):
block: Call .bdrv_co_create(_opts) unlocked block/export: Fix null pointer dereference in error path
qcow2: Unlock the graph in qcow2_do_open() where necessary
qemu-img: Take graph lock more selectively
test-bdrv-drain: Take graph lock more selectively
test-bdrv-drain: Call bdrv_co_unref() in coroutine context
blockjob: Adhere to rate limit even when reentered early
graph-lock: Honour read locks even in the main thread

 include/block/block-global-state.h |  8 +++---
 include/block/block_int-common.h   |  4 +--
 include/block/blockjob_int.h       | 14 +++++++---
 block.c                            |  1 -
 block/commit.c                     |  7 ++---
 block/create.c                     |  1 -
 block/crypto.c                     | 25 +++++++++--------
 block/export/export.c              |  6 +++--
 block/graph-lock.c                 | 10 -------
 block/mirror.c                     | 23 +++++++---------
 block/parallels.c                  |  6 ++---
 block/qcow.c                       |  6 ++---
 block/qcow2.c                      | 43 +++++++++++++++++++++---------
 block/qed.c                        |  6 ++---
 block/raw-format.c                 |  2 +-
 block/stream.c                     |  7 ++---
 block/vdi.c                        | 11 ++++----
 block/vhdx.c                       |  8 +++---
 block/vmdk.c                       | 27 +++++++++----------
 block/vpc.c                        |  6 ++---
 blockjob.c                         | 22 +++++++++++++--
 qemu-img.c                         |  5 ++--
 tests/unit/test-bdrv-drain.c       |  6 ++---
 23 files changed, 138 insertions(+), 116 deletions(-)
Signature · 1 line
2.40.1