Skip to content

Fix some jobs/drain/aio_poll related hangs

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 Latest17 patches 29 repliesIn review
  2. v114 patches 18 repliesSuperseded

Changes in v2 from the cover letter

- Rebased on top of mreitz/block (including fixes for new bugs: patch 1 and 16)
- Patch 12: Added missing bdrv_unref() calls in error path [Fam]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17job: Fix missing locking due to mismergejob.c+4 -02 replies
2/17blockjob: Wake up BDS when job becomes idleblockjob.c include/block/blockjob.h include/qemu/job.h +1 more+41 -01 reply
3/17aio-wait: Increase num_waiters even in home threadinclude/block/aio-wait.h+2 -03 replies
4/17test-bdrv-drain: Drain with block jobs in an I/O threadtests/test-bdrv-drain.c+86 -60 replies
5/17test-blockjob: Acquire AioContext around job_cancel_sync()include/qemu/job.h tests/test-blockjob.c+12 -00 replies
6/17job: Use AIO_WAIT_WHILE() in job_finish_sync()job.c+6 -83 replies
7/17test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callbacktests/test-bdrv-drain.c+10 -00 replies
8/17block: Add missing locking in bdrv_co_drain_bh_cb()block/io.c include/qemu/coroutine.h util/qemu-coroutine.c+25 -03 replies
9/17block-backend: Add .drained_poll callbackblock/block-backend.c+9 -01 reply
10/17block-backend: Fix potential double blk_delete()block/block-backend.c+6 -12 replies
11/17block-backend: Decrease in_flight only after callbackblock/block-backend.c+9 -17 replies
12/17mirror: Fix potential use-after-free in active commitblock/mirror.c+11 -03 replies
13/17blockjob: Lie better in child_job_drained_poll()blockjob.c include/qemu/job.h job.c+14 -21 reply
14/17block: Remove aio_poll() in bdrv_drain_poll variantsblock/io.c+0 -81 reply
15/17test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level()tests/test-bdrv-drain.c+13 -00 replies
16/17job: Avoid deadlocks in job_completed_txn_abort()job.c+11 -51 reply
17/17test-bdrv-drain: AIO_WAIT_WHILE() in job .commit/.aborttests/test-bdrv-drain.c+104 -121 reply

Reviews trailers per patch

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

PatchFam ZhengMax ReitzJohn Snow
1/17R-b R-b
2/17R-b R-b
3/17R-b
4/17R-b
5/17R-b
6/17R-b R-b
7/17R-b
8/17R-b
9/17R-b R-b
10/17R-b R-b
11/17R-b R-b
12/17R-b
13/17R-b
14/17R-b R-b
15/17R-b
16/17R-b
17/17R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 00/17] Fix some jobs/drain/aio_poll related hangs

Especially the combination of iothreads, block jobs and drain tends to lead to hangs currently. This series fixes a few of these bugs, although there are more of them, to be addressed in separate patches.

The primary goal of this series is to fix the scenario from:
https://bugzilla.redhat.com/show_bug.cgi?id=1601212

A simplified reproducer of the reported problem looks like this (two concurrent commit block jobs for disks in an iothread):

$qemu -qmp stdio \
    -object iothread,id=iothread1 \
    -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=0x6,iothread=iothread1 \
    -drive  id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=hd0 \
    -device scsi-hd,drive=drive_image1,id=image1,bootindex=1 \
    -drive  id=drive_image2,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=hd1 \
    -device scsi-hd,drive=drive_image2,id=image2,bootindex=2

{"execute":"qmp_capabilities"} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image1","snapshot-file":"sn1"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image1","snapshot-file":"sn11"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image1","snapshot-file":"sn111"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image2","snapshot-file":"sn2"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image2","snapshot-file":"sn22"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image2","snapshot-file":"sn222"}}

{ "execute": "block-commit", "arguments": { "device": "drive_image2","base":"sn2","backing-file":"sn2","top":"sn22"}} { "execute": "block-commit", "arguments": { "device": "drive_image1","base":"sn1","backing-file":"sn1","top":"sn11"}}

{"execute":"quit"}

v2:
- Rebased on top of mreitz/block (including fixes for new bugs: patch 1 and 16)
- Patch 12: Added missing bdrv_unref() calls in error path [Fam]

Kevin Wolf (17):
job: Fix missing locking due to mismerge
blockjob: Wake up BDS when job becomes idle
aio-wait: Increase num_waiters even in home thread
test-bdrv-drain: Drain with block jobs in an I/O thread
test-blockjob: Acquire AioContext around job_cancel_sync()
job: Use AIO_WAIT_WHILE() in job_finish_sync()
test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callback
block: Add missing locking in bdrv_co_drain_bh_cb()
block-backend: Add .drained_poll callback
block-backend: Fix potential double blk_delete()
block-backend: Decrease in_flight only after callback
mirror: Fix potential use-after-free in active commit
blockjob: Lie better in child_job_drained_poll()
block: Remove aio_poll() in bdrv_drain_poll variants
test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level()
job: Avoid deadlocks in job_completed_txn_abort()
test-bdrv-drain: AIO_WAIT_WHILE() in job .commit/.abort

 include/block/aio-wait.h |   2 +
 include/block/blockjob.h |  13 +++
 include/qemu/coroutine.h |   5 ++
 include/qemu/job.h       |  12 +++
 block/block-backend.c    |  26 +++++-
 block/io.c               |  23 +++--
 block/mirror.c           |  11 +++
 blockjob.c               |  20 ++++-
 job.c                    |  50 ++++++++---
 tests/test-bdrv-drain.c  | 215 ++++++++++++++++++++++++++++++++++++++++++++---
 tests/test-blockjob.c    |   6 ++
 util/qemu-coroutine.c    |   5 ++
 12 files changed, 354 insertions(+), 34 deletions(-)
Signature · 1 line
2.13.6