Skip to content

Commit 21bdff4

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: core: Have midlayer retry scsi_mode_sense() UAs
This has scsi_mode_sense() have the SCSI midlayer retry UAs instead of driving them itself. Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20240123002220.129141-13-michael.christie@oracle.com Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent e11f35c commit 21bdff4

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,11 +2262,25 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,
22622262
unsigned char cmd[12];
22632263
int use_10_for_ms;
22642264
int header_length;
2265-
int result, retry_count = retries;
2265+
int result;
22662266
struct scsi_sense_hdr my_sshdr;
2267+
struct scsi_failure failure_defs[] = {
2268+
{
2269+
.sense = UNIT_ATTENTION,
2270+
.asc = SCMD_FAILURE_ASC_ANY,
2271+
.ascq = SCMD_FAILURE_ASCQ_ANY,
2272+
.allowed = retries,
2273+
.result = SAM_STAT_CHECK_CONDITION,
2274+
},
2275+
{}
2276+
};
2277+
struct scsi_failures failures = {
2278+
.failure_definitions = failure_defs,
2279+
};
22672280
const struct scsi_exec_args exec_args = {
22682281
/* caller might not be interested in sense, but we need it */
22692282
.sshdr = sshdr ? : &my_sshdr,
2283+
.failures = &failures,
22702284
};
22712285

22722286
memset(data, 0, sizeof(*data));
@@ -2328,12 +2342,6 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,
23282342
goto retry;
23292343
}
23302344
}
2331-
if (scsi_status_is_check_condition(result) &&
2332-
sshdr->sense_key == UNIT_ATTENTION &&
2333-
retry_count) {
2334-
retry_count--;
2335-
goto retry;
2336-
}
23372345
}
23382346
return -EIO;
23392347
}

0 commit comments

Comments
 (0)