mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 14:14:37 +00:00
scsi: virtio-scsi: Correctly handle the case where all LUNs are unplugged
Commit 5ff8437214
("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>
This commit is contained in:
parent
fc13638ae9
commit
bb2e331468
1 changed files with 8 additions and 0 deletions
|
@ -350,6 +350,14 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
|
||||||
if (result == 0 && inq_result[0] >> 5) {
|
if (result == 0 && inq_result[0] >> 5) {
|
||||||
/* PQ indicates the LUN is not attached */
|
/* PQ indicates the LUN is not attached */
|
||||||
scsi_remove_device(sdev);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue