Skip to content

Commit b72f2d1

Browse files
mikechristiemartinkpetersen
authored andcommitted
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: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20240123002220.129141-18-michael.christie@oracle.com Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 3a7b457 commit b72f2d1

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

drivers/scsi/sr.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -717,27 +717,29 @@ static int sr_probe(struct device *dev)
717717

718718
static void get_sectorsize(struct scsi_cd *cd)
719719
{
720-
unsigned char cmd[10];
721-
unsigned char buffer[8];
722-
int the_result, retries = 3;
720+
static const u8 cmd[10] = { READ_CAPACITY };
721+
unsigned char buffer[8] = { };
722+
int the_result;
723723
int sector_size;
724724
struct request_queue *queue;
725+
struct scsi_failure failure_defs[] = {
726+
{
727+
.result = SCMD_FAILURE_RESULT_ANY,
728+
.allowed = 3,
729+
},
730+
{}
731+
};
732+
struct scsi_failures failures = {
733+
.failure_definitions = failure_defs,
734+
};
735+
const struct scsi_exec_args exec_args = {
736+
.failures = &failures,
737+
};
725738

726-
do {
727-
cmd[0] = READ_CAPACITY;
728-
memset((void *) &cmd[1], 0, 9);
729-
memset(buffer, 0, sizeof(buffer));
730-
731-
/* Do the command and wait.. */
732-
the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN,
733-
buffer, sizeof(buffer),
734-
SR_TIMEOUT, MAX_RETRIES, NULL);
735-
736-
retries--;
737-
738-
} while (the_result && retries);
739-
740-
739+
/* Do the command and wait.. */
740+
the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, buffer,
741+
sizeof(buffer), SR_TIMEOUT, MAX_RETRIES,
742+
&exec_args);
741743
if (the_result) {
742744
cd->capacity = 0x1fffff;
743745
sector_size = 2048; /* A guess, just in case */

0 commit comments

Comments
 (0)