diff options
author | Maxim Levitsky <mlevitsk@redhat.com> | 2020-07-29 22:48:06 +0300 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2020-07-30 21:08:52 -0400 |
commit | bb2e33146876306d5623080e008f61e96e407590 (patch) | |
tree | bcaa415abc9a25d21fabc9b3d40d129fcfe3da10 /drivers/scsi | |
parent | fc13638ae92ee9eb861732d642d922d577b82a9e (diff) |
scsi: virtio-scsi: Correctly handle the case where all LUNs are unplugged
Commit 5ff843721467 ("scsi: virtio_scsi: unplug LUNs when events missed")
missed a corner case in which all the LUNs are unplugged at the same time.
In this case INQUIRY returns DID_BAD_TARGET. Detect this and unplug the
LUN.
Link: https://lore.kernel.org/r/20200729194806.4933-2-mlevitsk@redhat.com
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/virtio_scsi.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 42fac69ce9ee..8cc003aa4d00 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -350,6 +350,14 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi) if (result == 0 && inq_result[0] >> 5) { /* PQ indicates the LUN is not attached */ scsi_remove_device(sdev); + } else if (host_byte(result) == DID_BAD_TARGET) { + /* + * If all LUNs of a virtio-scsi device are unplugged + * it will respond with BAD TARGET on any INQUIRY + * command. + * Remove the device in this case as well. + */ + scsi_remove_device(sdev); } } |