Commit b72f2d14 authored by Mike Christie's avatar Mike Christie Committed by Martin K. Petersen

scsi: sr: Have midlayer retry get_sectorsize() errors

This has get_sectorsize() 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: default avatarMike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-18-michael.christie@oracle.comAcked-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 3a7b4579
...@@ -717,27 +717,29 @@ static int sr_probe(struct device *dev) ...@@ -717,27 +717,29 @@ static int sr_probe(struct device *dev)
static void get_sectorsize(struct scsi_cd *cd) static void get_sectorsize(struct scsi_cd *cd)
{ {
unsigned char cmd[10]; static const u8 cmd[10] = { READ_CAPACITY };
unsigned char buffer[8]; unsigned char buffer[8] = { };
int the_result, retries = 3; int the_result;
int sector_size; int sector_size;
struct request_queue *queue; struct request_queue *queue;
struct scsi_failure failure_defs[] = {
do { {
cmd[0] = READ_CAPACITY; .result = SCMD_FAILURE_RESULT_ANY,
memset((void *) &cmd[1], 0, 9); .allowed = 3,
memset(buffer, 0, sizeof(buffer)); },
{}
};
struct scsi_failures failures = {
.failure_definitions = failure_defs,
};
const struct scsi_exec_args exec_args = {
.failures = &failures,
};
/* Do the command and wait.. */ /* Do the command and wait.. */
the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, buffer,
buffer, sizeof(buffer), sizeof(buffer), SR_TIMEOUT, MAX_RETRIES,
SR_TIMEOUT, MAX_RETRIES, NULL); &exec_args);
retries--;
} while (the_result && retries);
if (the_result) { if (the_result) {
cd->capacity = 0x1fffff; cd->capacity = 0x1fffff;
sector_size = 2048; /* A guess, just in case */ sector_size = 2048; /* A guess, just in case */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment