virtio-blk: restart s->rq reqs in vq AioContexts
authorStefan Hajnoczi <stefanha@redhat.com>
Fri, 19 Jan 2024 13:57:46 +0000 (08:57 -0500)
committerKevin Wolf <kwolf@redhat.com>
Fri, 26 Jan 2024 10:16:58 +0000 (11:16 +0100)
commit71ee0cdd14cc01a8b51aa4e9577dd0a1bb2f8e19
tree2a27b4df1f2b3ed1ed2d52ec46f106ec498e523e
parent3cdaf3dd4a4ca94ebabe7eab23b432f1a6c547cc
virtio-blk: restart s->rq reqs in vq AioContexts

A virtio-blk device with the iothread-vq-mapping parameter has
per-virtqueue AioContexts. It is not thread-safe to process s->rq
requests in the BlockBackend AioContext since that may be different from
the virtqueue's AioContext to which this request belongs. The code
currently races and could crash.

Adapt virtio_blk_dma_restart_cb() to first split s->rq into per-vq lists
and then schedule a BH each vq's AioContext as necessary. This way
requests are safely processed in their vq's AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20240119135748.270944-5-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block/virtio-blk.c