Skip to content

block: Some multi-threading fixes

Hanna Czenczek qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest19 patches 11 repliesIn review
  2. v116 patches 19 repliesSuperseded

Changes in v2 from the cover letter

- Kept .ret = EINPGORESS-style initializations where they already had been (curl, nvme)
- Dropped trivial BH waking code (i.e. which can be directly replaced by aio_co_wake()) in iscsi, nfs, nvme
- curl: Yield in curl_do_preadv() (former curl_setup_preadv()) and curl_find_buf() instead of returning whether curl_co_preadv() has to yield or not
- nvme: Added a patch that annotates some functions (primarily BHs and CBs) with which AioContext they (must) run in
- qcow2 cache-cleaning timer: Run the timer as a coroutine instead of in a timer CB; use a CoQueue to await it exiting instead of polling (well, we still need to poll in case we don’t run in a coroutine, but that’s standard procedure, I believe)
- The need to initialize the CoQueue showed that there is a code path in qcow2 that doesn’t initialize its CoMutex. Added a patch to do that.
- Also added a patch to have the timer use realtime instead of virtual time.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19block: Note on aio_co_wake use if not yet yieldinginclude/block/aio.h+15 -00 replies
2/19rbd: Run co BH CB in the coroutine’s AioContextblock/rbd.c+4 -80 replies
3/19iscsi: Run co BH CB in the coroutine’s AioContextblock/iscsi.c+21 -350 replies
4/19nfs: Run co BH CB in the coroutine’s AioContextblock/nfs.c+16 -255 replies
5/19curl: Fix coroutine wakingblock/curl.c+31 -140 replies
6/19gluster: Do not move coroutine into BDS contextblock/gluster.c+11 -60 replies
7/19nvme: Kick and check completions in BDS contextblock/nvme.c+13 -10 replies
8/19nvme: Fix coroutine wakingblock/nvme.c+29 -270 replies
9/19nvme: Note in which AioContext some functions runblock/nvme.c+34 -90 replies
10/19block/io: Take reqs_lock for tracked_requestsblock/io.c+3 -00 replies
11/19qcow2: Re-initialize lock in invalidate_cacheblock/qcow2.c+2 -00 replies
12/19qcow2: Fix cache_clean_timerblock/qcow2.c block/qcow2.h+118 -304 replies
13/19qcow2: Schedule cache-clean-timer in realtimeblock/qcow2.c+1 -10 replies
14/19ssh: Run restart_coroutine in current AioContextblock/ssh.c+11 -110 replies
15/19blkreplay: Run BH in coroutine’s AioContextblock/blkreplay.c+2 -10 replies
16/19block: Note in which AioContext AIO CBs are calledinclude/block/block_int-common.h+6 -10 replies
17/19iscsi: Create AIO BH in original AioContextblock/iscsi.c+4 -30 replies
18/19null-aio: Run CB in original AioContextblock/null.c+3 -40 replies
19/19win32-aio: Run CB in original contextblock/win32-aio.c+24 -70 replies

Reviews trailers per patch

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

PatchKevin WolfStefan Hajnoczi
SeriesR-b R-b
1/19
2/19
3/19
4/19
5/19
6/19
7/19
8/19
9/19
10/19
11/19
12/19
13/19
14/19
15/19
16/19
17/19
18/19
19/19

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/19] block: Some multi-threading fixes

Hi,

See the v1 cover letter for a general overview:

https://lists.nongnu.org/archive/html/qemu-block/2025-10/msg00501.html

