public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: mwilck@suse.com
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
	Ming Lei <ming.lei@redhat.com>,
	Bart Van Assche <Bart.VanAssche@sandisk.com>
Subject: [PATCH 1/2] scsi: add BLIST_RETRY_SCAN to ignore errors during scanning
Date: Wed, 15 Jun 2022 18:41:48 +0200	[thread overview]
Message-ID: <20220615164149.3092-2-mwilck@suse.com> (raw)
In-Reply-To: <20220615164149.3092-1-mwilck@suse.com>

From: Hannes Reinecke <hare@suse.de>

On flaky connections the INQUIRY command might run into a timeout,
but as we already have performed a REPORT LUNS command we know that
a LUN should be present. So ignore errors for the INQUIRY commands,
and retry until we exhaust the number of retries.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 drivers/scsi/scsi_scan.c    | 12 +++++++++---
 include/scsi/scsi_devinfo.h |  4 +++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 91ac901a6682..b9b851ce1b72 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -649,8 +649,6 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	int pass, count, result;
 	struct scsi_sense_hdr sshdr;
 
-	*bflags = 0;
-
 	/* Perform up to 3 passes.  The first pass uses a conservative
 	 * transfer length of 36 unless sdev->inquiry_len specifies a
 	 * different value. */
@@ -697,6 +695,11 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 				    (sshdr.ascq == 0))
 					continue;
 			}
+			if (*bflags & BLIST_RETRY_SCAN) {
+				SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
+						"scsi scan: retry inquiry after REPORT LUNs\n"));
+				continue;
+			}
 		} else if (result == 0) {
 			/*
 			 * if nothing was transferred, we try
@@ -709,6 +712,8 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 		break;
 	}
 
+	*bflags = 0;
+
 	if (result == 0) {
 		scsi_sanitize_inquiry_string(&inq_result[8], 8);
 		scsi_sanitize_inquiry_string(&inq_result[16], 16);
@@ -1531,9 +1536,10 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 				    " allowed by the host adapter\n", lun);
 		} else {
 			int res;
+			blist_flags_t bflags = BLIST_RETRY_SCAN;
 
 			res = scsi_probe_and_add_lun(starget,
-				lun, NULL, NULL, rescan, NULL);
+				lun, &bflags, NULL, rescan, NULL);
 			if (res == SCSI_SCAN_NO_RESPONSE) {
 				/*
 				 * Got some results, but now none, abort.
diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index 5d14adae21c7..e74a228d73d1 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -68,8 +68,10 @@
 #define BLIST_RETRY_ITF		((__force blist_flags_t)(1ULL << 32))
 /* Always retry ABORTED_COMMAND with ASC 0xc1 */
 #define BLIST_RETRY_ASC_C1	((__force blist_flags_t)(1ULL << 33))
+/* Retry errors during scanning */
+#define BLIST_RETRY_SCAN	((__force blist_flags_t)(1ULL << 34))
 
-#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1
+#define __BLIST_LAST_USED BLIST_RETRY_SCAN
 
 #define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \
 			       (__force blist_flags_t) \
-- 
2.36.1


  reply	other threads:[~2022-06-15 16:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 16:41 [PATCH 0/2] Fixes for device probing on flaky connections mwilck
2022-06-15 16:41 ` mwilck [this message]
2022-06-22  2:02   ` [PATCH 1/2] scsi: add BLIST_RETRY_SCAN to ignore errors during scanning Martin K. Petersen
2022-06-22  8:16     ` Martin Wilck
2022-06-22 10:49       ` Hannes Reinecke
2022-06-22 12:05         ` Martin Wilck
2022-06-15 16:41 ` [PATCH 2/2] scsi: scan: retry INQUIRY after timeout mwilck

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=20220615164149.3092-2-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    /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