3
3
*
4
4
* SCSI error/timeout handling
5
5
* Initial versions: Eric Youngdale. Based upon conversations with
6
- * Leonard Zubkoff and David Miller at Linux Expo,
6
+ * Leonard Zubkoff and David Miller at Linux Expo,
7
7
* ideas originating from all over the place.
8
8
*
9
9
* Restructured scsi_unjam_host and associated functions.
10
10
* September 04, 2002 Mike Anderson ([email protected] )
11
11
*
12
12
* Forward port of Russell King's ([email protected] ) changes and
13
- * minor cleanups.
13
+ * minor cleanups.
14
14
* September 30, 2002 Mike Anderson ([email protected] )
15
15
*/
16
16
@@ -129,14 +129,15 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
129
129
{
130
130
struct scsi_cmnd * scmd = req -> special ;
131
131
enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED ;
132
+ struct Scsi_Host * host = scmd -> device -> host ;
132
133
133
134
trace_scsi_dispatch_cmd_timeout (scmd );
134
135
scsi_log_completion (scmd , TIMEOUT_ERROR );
135
136
136
- if (scmd -> device -> host -> transportt -> eh_timed_out )
137
- rtn = scmd -> device -> host -> transportt -> eh_timed_out (scmd );
138
- else if (scmd -> device -> host -> hostt -> eh_timed_out )
139
- rtn = scmd -> device -> host -> hostt -> eh_timed_out (scmd );
137
+ if (host -> transportt -> eh_timed_out )
138
+ rtn = host -> transportt -> eh_timed_out (scmd );
139
+ else if (host -> hostt -> eh_timed_out )
140
+ rtn = host -> hostt -> eh_timed_out (scmd );
140
141
141
142
if (unlikely (rtn == BLK_EH_NOT_HANDLED &&
142
143
!scsi_eh_scmd_add (scmd , SCSI_EH_CANCEL_CMD ))) {
@@ -195,7 +196,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
195
196
++ total_failures ;
196
197
if (scmd -> eh_eflags & SCSI_EH_CANCEL_CMD )
197
198
++ cmd_cancel ;
198
- else
199
+ else
199
200
++ cmd_failed ;
200
201
}
201
202
}
@@ -214,7 +215,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
214
215
215
216
SCSI_LOG_ERROR_RECOVERY (2 , printk ("Total of %d commands on %d"
216
217
" devices require eh work\n" ,
217
- total_failures , devices_failed ));
218
+ total_failures , devices_failed ));
218
219
}
219
220
#endif
220
221
@@ -294,7 +295,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
294
295
return NEEDS_RETRY ;
295
296
}
296
297
/*
297
- * if the device is in the process of becoming ready, we
298
+ * if the device is in the process of becoming ready, we
298
299
* should retry.
299
300
*/
300
301
if ((sshdr .asc == 0x04 ) && (sshdr .ascq == 0x01 ))
@@ -488,7 +489,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
488
489
*/
489
490
static void scsi_eh_done (struct scsi_cmnd * scmd )
490
491
{
491
- struct completion * eh_action ;
492
+ struct completion * eh_action ;
492
493
493
494
SCSI_LOG_ERROR_RECOVERY (3 ,
494
495
printk ("%s scmd: %p result: %x\n" ,
@@ -507,22 +508,23 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
507
508
{
508
509
unsigned long flags ;
509
510
int rtn ;
511
+ struct Scsi_Host * host = scmd -> device -> host ;
512
+ struct scsi_host_template * hostt = host -> hostt ;
510
513
511
514
SCSI_LOG_ERROR_RECOVERY (3 , printk ("%s: Snd Host RST\n" ,
512
515
__func__ ));
513
516
514
- if (!scmd -> device -> host -> hostt -> eh_host_reset_handler )
517
+ if (!hostt -> eh_host_reset_handler )
515
518
return FAILED ;
516
519
517
- rtn = scmd -> device -> host -> hostt -> eh_host_reset_handler (scmd );
520
+ rtn = hostt -> eh_host_reset_handler (scmd );
518
521
519
522
if (rtn == SUCCESS ) {
520
- if (!scmd -> device -> host -> hostt -> skip_settle_delay )
523
+ if (!hostt -> skip_settle_delay )
521
524
ssleep (HOST_RESET_SETTLE_TIME );
522
- spin_lock_irqsave (scmd -> device -> host -> host_lock , flags );
523
- scsi_report_bus_reset (scmd -> device -> host ,
524
- scmd_channel (scmd ));
525
- spin_unlock_irqrestore (scmd -> device -> host -> host_lock , flags );
525
+ spin_lock_irqsave (host -> host_lock , flags );
526
+ scsi_report_bus_reset (host , scmd_channel (scmd ));
527
+ spin_unlock_irqrestore (host -> host_lock , flags );
526
528
}
527
529
528
530
return rtn ;
@@ -536,22 +538,23 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
536
538
{
537
539
unsigned long flags ;
538
540
int rtn ;
541
+ struct Scsi_Host * host = scmd -> device -> host ;
542
+ struct scsi_host_template * hostt = host -> hostt ;
539
543
540
544
SCSI_LOG_ERROR_RECOVERY (3 , printk ("%s: Snd Bus RST\n" ,
541
545
__func__ ));
542
546
543
- if (!scmd -> device -> host -> hostt -> eh_bus_reset_handler )
547
+ if (!hostt -> eh_bus_reset_handler )
544
548
return FAILED ;
545
549
546
- rtn = scmd -> device -> host -> hostt -> eh_bus_reset_handler (scmd );
550
+ rtn = hostt -> eh_bus_reset_handler (scmd );
547
551
548
552
if (rtn == SUCCESS ) {
549
- if (!scmd -> device -> host -> hostt -> skip_settle_delay )
553
+ if (!hostt -> skip_settle_delay )
550
554
ssleep (BUS_RESET_SETTLE_TIME );
551
- spin_lock_irqsave (scmd -> device -> host -> host_lock , flags );
552
- scsi_report_bus_reset (scmd -> device -> host ,
553
- scmd_channel (scmd ));
554
- spin_unlock_irqrestore (scmd -> device -> host -> host_lock , flags );
555
+ spin_lock_irqsave (host -> host_lock , flags );
556
+ scsi_report_bus_reset (host , scmd_channel (scmd ));
557
+ spin_unlock_irqrestore (host -> host_lock , flags );
555
558
}
556
559
557
560
return rtn ;
@@ -577,16 +580,18 @@ static int scsi_try_target_reset(struct scsi_cmnd *scmd)
577
580
{
578
581
unsigned long flags ;
579
582
int rtn ;
583
+ struct Scsi_Host * host = scmd -> device -> host ;
584
+ struct scsi_host_template * hostt = host -> hostt ;
580
585
581
- if (!scmd -> device -> host -> hostt -> eh_target_reset_handler )
586
+ if (!hostt -> eh_target_reset_handler )
582
587
return FAILED ;
583
588
584
- rtn = scmd -> device -> host -> hostt -> eh_target_reset_handler (scmd );
589
+ rtn = hostt -> eh_target_reset_handler (scmd );
585
590
if (rtn == SUCCESS ) {
586
- spin_lock_irqsave (scmd -> device -> host -> host_lock , flags );
591
+ spin_lock_irqsave (host -> host_lock , flags );
587
592
__starget_for_each_device (scsi_target (scmd -> device ), NULL ,
588
593
__scsi_report_device_reset );
589
- spin_unlock_irqrestore (scmd -> device -> host -> host_lock , flags );
594
+ spin_unlock_irqrestore (host -> host_lock , flags );
590
595
}
591
596
592
597
return rtn ;
@@ -605,27 +610,28 @@ static int scsi_try_target_reset(struct scsi_cmnd *scmd)
605
610
static int scsi_try_bus_device_reset (struct scsi_cmnd * scmd )
606
611
{
607
612
int rtn ;
613
+ struct scsi_host_template * hostt = scmd -> device -> host -> hostt ;
608
614
609
- if (!scmd -> device -> host -> hostt -> eh_device_reset_handler )
615
+ if (!hostt -> eh_device_reset_handler )
610
616
return FAILED ;
611
617
612
- rtn = scmd -> device -> host -> hostt -> eh_device_reset_handler (scmd );
618
+ rtn = hostt -> eh_device_reset_handler (scmd );
613
619
if (rtn == SUCCESS )
614
620
__scsi_report_device_reset (scmd -> device , NULL );
615
621
return rtn ;
616
622
}
617
623
618
- static int scsi_try_to_abort_cmd (struct scsi_cmnd * scmd )
624
+ static int scsi_try_to_abort_cmd (struct scsi_host_template * hostt , struct scsi_cmnd * scmd )
619
625
{
620
- if (!scmd -> device -> host -> hostt -> eh_abort_handler )
626
+ if (!hostt -> eh_abort_handler )
621
627
return FAILED ;
622
628
623
- return scmd -> device -> host -> hostt -> eh_abort_handler (scmd );
629
+ return hostt -> eh_abort_handler (scmd );
624
630
}
625
631
626
632
static void scsi_abort_eh_cmnd (struct scsi_cmnd * scmd )
627
633
{
628
- if (scsi_try_to_abort_cmd (scmd ) != SUCCESS )
634
+ if (scsi_try_to_abort_cmd (scmd -> device -> host -> hostt , scmd ) != SUCCESS )
629
635
if (scsi_try_bus_device_reset (scmd ) != SUCCESS )
630
636
if (scsi_try_target_reset (scmd ) != SUCCESS )
631
637
if (scsi_try_bus_reset (scmd ) != SUCCESS )
@@ -846,7 +852,7 @@ EXPORT_SYMBOL(scsi_eh_finish_cmd);
846
852
*
847
853
* Description:
848
854
* See if we need to request sense information. if so, then get it
849
- * now, so we have a better idea of what to do.
855
+ * now, so we have a better idea of what to do.
850
856
*
851
857
* Notes:
852
858
* This has the unfortunate side effect that if a shost adapter does
@@ -958,15 +964,14 @@ static int scsi_eh_abort_cmds(struct list_head *work_q,
958
964
SCSI_LOG_ERROR_RECOVERY (3 , printk ("%s: aborting cmd:"
959
965
"0x%p\n" , current -> comm ,
960
966
scmd ));
961
- rtn = scsi_try_to_abort_cmd (scmd );
967
+ rtn = scsi_try_to_abort_cmd (scmd -> device -> host -> hostt , scmd );
962
968
if (rtn == SUCCESS || rtn == FAST_IO_FAIL ) {
963
969
scmd -> eh_eflags &= ~SCSI_EH_CANCEL_CMD ;
964
970
if (!scsi_device_online (scmd -> device ) ||
965
971
rtn == FAST_IO_FAIL ||
966
972
!scsi_eh_tur (scmd )) {
967
973
scsi_eh_finish_cmd (scmd , done_q );
968
974
}
969
-
970
975
} else
971
976
SCSI_LOG_ERROR_RECOVERY (3 , printk ("%s: aborting"
972
977
" cmd failed:"
@@ -1010,7 +1015,7 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
1010
1015
*
1011
1016
* Notes:
1012
1017
* If commands are failing due to not ready, initializing command required,
1013
- * try revalidating the device, which will end up sending a start unit.
1018
+ * try revalidating the device, which will end up sending a start unit.
1014
1019
*/
1015
1020
static int scsi_eh_stu (struct Scsi_Host * shost ,
1016
1021
struct list_head * work_q ,
@@ -1064,7 +1069,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
1064
1069
* Try a bus device reset. Still, look to see whether we have multiple
1065
1070
* devices that are jammed or not - if we have multiple devices, it
1066
1071
* makes no sense to try bus_device_reset - we really would need to try
1067
- * a bus_reset instead.
1072
+ * a bus_reset instead.
1068
1073
*/
1069
1074
static int scsi_eh_bus_device_reset (struct Scsi_Host * shost ,
1070
1075
struct list_head * work_q ,
@@ -1164,7 +1169,7 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost,
1164
1169
}
1165
1170
1166
1171
/**
1167
- * scsi_eh_bus_reset - send a bus reset
1172
+ * scsi_eh_bus_reset - send a bus reset
1168
1173
* @shost: &scsi host being recovered.
1169
1174
* @work_q: &list_head for pending commands.
1170
1175
* @done_q: &list_head for processed commands.
@@ -1181,7 +1186,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
1181
1186
* we really want to loop over the various channels, and do this on
1182
1187
* a channel by channel basis. we should also check to see if any
1183
1188
* of the failed commands are on soft_reset devices, and if so, skip
1184
- * the reset.
1189
+ * the reset.
1185
1190
*/
1186
1191
1187
1192
for (channel = 0 ; channel <= shost -> max_channel ; channel ++ ) {
@@ -1223,7 +1228,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
1223
1228
}
1224
1229
1225
1230
/**
1226
- * scsi_eh_host_reset - send a host reset
1231
+ * scsi_eh_host_reset - send a host reset
1227
1232
* @work_q: list_head for processed commands.
1228
1233
* @done_q: list_head for processed commands.
1229
1234
*/
@@ -1376,7 +1381,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
1376
1381
return SUCCESS ;
1377
1382
/*
1378
1383
* when the low level driver returns did_soft_error,
1379
- * it is responsible for keeping an internal retry counter
1384
+ * it is responsible for keeping an internal retry counter
1380
1385
* in order to avoid endless loops (db)
1381
1386
*
1382
1387
* actually this is a bug in this function here. we should
@@ -1414,7 +1419,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
1414
1419
*/
1415
1420
break ;
1416
1421
/* fallthrough */
1417
-
1418
1422
case DID_BUS_BUSY :
1419
1423
case DID_PARITY :
1420
1424
goto maybe_retry ;
@@ -1982,7 +1986,7 @@ int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
1982
1986
if (sb_len > 7 )
1983
1987
sshdr -> additional_length = sense_buffer [7 ];
1984
1988
} else {
1985
- /*
1989
+ /*
1986
1990
* fixed format
1987
1991
*/
1988
1992
if (sb_len > 2 )
0 commit comments