vhost-scsi: Reduce vhost_scsi_mutex use
authorMike Christie <michael.christie@oracle.com>
Tue, 21 Mar 2023 02:06:24 +0000 (21:06 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 21 Apr 2023 07:02:31 +0000 (03:02 -0400)
commitbea273c7a8712a055cd504a2bb7d76d8d713ba6e
tree40c79a72003e176a5b356f7b2c8f3ea84037b245
parentf5ed6f9e82ee62bf805551522dfa2d6c8030bb47
vhost-scsi: Reduce vhost_scsi_mutex use

We on longer need to hold the vhost_scsi_mutex the entire time we
set/clear the endpoint. The tv_tpg_mutex handles tpg accesses not related
to the tpg list, the port link/unlink functions use the tv_tpg_mutex while
accessing the tpg->vhost_scsi pointer, vhost_scsi_do_plug will no longer
queue events after the virtqueue's backend has been cleared and flushed,
and we don't drop our refcount to the tpg until after we have stopped
cmds and wait for outstanding cmds to complete.

This moves the vhost_scsi_mutex use to it's documented use of being used
to access the tpg list. We then don't need to hold it while a flush is
being performed causing other device's vhost_scsi_set_endpoint
and vhost_scsi_make_tpg/vhost_scsi_drop_tpg calls to have to wait on a
flakey device.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Message-Id: <20230321020624.13323-8-michael.christie@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/scsi.c