Linux-SCSI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time
@ 2020-07-29 19:48 Maxim Levitsky
  2020-07-29 19:48 ` [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged Maxim Levitsky
  2020-07-30  2:24 ` [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Maxim Levitsky @ 2020-07-29 19:48 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paolo Bonzini, open list:SCSI SUBSYSTEM,
	open list:VIRTIO BLOCK AND SCSI DRIVERS, Stefan Hajnoczi,
	Michael S. Tsirkin, Martin K. Petersen, James E.J. Bottomley,
	Jason Wang, Maxim Levitsky

virtio-scsi currently has limit of 8 outstanding notifications so when more that\r
8 LUNs are unplugged, some are missed.\r
\r
Commit 5ff843721467 ("scsi: virtio_scsi: unplug LUNs when events missed")\r
Fixed this by checking the 'event overflow' bit and manually scanned the bus\r
to see which LUNs are still there.\r
\r
However there is a corner case when all LUNs are unplugged.\r
In this case (which is not fully scsi confirmant IMHO), all scsi\r
commands to such device respond with INVALID TARGET.\r
\r
This patch proposes to detect this and remove the LUN in this case\r
as well.\r
\r
Maxim Levitsky (1):\r
  scsi: virtio-scsi: handle correctly case when all LUNs were unplugged\r
\r
 drivers/scsi/virtio_scsi.c | 10 ++++++++++\r
 1 file changed, 10 insertions(+)\r
\r
-- \r
2.26.2\r
\r


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged
  2020-07-29 19:48 [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time Maxim Levitsky
@ 2020-07-29 19:48 ` Maxim Levitsky
  2020-07-29 22:10   ` Paolo Bonzini
  2020-07-30  2:24 ` [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time Martin K. Petersen
  1 sibling, 1 reply; 4+ messages in thread
From: Maxim Levitsky @ 2020-07-29 19:48 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paolo Bonzini, open list:SCSI SUBSYSTEM,
	open list:VIRTIO BLOCK AND SCSI DRIVERS, Stefan Hajnoczi,
	Michael S. Tsirkin, Martin K. Petersen, James E.J. Bottomley,
	Jason Wang, 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 <mlevitsk@redhat.com>
---
 drivers/scsi/virtio_scsi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 0e0910c5b9424..c7f0c22b6f11d 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -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);
-- 
2.26.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged
  2020-07-29 19:48 ` [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged Maxim Levitsky
@ 2020-07-29 22:10   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-07-29 22:10 UTC (permalink / raw)
  To: Maxim Levitsky, linux-kernel
  Cc: open list:SCSI SUBSYSTEM,
	open list:VIRTIO BLOCK AND SCSI DRIVERS, Stefan Hajnoczi,
	Michael S. Tsirkin, Martin K. Petersen, James E.J. Bottomley,
	Jason Wang

On 29/07/20 21:48, Maxim Levitsky wrote:
> 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 <mlevitsk@redhat.com>
> ---
>  drivers/scsi/virtio_scsi.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 0e0910c5b9424..c7f0c22b6f11d 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -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);
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time
  2020-07-29 19:48 [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time Maxim Levitsky
  2020-07-29 19:48 ` [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged Maxim Levitsky
@ 2020-07-30  2:24 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2020-07-30  2:24 UTC (permalink / raw)
  To: linux-kernel, Maxim Levitsky
  Cc: Martin K . Petersen, Michael S. Tsirkin,
	open list:SCSI SUBSYSTEM, Stefan Hajnoczi,
	open list:VIRTIO BLOCK AND SCSI DRIVERS, Paolo Bonzini,
	Jason Wang, James E.J. Bottomley

On Wed, 29 Jul 2020 22:48:05 +0300, Maxim Levitsky wrote:

> 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

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 19:48 [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time Maxim Levitsky
2020-07-29 19:48 ` [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged Maxim Levitsky
2020-07-29 22:10   ` Paolo Bonzini
2020-07-30  2:24 ` [PATCH 0/1] virtio-scsi: fix missing unplug events when all LUNs are unplugged at the same time Martin K. Petersen

Linux-SCSI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-scsi/0 linux-scsi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-scsi linux-scsi/ https://lore.kernel.org/linux-scsi \
		linux-scsi@vger.kernel.org
	public-inbox-index linux-scsi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-scsi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git