[PATCH v2 34/35] scsi: sr: Have scsi-ml retry get_sectorsize errors

Mike Christie
2022-09-29T02:57:39Z

This has get_sectorsize have scsi-ml retry errors instead of driving them
itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/scsi/sr.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index e3171f040fe1..8e21ad83e938 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -727,30 +727,31 @@ static void get_sectorsize(struct scsi_cd *cd)
{
unsigned char cmd[10];
unsigned char buffer[8];
- int the_result, retries = 3;
+ int the_result;
int sector_size;
struct request_queue *queue;
+ struct scsi_failure failures[] = {
+ {
+ .result = SCMD_FAILURE_ANY,
+ .allowed = 3,
+ },
+ {},
+ };

- do {
- cmd[0] = READ_CAPACITY;
- memset((void *) &cmd[1], 0, 9);
- memset(buffer, 0, sizeof(buffer));
-
- /* Do the command and wait.. */
- the_result = scsi_exec_req(((struct scsi_exec_args) {
- .sdev = cd->device,
- .cmd = cmd,
- .data_dir = DMA_FROM_DEVICE,
- .buf = buffer,
- .buf_len = sizeof(buffer),
- .timeout = SR_TIMEOUT,
- .retries = MAX_RETRIES }));
-
- retries--;
-
- } while (the_result && retries);
-
+ cmd[0] = READ_CAPACITY;
+ memset((void *) &cmd[1], 0, 9);
+ memset(buffer, 0, sizeof(buffer));

+ /* Do the command and wait.. */
+ the_result = scsi_exec_req(((struct scsi_exec_args) {
+ .sdev = cd->device,
+ .cmd = cmd,
+ .data_dir = DMA_FROM_DEVICE,
+ .buf = buffer,
+ .buf_len = sizeof(buffer),
+ .timeout = SR_TIMEOUT,
+ .retries = MAX_RETRIES,
+ .failures = failures }));
if (the_result) {
cd->capacity = 0x1fffff;
sector_size = 2048; /* A guess, just in case */
--
2.25.1