Skip to content

scsi-disk: fix UNMAP and WRITE SAME racing with inactivation

Denis V. Lunev qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5scsi-disk: check all UNMAP descriptors before discarding anyhw/scsi/scsi-disk.c+14 -100 replies
2/5scsi-disk: fix UNMAP racing with inactivation of block nodeshw/scsi/scsi-disk.c+112 -470 replies
3/5scsi-disk: fix WRITE SAME racing with inactivation of block nodeshw/scsi/scsi-disk.c+39 -630 replies
4/5virtio-scsi-test: split virtio_scsi_do_command() into submit and waittests/qtest/virtio-scsi-test.c+59 -260 replies
5/5virtio-scsi-test: test UNMAP and WRITE SAME during inactivationtests/qtest/virtio-scsi-test.c+88 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] scsi-disk: fix UNMAP and WRITE SAME racing with inactivation

scsi-disk splits UNMAP into one discard per descriptor and a non-zero WRITE SAME into 512 KiB writes, submitting each step from the completion callback of the previous one. A drain in between only waits for the step in flight; the next one is queued by blk_wait_while_drained() and resumed by drain_end. When the drain is the one in bdrv_inactivate_all() (end of live migration, blockdev-set-active), the resumed request hits an inactive node:

bdrv_co_write_req_prepare: Assertion
`!(bs->open_flags & BDRV_O_INACTIVE)' failed.

We hit this in production on a guest UNMAP with 38 descriptors.

The fix follows the one Kevin did for IDE TRIM:
https://lore.kernel.org/qemu-devel/[email protected]/

Cc Paolo Bonzini <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Hanna Reitz <[email protected]>
Cc Fabiano Rosas <[email protected]>
Cc Laurent Vivier <[email protected]>

Denis V. Lunev (5):
scsi-disk: check all UNMAP descriptors before discarding any
scsi-disk: fix UNMAP racing with inactivation of block nodes
scsi-disk: fix WRITE SAME racing with inactivation of block nodes
virtio-scsi-test: split virtio_scsi_do_command() into submit and wait
virtio-scsi-test: test UNMAP and WRITE SAME during inactivation

 hw/scsi/scsi-disk.c            | 277 +++++++++++++++++++--------------
 tests/qtest/virtio-scsi-test.c | 173 ++++++++++++++++----
 2 files changed, 308 insertions(+), 142 deletions(-)

base-commit: d73149283205645625bfa9fe029cfb68e4c4a9ae

Signature · 1 line
2.53.0