Changes in v2:
- Kept .ret = EINPGORESS-style initializations where they already had been (curl, nvme)
- Dropped trivial BH waking code (i.e. which can be directly replaced by aio_co_wake()) in iscsi, nfs, nvme
- curl: Yield in curl_do_preadv() (former curl_setup_preadv()) and curl_find_buf() instead of returning whether curl_co_preadv() has to yield or not
- nvme: Added a patch that annotates some functions (primarily BHs and CBs) with which AioContext they (must) run in
- qcow2 cache-cleaning timer: Run the timer as a coroutine instead of in a timer CB; use a CoQueue to await it exiting instead of polling (well, we still need to poll in case we don’t run in a coroutine, but that’s standard procedure, I believe)
- The need to initialize the CoQueue showed that there is a code path in qcow2 that doesn’t initialize its CoMutex. Added a patch to do that.
- Also added a patch to have the timer use realtime instead of virtual time.

git backport-diff against v1:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/19:[----] [--] 'block: Note on aio_co_wake use if not yet yielding' 002/19:[----] [--] 'rbd: Run co BH CB in the coroutine’s AioContext' 003/19:[0019] [FC] 'iscsi: Run co BH CB in the coroutine’s AioContext' 004/19:[0022] [FC] 'nfs: Run co BH CB in the coroutine’s AioContext' 005/19:[0060] [FC] 'curl: Fix coroutine waking' 006/19:[----] [--] 'gluster: Do not move coroutine into BDS context' 007/19:[----] [--] 'nvme: Kick and check completions in BDS context' 008/19:[0038] [FC] 'nvme: Fix coroutine waking' 009/19:[down] 'nvme: Note in which AioContext some functions run' 010/19:[----] [--] 'block/io: Take reqs_lock for tracked_requests' 011/19:[down] 'qcow2: Re-initialize lock in invalidate_cache' 012/19:[0145] [FC] 'qcow2: Fix cache_clean_timer' 013/19:[down] 'qcow2: Schedule cache-clean-timer in realtime' 014/19:[----] [--] 'ssh: Run restart_coroutine in current AioContext' 015/19:[----] [--] 'blkreplay: Run BH in coroutine’s AioContext' 016/19:[----] [--] 'block: Note in which AioContext AIO CBs are called' 017/19:[----] [--] 'iscsi: Create AIO BH in original AioContext' 018/19:[----] [--] 'null-aio: Run CB in original AioContext' 019/19:[----] [--] 'win32-aio: Run CB in original context'

Hanna Czenczek (19):
block: Note on aio_co_wake use if not yet yielding
rbd: Run co BH CB in the coroutine’s AioContext
iscsi: Run co BH CB in the coroutine’s AioContext
nfs: Run co BH CB in the coroutine’s AioContext
curl: Fix coroutine waking
gluster: Do not move coroutine into BDS context
nvme: Kick and check completions in BDS context
nvme: Fix coroutine waking
nvme: Note in which AioContext some functions run block/io: Take reqs_lock for tracked_requests
qcow2: Re-initialize lock in invalidate_cache
qcow2: Fix cache_clean_timer
qcow2: Schedule cache-clean-timer in realtime
ssh: Run restart_coroutine in current AioContext
blkreplay: Run BH in coroutine’s AioContext
block: Note in which AioContext AIO CBs are called
iscsi: Create AIO BH in original AioContext
null-aio: Run CB in original AioContext
win32-aio: Run CB in original context

 block/qcow2.h                    |   5 +-
 include/block/aio.h              |  15 ++++
 include/block/block_int-common.h |   7 +-
 block/blkreplay.c                |   3 +-
 block/curl.c                     |  45 +++++++---
 block/gluster.c                  |  17 ++--
 block/io.c                       |   3 +
 block/iscsi.c                    |  63 ++++++--------
 block/nfs.c                      |  41 ++++-----
 block/null.c                     |   7 +-
 block/nvme.c                     | 113 ++++++++++++++++--------
 block/qcow2.c                    | 145 ++++++++++++++++++++++++-------
 block/rbd.c                      |  12 +--
 block/ssh.c                      |  22 ++---
 block/win32-aio.c                |  31 +++++--
 15 files changed, 347 insertions(+), 182 deletions(-)
Signature · 1 line
2.51.1