Skip to content

block: Start/end drain on correct AioContext

Hanna Reitz qemu-devel 2 versions – Applied

Status from this message: Thanks, applied to the block branch.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 5 repliesApplied
  2. v13 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Patch 1:
- Move bdrv_child_get_parent_aio_context() from block-global-state.h to block-io.h
- Move BdrvChildClass.get_parent_aio_context into the I/O code section
- Mark blk_root_get_parent_aio_context() as I/O code
- Mark child_job_get_parent_aio_context(), and lock the job mutex, which we now need to do (as of 3ed4f708fe1)
- Patch 2:
- Added comment similar to Kevin’s suggestion
(Still decided to take Kevin’s R-b, even though I didn’t use the literal suggestion, but made it a bit more verbose)

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3block: Make bdrv_child_get_parent_aio_context I/Oblock.c block/block-backend.c blockjob.c +3 more+8 -50 replies
2/3block-backend: Update ctx immediately after rootblock/block-backend.c+7 -10 replies
3/3block: Start/end drain on correct AioContextblock/io.c+4 -20 replies

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchKevin Wolf
1/3
2/3R-b
3/3R-b

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 0/3] block: Start/end drain on correct AioContext

Hi,

v1 cover letter:
https://lists.nongnu.org/archive/html/qemu-block/2022-09/msg00389.html

bdrv_replace_child_noperm() drains the child via bdrv_parent_drained_{begin,end}_single(). When it removes a child, the bdrv_parent_drained_end_single() at its end will be called on an empty child, making the BDRV_POLL_WHILE() in it poll the main AioContext (because c->bs is NULL).

That’s wrong, though, because it’s supposed to operate on the parent. bdrv_parent_drained_end_single_no_poll() will have scheduled any BHs in the parents’ AioContext, which may be anything, not necessarily the main context. Therefore, we must poll the parent’s context.

Patch 3 does this for both bdrv_parent_drained_{begin,end}_single(). Patch 1 ensures that we can legally call bdrv_child_get_parent_aio_context() from those I/O context functions, and patch 2 fixes blk_do_set_aio_context() to not cause an assertion failure if it beginning a drain can end up in blk_get_aio_context() before blk->ctx has been updated.

v2:
- Patch 1:
- Move bdrv_child_get_parent_aio_context() from block-global-state.h to block-io.h
- Move BdrvChildClass.get_parent_aio_context into the I/O code section
- Mark blk_root_get_parent_aio_context() as I/O code
- Mark child_job_get_parent_aio_context(), and lock the job mutex, which we now need to do (as of 3ed4f708fe1)
- Patch 2:
- Added comment similar to Kevin’s suggestion
(Still decided to take Kevin’s R-b, even though I didn’t use the literal suggestion, but made it a bit more verbose)

Hanna Reitz (3):
block: Make bdrv_child_get_parent_aio_context I/O
block-backend: Update ctx immediately after root
block: Start/end drain on correct AioContext

 include/block/block-global-state.h | 1 -
 include/block/block-io.h           | 2 ++
 include/block/block_int-common.h   | 4 ++--
 block.c                            | 2 +-
 block/block-backend.c              | 9 ++++++++-
 block/io.c                         | 6 ++++--
 blockjob.c                         | 3 ++-
 7 files changed, 19 insertions(+), 8 deletions(-)
Signature · 1 line
2.36.1