virtio-scsi: replace AioContext lock with tmf_bh_lock
commited18b1ed4f34888872b5fbc2f217c65d62c95cfd
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 5 Dec 2023 18:19:58 +0000 (5 13:19 -0500)
committerKevin Wolf <kwolf@redhat.com>
Thu, 21 Dec 2023 21:49:27 +0000 (21 22:49 +0100)
treea62eff3b16c753d530e61e2098a88a0029872306
parente661a2470342d6fa873369c81988a19b1bb7b3f4
virtio-scsi: replace AioContext lock with tmf_bh_lock

Protect the Task Management Function BH state with a lock. The TMF BH
runs in the main loop thread. An IOThread might process a TMF at the
same time as the TMF BH is running. Therefore tmf_bh_list and tmf_bh
must be protected by a lock.

Run TMF request completion in the IOThread using aio_wait_bh_oneshot().
This avoids more locking to protect the virtqueue and SCSI layer state.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231205182011.1976568-2-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/scsi/virtio-scsi.c
include/hw/virtio/virtio-scsi.h