linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>, linux-kernel@vger.kernel.org
Cc: "open list:SCSI SUBSYSTEM" <linux-scsi@vger.kernel.org>,
	"open list:VIRTIO BLOCK AND SCSI DRIVERS" 
	<virtualization@lists.linux-foundation.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Jason Wang <jasowang@redhat.com>
Subject: Re: [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged
Date: Thu, 30 Jul 2020 00:10:19 +0200	[thread overview]
Message-ID: <e56b2e4c-6dcd-1ec5-dde6-ef81c1f98e2a@redhat.com> (raw)
In-Reply-To: <20200729194806.4933-2-mlevitsk@redhat.com>

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>


  reply	other threads:[~2020-07-29 22:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e56b2e4c-6dcd-1ec5-dde6-ef81c1f98e2a@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mlevitsk@redhat.com \
    --cc=mst@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).