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]/ Signed-off-by: Denis V. Lunev <[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]> Cc: [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 -- 2.53.0
