virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time
Subsystems (2)
cover virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time
virtio-scsi currently has limit of 8 outstanding notifications so when more that 8 LUNs are unplugged, some are missed.
Commit 5ff843721467 ("scsi: virtio_scsi: unplug LUNs when events missed") Fixed this by checking the 'event overflow' bit and manually scanned the bus to see which LUNs are still there.
However there is a corner case when all LUNs are unplugged. In this case (which is not fully scsi confirmant IMHO), all scsi commands to such device respond with INVALID TARGET.
This patch proposes to detect this and remove the LUN in this case as well.
Maxim Levitsky (1):
scsi: virtio-scsi: handle correctly case when all LUNs were unplugged
drivers/scsi/virtio_scsi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Signature · 1 line
2.26.2
PATCH 1/1 scsi: virtio-scsi: handle correctly case when all LUNs were unplugged
Commit 5ff843721467 ("scsi: virtio_scsi: unplug LUNs when events missed"), almost fixed the case of mass unpluging of LUNs, but it missed a corner case in which all the LUNs are unplugged at the same time.
In this case INQUIRY ends with DID_BAD_TARGET.
Detect this and unplug the LUN.
--- drivers/scsi/virtio_scsi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/virtio_scsi.c +10 -0
@@ -351,6 +351,16 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)/* 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); + } }kfree (inq_result);
Signature · 1 line
2.26.2
Re: [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged
Quoted 24 lines · Maxim Levitsky
Commit
5ff843721467("scsi:virtio_scsi: unplug LUNs when events missed"), almost fixed the case of mass unpluging of LUNs, but it missed a corner case in which all the LUNs are unplugged at the same time.In this case INQUIRY ends with
DID_BAD_TARGET.
Detect this and unplug the LUN.Signed-off-by Maxim Levitsky <[email protected]>--- drivers/scsi/virtio_scsi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/scsi/virtio_scsi.c +3
-0@@ -351,6 +351,16 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)/* PQ indicates the LUN is not attached */ scsi_remove_device (sdev); } + +else if (host_byte (result) ==DID_BAD_TARGET ) { +/*
drivers/scsi/virtio_scsi.c static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi) · line 366
Quoted 10 lines
drivers/scsi/virtio_scsi.c +7
-0+* 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); + } }kfree (inq_result);
Martin K. Petersen
AppliedQuoted 8 lines · Maxim Levitsky
virtio-scsi currently has limit of 8 outstanding notifications so when more that 8 LUNs are unplugged, some are missed.
Commit
5ff843721467("scsi:virtio_scsi: unplug LUNs when events missed") Fixed this by checking the 'event overflow' bit and manually scanned the bus to see which LUNs are still there.[...]
Applied to 5.9/scsi-queue, thanks!
[1/1] scsi: virtio-scsi: Correctly handle the case where all LUNs are unplugged
https://git.kernel.org/mkp/scsi/c/b12149f2698c
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering