Skip to content

Commit 8d24677

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: core: Have SCSI midlayer retry scsi_report_lun_scan() errors
This has scsi_report_lun_scan() have the SCSI midlayer retry errors instead of driving them itself. There is one behavior change where we no longer retry when scsi_execute_cmd() returns < 0, but we should be ok. We don't need to retry for failures like the queue being removed, and for the case where there are no tags/reqs the block layer waits/retries for us. For possible memory allocation failures from blk_rq_map_kern() we use GFP_NOIO, so retrying will probably not help. Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20240123002220.129141-14-michael.christie@oracle.com Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 21bdff4 commit 8d24677

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

drivers/scsi/scsi_scan.c

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,14 +1416,34 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
14161416
unsigned int length;
14171417
u64 lun;
14181418
unsigned int num_luns;
1419-
unsigned int retries;
14201419
int result;
14211420
struct scsi_lun *lunp, *lun_data;
1422-
struct scsi_sense_hdr sshdr;
14231421
struct scsi_device *sdev;
14241422
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
1423+
struct scsi_failure failure_defs[] = {
1424+
{
1425+
.sense = UNIT_ATTENTION,
1426+
.asc = SCMD_FAILURE_ASC_ANY,
1427+
.ascq = SCMD_FAILURE_ASCQ_ANY,
1428+
.result = SAM_STAT_CHECK_CONDITION,
1429+
},
1430+
/* Fail all CCs except the UA above */
1431+
{
1432+
.sense = SCMD_FAILURE_SENSE_ANY,
1433+
.result = SAM_STAT_CHECK_CONDITION,
1434+
},
1435+
/* Retry any other errors not listed above */
1436+
{
1437+
.result = SCMD_FAILURE_RESULT_ANY,
1438+
},
1439+
{}
1440+
};
1441+
struct scsi_failures failures = {
1442+
.total_allowed = 3,
1443+
.failure_definitions = failure_defs,
1444+
};
14251445
const struct scsi_exec_args exec_args = {
1426-
.sshdr = &sshdr,
1446+
.failures = &failures,
14271447
};
14281448
int ret = 0;
14291449

@@ -1494,29 +1514,18 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
14941514
* should come through as a check condition, and will not generate
14951515
* a retry.
14961516
*/
1497-
for (retries = 0; retries < 3; retries++) {
1498-
SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
1499-
"scsi scan: Sending REPORT LUNS to (try %d)\n",
1500-
retries));
1501-
1502-
result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN,
1503-
lun_data, length,
1504-
SCSI_REPORT_LUNS_TIMEOUT, 3,
1505-
&exec_args);
1517+
scsi_failures_reset_retries(&failures);
15061518

1507-
SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
1508-
"scsi scan: REPORT LUNS"
1509-
" %s (try %d) result 0x%x\n",
1510-
result ? "failed" : "successful",
1511-
retries, result));
1512-
if (result == 0)
1513-
break;
1514-
else if (scsi_sense_valid(&sshdr)) {
1515-
if (sshdr.sense_key != UNIT_ATTENTION)
1516-
break;
1517-
}
1518-
}
1519+
SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
1520+
"scsi scan: Sending REPORT LUNS\n"));
1521+
1522+
result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, lun_data,
1523+
length, SCSI_REPORT_LUNS_TIMEOUT, 3,
1524+
&exec_args);
15191525

1526+
SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
1527+
"scsi scan: REPORT LUNS %s result 0x%x\n",
1528+
result ? "failed" : "successful", result));
15201529
if (result) {
15211530
/*
15221531
* The device probably does not support a REPORT LUN command

0 commit comments

Comments
 (0)