Skip to content

Commit a0a2864

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fix from James Bottomley: "A single fix this time: a fix for a virtqueue removal bug which only appears to affect S390, but which results in the queue hanging forever thus causing the machine to fail shutdown" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: virtio_scsi: Reject commands when virtqueue is broken
2 parents a49e6f5 + 6f3e71c commit a0a2864

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/scsi/virtio_scsi.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
534534
{
535535
struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
536536
struct virtio_scsi_cmd *cmd = scsi_cmd_priv(sc);
537+
unsigned long flags;
537538
int req_size;
539+
int ret;
538540

539541
BUG_ON(scsi_sg_count(sc) > shost->sg_tablesize);
540542

@@ -562,8 +564,15 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
562564
req_size = sizeof(cmd->req.cmd);
563565
}
564566

565-
if (virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd)) != 0)
567+
ret = virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd));
568+
if (ret == -EIO) {
569+
cmd->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET;
570+
spin_lock_irqsave(&req_vq->vq_lock, flags);
571+
virtscsi_complete_cmd(vscsi, cmd);
572+
spin_unlock_irqrestore(&req_vq->vq_lock, flags);
573+
} else if (ret != 0) {
566574
return SCSI_MLQUEUE_HOST_BUSY;
575+
}
567576
return 0;
568577
}
569578

0 commit comments

Comments
 (0)