vhost-scsi: Delay releasing our refcount on the tpg
authorMike Christie <michael.christie@oracle.com>
Tue, 21 Mar 2023 02:06:20 +0000 (21:06 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 21 Apr 2023 07:02:30 +0000 (03:02 -0400)
commit9a10cb4de33f4c914bd2e33ac05cff3ddb6a67b0
tree96bb671b70021294552587a4d63e16495e25d3f3
parent4b6ec919b84830949313c805c586fb34f141ce0c
vhost-scsi: Delay releasing our refcount on the tpg

We currently hold the vhost_scsi_mutex the entire time we are running
vhost_scsi_clear_endpoint. One of the reasons for this is that it prevents
userspace from being able to free the se_tpg from under us after we have
called target_undepend_item. However, it forces management operations for
for other devices to have to wait on a flakey device's:

vhost_scsi_clear_endpoint -> vhost_scsi_flush()

call which can which can take a long time.

This moves the target_undepend_item call and the tpg unsetup code to after
we have stopped new IO from starting up and after we have waited on
running IO. We can then release our refcount on the tpg and session
knowing our device is no longer accessing them. We can then drop the
vhost_scsi_mutex use during thee flush call in later patches in this set,
when we have removed other reasons for holding it.

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