Skip to content

Commit e11f35c

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: ch: Have midlayer retry ch_do_scsi() UAs
This has ch_do_scsi() 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-12-michael.christie@oracle.com Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 11a2672 commit e11f35c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

drivers/scsi/ch.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,29 @@ static int
185185
ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
186186
void *buffer, unsigned int buflength, enum req_op op)
187187
{
188-
int errno, retries = 0, timeout, result;
188+
int errno = 0, timeout, result;
189189
struct scsi_sense_hdr sshdr;
190+
struct scsi_failure failure_defs[] = {
191+
{
192+
.sense = UNIT_ATTENTION,
193+
.asc = SCMD_FAILURE_ASC_ANY,
194+
.ascq = SCMD_FAILURE_ASCQ_ANY,
195+
.allowed = 3,
196+
.result = SAM_STAT_CHECK_CONDITION,
197+
},
198+
{}
199+
};
200+
struct scsi_failures failures = {
201+
.failure_definitions = failure_defs,
202+
};
190203
const struct scsi_exec_args exec_args = {
191204
.sshdr = &sshdr,
205+
.failures = &failures,
192206
};
193207

194208
timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
195209
? timeout_init : timeout_move;
196210

197-
retry:
198-
errno = 0;
199211
result = scsi_execute_cmd(ch->device, cmd, op, buffer, buflength,
200212
timeout * HZ, MAX_RETRIES, &exec_args);
201213
if (result < 0)
@@ -204,13 +216,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
204216
if (debug)
205217
scsi_print_sense_hdr(ch->device, ch->name, &sshdr);
206218
errno = ch_find_errno(&sshdr);
207-
208-
switch(sshdr.sense_key) {
209-
case UNIT_ATTENTION:
210-
if (retries++ < 3)
211-
goto retry;
212-
break;
213-
}
214219
}
215220
return errno;
216221
}

0 commit comments

Comments
 (0)