mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
vhost-scsi: do not relock event vq mutex on send_evt fallback
vhost_scsi_send_evt() is called with the event virtqueue mutex held.
If the worker is gone, the fallback currently calls
vhost_scsi_complete_events(), which tries to acquire the same mutex again
and deadlocks the caller.
Split event completion into a helper for callers that already hold the
mutex and a locking wrapper for the event worker. Use the helper on the
fallback path.
Link: https://lore.kernel.org/all/20260905005352.1E5B01F00A3D@smtp.kernel.org/
Fixes: b1b2ce58ed ("vhost-scsi: Handle vhost_vq_work_queue failures for events")
Signed-off-by: Jia Jia <physicalmtea@gmail.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260915094244.7900-3-physicalmtea@gmail.com>
This commit is contained in:
parent
a9a428115b
commit
a016d03a9c
|
|
@ -660,19 +660,26 @@ vhost_scsi_do_evt_work(struct vhost_scsi *vs, struct vhost_scsi_evt *evt)
|
|||
vhost_scsi_log_write(vq, vq_log, log_num);
|
||||
}
|
||||
|
||||
static void vhost_scsi_complete_events(struct vhost_scsi *vs, bool drop)
|
||||
/* Caller must hold the event virtqueue mutex. */
|
||||
static void __vhost_scsi_complete_events(struct vhost_scsi *vs, bool drop)
|
||||
{
|
||||
struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq;
|
||||
struct vhost_scsi_evt *evt, *t;
|
||||
struct llist_node *llnode;
|
||||
|
||||
mutex_lock(&vq->mutex);
|
||||
llnode = llist_reverse_order(llist_del_all(&vs->vs_event_list));
|
||||
llist_for_each_entry_safe(evt, t, llnode, list) {
|
||||
if (!drop)
|
||||
vhost_scsi_do_evt_work(vs, evt);
|
||||
vhost_scsi_free_evt(vs, evt);
|
||||
}
|
||||
}
|
||||
|
||||
static void vhost_scsi_complete_events(struct vhost_scsi *vs, bool drop)
|
||||
{
|
||||
struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq;
|
||||
|
||||
mutex_lock(&vq->mutex);
|
||||
__vhost_scsi_complete_events(vs, drop);
|
||||
mutex_unlock(&vq->mutex);
|
||||
}
|
||||
|
||||
|
|
@ -1859,7 +1866,7 @@ vhost_scsi_send_evt(struct vhost_scsi *vs, struct vhost_virtqueue *vq,
|
|||
|
||||
llist_add(&evt->list, &vs->vs_event_list);
|
||||
if (!vhost_vq_work_queue(vq, &vs->vs_event_work))
|
||||
vhost_scsi_complete_events(vs, true);
|
||||
__vhost_scsi_complete_events(vs, true);
|
||||
}
|
||||
|
||||
static void vhost_scsi_evt_handle_kick(struct vhost_work *work)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user