Skip to content

block: bdrv_set_aio_context() related fixes

Kevin Wolf qemu-devel 2 versions – Applied

Status from this message: Applied to the block branch.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest13 patches 5 repliesApplied
  2. v112 patches 17 repliesSuperseded

Changes in v2 from the cover letter

- New patch 5: Remove now redundant assignments [Paolo]
- Patch 8 (was 7): Instead of using aio_co_schedule() to switch the AioContext and modifying the coroutine code, enter the coroutine in a BH in the new AioContext and bdrv_dec_in_flight() in that BH [Paolo]
- Patch 12 (was 11): Cover new == old case in comment [Eric]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/13block-backend: Make blk_inc/dec_in_flight publicblock/block-backend.c include/sysemu/block-backend.h+4 -20 replies
2/13virtio-blk: Increase in_flight for request restart BHhw/block/virtio-blk.c+4 -00 replies
3/13nbd: Restrict connection_co reentranceblock/nbd-client.c block/nbd-client.h+23 -00 replies
4/13io: Make qio_channel_yield() interruptibleinclude/io/channel.h io/channel.c+16 -30 replies
5/13io: Remove redundant read/write_coroutine assignmentsio/channel.c+6 -84 replies
6/13nbd: Move nbd_read_eof() to nbd/client.cinclude/block/nbd.h nbd/client.c nbd/nbd-internal.h+23 -210 replies
7/13nbd: Use low-level QIOChannel API in nbd_read_eof()block/nbd-client.c include/block/nbd.h nbd/client.c+40 -180 replies
8/13nbd: Increase bs->in_flight during AioContext switchblock/nbd-client.c+18 -20 replies
9/13block: Don't poll in bdrv_set_aio_context()block.c+0 -40 replies
10/13block: Fix AioContext switch for drained nodeblock.c+7 -00 replies
11/13test-bdrv-drain: AioContext switch in drained sectiontests/test-bdrv-drain.c+32 -00 replies
12/13block: Use normal drain for bdrv_set_aio_context()block.c+6 -90 replies
13/13aio-posix: Assert that aio_poll() is always called in home threadutil/aio-posix.c+2 -10 replies

Reviews trailers per patch

7 of 13 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/13
2/13
3/13R-b
4/13
5/13
6/13R-b
7/13R-b
8/13
9/13R-b
10/13R-b
11/13R-b
12/13
13/13R-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 [Qemu-devel] [PATCH v2 00/13] block: bdrv_set_aio_context() related fixes

Background for this series is the following bug report, which is about a crash with virtio-blk + iothread and request resubmission for werror/rerror:

https://bugzilla.redhat.com/show_bug.cgi?id=1671173

The reason is that bdrv_set_aio_context() didn't correctly quiesce everything. Instead, it had a local hack to call aio_poll() for the source AioContext, which covered some, but not all cases, and is wrong because you can only call aio_poll() from the home thread.

So this series tries to make bdrv_drain() actually drain the known cases (fixes virtio-blk and the NBD client) and use the regular drain functions in bdrv_set_aio_context() instead of open-coding something similar.

v2:
- New patch 5: Remove now redundant assignments [Paolo]
- Patch 8 (was 7): Instead of using aio_co_schedule() to switch the AioContext and modifying the coroutine code, enter the coroutine in a BH in the new AioContext and bdrv_dec_in_flight() in that BH [Paolo]
- Patch 12 (was 11): Cover new == old case in comment [Eric]

Kevin Wolf (13):
block-backend: Make blk_inc/dec_in_flight public
virtio-blk: Increase in_flight for request restart BH
nbd: Restrict connection_co reentrance
io: Make qio_channel_yield() interruptible
io: Remove redundant read/write_coroutine assignments
nbd: Move nbd_read_eof() to nbd/client.c
nbd: Use low-level QIOChannel API in nbd_read_eof()
nbd: Increase bs->in_flight during AioContext switch
block: Don't poll in bdrv_set_aio_context()
block: Fix AioContext switch for drained node
test-bdrv-drain: AioContext switch in drained section
block: Use normal drain for bdrv_set_aio_context()
aio-posix: Assert that aio_poll() is always called in home thread

 block/nbd-client.h             |  1 +
 include/block/nbd.h            |  3 +-
 include/io/channel.h           |  9 ++++--
 include/sysemu/block-backend.h |  2 ++
 nbd/nbd-internal.h             | 19 -------------
 block.c                        | 26 ++++++++---------
 block/block-backend.c          |  4 +--
 block/nbd-client.c             | 36 +++++++++++++++++++++--
 hw/block/virtio-blk.c          |  4 +++
 io/channel.c                   | 24 ++++++++++------
 nbd/client.c                   | 52 ++++++++++++++++++++++++++++++++--
 tests/test-bdrv-drain.c        | 32 +++++++++++++++++++++
 util/aio-posix.c               |  3 +-
 13 files changed, 164 insertions(+), 51 deletions(-)
Signature · 1 line
2.20.1