From: Maxim Levitsky <mlevitsk@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
linux-scsi@vger.kernel.org (open list:SCSI SUBSYSTEM),
virtualization@lists.linux-foundation.org (open list:VIRTIO
BLOCK AND SCSI DRIVERS), 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>,
Maxim Levitsky <mlevitsk@redhat.com>
Subject: [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged
Date: Wed, 29 Jul 2020 22:48:06 +0300 [thread overview]
Message-ID: <20200729194806.4933-2-mlevitsk@redhat.com> (raw)
In-Reply-To: <20200729194806.4933-1-mlevitsk@redhat.com>
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
next prev parent reply other threads:[~2020-07-29 19:48 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 ` Maxim Levitsky [this message]
2020-07-29 22:10 ` [PATCH 1/1] scsi: virtio-scsi: handle correctly case when all LUNs were unplugged 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
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=20200729194806.4933-2-mlevitsk@redhat.com \
--to=mlevitsk@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=mst@redhat.com \
--cc=pbonzini@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).