diff options
author | Mike Christie <michael.christie@oracle.com> | 2024-03-15 19:47:00 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2024-05-22 08:31:15 -0400 |
commit | 1eceddeeb6a9beb7ef2a22c176c03c5ff18c6386 (patch) | |
tree | cb06b9a3a38db85c9731694e53953650b9153985 /drivers/vhost | |
parent | b1b2ce58ed23c5d56e0ab299a5271ac01f95b75c (diff) | |
download | linux-1eceddeeb6a9beb7ef2a22c176c03c5ff18c6386.tar.gz linux-1eceddeeb6a9beb7ef2a22c176c03c5ff18c6386.tar.bz2 linux-1eceddeeb6a9beb7ef2a22c176c03c5ff18c6386.zip |
vhost-scsi: Handle vhost_vq_work_queue failures for cmds
In the next patches we will support the vhost_task being killed while in
use. The problem for vhost-scsi is that we can't free some structs until
we get responses for commands we have submitted to the target layer and
we currently process the responses from the vhost_task.
This has just drop the responses and free the command's resources. When
all commands have completed then operations like flush will be woken up
and we can complete device release and endpoint cleanup.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Message-Id: <20240316004707.45557-3-michael.christie@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/scsi.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index f34f9895b898..6ec1abe7364f 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -358,6 +358,16 @@ static void vhost_scsi_release_tmf_res(struct vhost_scsi_tmf *tmf) vhost_scsi_put_inflight(inflight); } +static void vhost_scsi_drop_cmds(struct vhost_scsi_virtqueue *svq) +{ + struct vhost_scsi_cmd *cmd, *t; + struct llist_node *llnode; + + llnode = llist_del_all(&svq->completion_list); + llist_for_each_entry_safe(cmd, t, llnode, tvc_completion_list) + vhost_scsi_release_cmd_res(&cmd->tvc_se_cmd); +} + static void vhost_scsi_release_cmd(struct se_cmd *se_cmd) { if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) { @@ -373,7 +383,8 @@ static void vhost_scsi_release_cmd(struct se_cmd *se_cmd) struct vhost_scsi_virtqueue, vq); llist_add(&cmd->tvc_completion_list, &svq->completion_list); - vhost_vq_work_queue(&svq->vq, &svq->completion_work); + if (!vhost_vq_work_queue(&svq->vq, &svq->completion_work)) + vhost_scsi_drop_cmds(svq); } } |