Skip to content

blockdev: fix QMP 'transaction' with IOThreads

Stefan Hajnoczi qemu-devel 2 versions – Applied

Status from this message: Thanks, applied to my block-next tree:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 13 repliesApplied
  2. v19 patches 4 repliesSuperseded

Changes in v2 from the cover letter

* Use StrOrNull for x-blockdev-set-iothread iothread argument [eblake]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/9blockdev: hold AioContext for bdrv_unref() in external_snapshot_clean()blockdev.c+1 -11 reply
2/9block: don't keep AioContext acquired after external_snapshot_prepare()blockdev.c+48 -231 reply
3/9block: don't keep AioContext acquired after drive_backup_prepare()blockdev.c+34 -81 reply
4/9block: don't keep AioContext acquired after blockdev_backup_prepare()blockdev.c+34 -101 reply
5/9block: don't keep AioContext acquired after internal_snapshot_prepare()blockdev.c+31 -161 reply
6/9block: drop unused BlockDirtyBitmapState->aio_context fieldblockdev.c+0 -131 reply
7/9iothread: add iothread_by_id() APIinclude/sysemu/iothread.h iothread.c+8 -01 reply
8/9blockdev: add x-blockdev-set-iothread testing commandblockdev.c qapi/block-core.json+77 -01 reply
9/9qemu-iotests: add 202 external snapshots IOThread testtests/qemu-iotests/202 tests/qemu-iotests/202.out tests/qemu-iotests/group+107 -01 reply

Reviews trailers per patch

All 9 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchEric BlakeKevin WolfPaolo Bonzini
SeriesR-b R-b
1/9R-b
2/9R-b
3/9R-b
4/9R-b
5/9R-b
6/9R-b
7/9R-b
8/9R-b
9/9R-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 0/9] blockdev: fix QMP 'transaction' with IOThreads

v2:
* Use StrOrNull for x-blockdev-set-iothread iothread argument [eblake]

(This is for QEMU 2.12 because this bug is not -rc4 critical)

Previously AioContext was held across QMP 'transaction' in an attempt to achieve bdrv_drained_begin/end() semantics. Nowadays we have bdrv_drained_begin/end() and the AioContext lock just protects state. Therefore there is no reason to hold AioContext across .prepare/.commit/.abort/.clean() anymore.

Besides being cleanup-worthy, holding AioContext also exposes a bug:
BDRV_POLL_WHILE() doesn't support recursive AioContext locking and will hang if depth > 1. This is easy to trigger by submitting a transaction with 2 actions that touch two drives assigned to an IOThread. The IOThread's AioContext will be locked twice and BDRV_POLL_WHILE() will hang.

BDRV_POLL_WHILE() is best fixed by eliminating the AioContext lock entirely in favor of fine-grained locking. I discussed some fixes for BDRV_POLL_WHILE() with Paolo but we came to the conclusion that it will just add complexity when we really want to stop using AioContext locking.

Summary:

* Patch 1 fixes missing AioContext lock protection

* Patches 2-6 clean up excessive AioContext locked regions in QMP 'transaction' to solve the hang

* Patches 7-9 add a qemu-iotests test case and the necessary infrastructure

Stefan Hajnoczi (9):
blockdev: hold AioContext for bdrv_unref() in
external_snapshot_clean()
block: don't keep AioContext acquired after
external_snapshot_prepare()
block: don't keep AioContext acquired after drive_backup_prepare()
block: don't keep AioContext acquired after blockdev_backup_prepare()
block: don't keep AioContext acquired after
internal_snapshot_prepare()
block: drop unused BlockDirtyBitmapState->aio_context field
iothread: add iothread_by_id() API
blockdev: add x-blockdev-set-iothread testing command
qemu-iotests: add 202 external snapshots IOThread test

 qapi/block-core.json       |  36 +++++++
 include/sysemu/iothread.h  |   1 +
 blockdev.c                 | 258 +++++++++++++++++++++++++++++++++------------
 iothread.c                 |   7 ++
 tests/qemu-iotests/202     |  95 +++++++++++++++++
 tests/qemu-iotests/202.out |  11 ++
 tests/qemu-iotests/group   |   1 +
 7 files changed, 339 insertions(+), 70 deletions(-)
 create mode 100755 tests/qemu-iotests/202
 create mode 100644 tests/qemu-iotests/202.out
Signature · 1 line
2.14.3