aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_error.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi_error.c')
-rw-r--r--drivers/scsi/scsi_error.c104
1 files changed, 30 insertions, 74 deletions
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index ceb4e0c99b37..0fc8b48f052b 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -73,12 +73,7 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
73 73
74 spin_lock_irqsave(shost->host_lock, flags); 74 spin_lock_irqsave(shost->host_lock, flags);
75 75
76 scsi_eh_eflags_set(scmd, eh_flag); 76 scmd->eh_eflags |= eh_flag;
77 /*
78 * FIXME: Can we stop setting owner and state.
79 */
80 scmd->owner = SCSI_OWNER_ERROR_HANDLER;
81 scmd->state = SCSI_STATE_FAILED;
82 list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q); 77 list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q);
83 set_bit(SHOST_RECOVERY, &shost->shost_state); 78 set_bit(SHOST_RECOVERY, &shost->shost_state);
84 shost->host_failed++; 79 shost->host_failed++;
@@ -233,8 +228,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
233 list_for_each_entry(scmd, work_q, eh_entry) { 228 list_for_each_entry(scmd, work_q, eh_entry) {
234 if (scmd->device == sdev) { 229 if (scmd->device == sdev) {
235 ++total_failures; 230 ++total_failures;
236 if (scsi_eh_eflags_chk(scmd, 231 if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD)
237 SCSI_EH_CANCEL_CMD))
238 ++cmd_cancel; 232 ++cmd_cancel;
239 else 233 else
240 ++cmd_failed; 234 ++cmd_failed;
@@ -430,7 +424,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
430 **/ 424 **/
431static void scsi_eh_times_out(struct scsi_cmnd *scmd) 425static void scsi_eh_times_out(struct scsi_cmnd *scmd)
432{ 426{
433 scsi_eh_eflags_set(scmd, SCSI_EH_REC_TIMEOUT); 427 scmd->eh_eflags |= SCSI_EH_REC_TIMEOUT;
434 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd:%p\n", __FUNCTION__, 428 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd:%p\n", __FUNCTION__,
435 scmd)); 429 scmd));
436 430
@@ -451,7 +445,6 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
451 */ 445 */
452 if (del_timer(&scmd->eh_timeout)) { 446 if (del_timer(&scmd->eh_timeout)) {
453 scmd->request->rq_status = RQ_SCSI_DONE; 447 scmd->request->rq_status = RQ_SCSI_DONE;
454 scmd->owner = SCSI_OWNER_ERROR_HANDLER;
455 448
456 SCSI_LOG_ERROR_RECOVERY(3, printk("%s scmd: %p result: %x\n", 449 SCSI_LOG_ERROR_RECOVERY(3, printk("%s scmd: %p result: %x\n",
457 __FUNCTION__, scmd, scmd->result)); 450 __FUNCTION__, scmd, scmd->result));
@@ -484,8 +477,6 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
484 * we will use a queued command if possible, otherwise we will 477 * we will use a queued command if possible, otherwise we will
485 * emulate the queuing and calling of completion function ourselves. 478 * emulate the queuing and calling of completion function ourselves.
486 */ 479 */
487 scmd->owner = SCSI_OWNER_LOWLEVEL;
488
489 if (sdev->scsi_level <= SCSI_2) 480 if (sdev->scsi_level <= SCSI_2)
490 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) | 481 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) |
491 (sdev->lun << 5 & 0xe0); 482 (sdev->lun << 5 & 0xe0);
@@ -512,9 +503,8 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
512 * see if timeout. if so, tell the host to forget about it. 503 * see if timeout. if so, tell the host to forget about it.
513 * in other words, we don't want a callback any more. 504 * in other words, we don't want a callback any more.
514 */ 505 */
515 if (scsi_eh_eflags_chk(scmd, SCSI_EH_REC_TIMEOUT)) { 506 if (scmd->eh_eflags & SCSI_EH_REC_TIMEOUT) {
516 scsi_eh_eflags_clr(scmd, SCSI_EH_REC_TIMEOUT); 507 scmd->eh_eflags &= ~SCSI_EH_REC_TIMEOUT;
517 scmd->owner = SCSI_OWNER_LOWLEVEL;
518 508
519 /* 509 /*
520 * as far as the low level driver is 510 * as far as the low level driver is
@@ -530,8 +520,6 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
530 shost->hostt->eh_abort_handler(scmd); 520 shost->hostt->eh_abort_handler(scmd);
531 521
532 scmd->request->rq_status = RQ_SCSI_DONE; 522 scmd->request->rq_status = RQ_SCSI_DONE;
533 scmd->owner = SCSI_OWNER_ERROR_HANDLER;
534
535 rtn = FAILED; 523 rtn = FAILED;
536 } 524 }
537 525
@@ -641,9 +629,7 @@ static void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
641 struct list_head *done_q) 629 struct list_head *done_q)
642{ 630{
643 scmd->device->host->host_failed--; 631 scmd->device->host->host_failed--;
644 scmd->state = SCSI_STATE_BHQUEUE; 632 scmd->eh_eflags = 0;
645
646 scsi_eh_eflags_clr_all(scmd);
647 633
648 /* 634 /*
649 * set this back so that the upper level can correctly free up 635 * set this back so that the upper level can correctly free up
@@ -676,13 +662,11 @@ static void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
676static int scsi_eh_get_sense(struct list_head *work_q, 662static int scsi_eh_get_sense(struct list_head *work_q,
677 struct list_head *done_q) 663 struct list_head *done_q)
678{ 664{
679 struct list_head *lh, *lh_sf; 665 struct scsi_cmnd *scmd, *next;
680 struct scsi_cmnd *scmd;
681 int rtn; 666 int rtn;
682 667
683 list_for_each_safe(lh, lh_sf, work_q) { 668 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
684 scmd = list_entry(lh, struct scsi_cmnd, eh_entry); 669 if ((scmd->eh_eflags & SCSI_EH_CANCEL_CMD) ||
685 if (scsi_eh_eflags_chk(scmd, SCSI_EH_CANCEL_CMD) ||
686 SCSI_SENSE_VALID(scmd)) 670 SCSI_SENSE_VALID(scmd))
687 continue; 671 continue;
688 672
@@ -742,9 +726,6 @@ static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)
742 */ 726 */
743 if (scmd->serial_number == 0) 727 if (scmd->serial_number == 0)
744 return SUCCESS; 728 return SUCCESS;
745
746 scmd->owner = SCSI_OWNER_LOWLEVEL;
747
748 return scmd->device->host->hostt->eh_abort_handler(scmd); 729 return scmd->device->host->hostt->eh_abort_handler(scmd);
749} 730}
750 731
@@ -815,20 +796,18 @@ retry_tur:
815static int scsi_eh_abort_cmds(struct list_head *work_q, 796static int scsi_eh_abort_cmds(struct list_head *work_q,
816 struct list_head *done_q) 797 struct list_head *done_q)
817{ 798{
818 struct list_head *lh, *lh_sf; 799 struct scsi_cmnd *scmd, *next;
819 struct scsi_cmnd *scmd;
820 int rtn; 800 int rtn;
821 801
822 list_for_each_safe(lh, lh_sf, work_q) { 802 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
823 scmd = list_entry(lh, struct scsi_cmnd, eh_entry); 803 if (!(scmd->eh_eflags & SCSI_EH_CANCEL_CMD))
824 if (!scsi_eh_eflags_chk(scmd, SCSI_EH_CANCEL_CMD))
825 continue; 804 continue;
826 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting cmd:" 805 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting cmd:"
827 "0x%p\n", current->comm, 806 "0x%p\n", current->comm,
828 scmd)); 807 scmd));
829 rtn = scsi_try_to_abort_cmd(scmd); 808 rtn = scsi_try_to_abort_cmd(scmd);
830 if (rtn == SUCCESS) { 809 if (rtn == SUCCESS) {
831 scsi_eh_eflags_clr(scmd, SCSI_EH_CANCEL_CMD); 810 scmd->eh_eflags &= ~SCSI_EH_CANCEL_CMD;
832 if (!scsi_device_online(scmd->device) || 811 if (!scsi_device_online(scmd->device) ||
833 !scsi_eh_tur(scmd)) { 812 !scsi_eh_tur(scmd)) {
834 scsi_eh_finish_cmd(scmd, done_q); 813 scsi_eh_finish_cmd(scmd, done_q);
@@ -862,10 +841,7 @@ static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
862 if (!scmd->device->host->hostt->eh_device_reset_handler) 841 if (!scmd->device->host->hostt->eh_device_reset_handler)
863 return FAILED; 842 return FAILED;
864 843
865 scmd->owner = SCSI_OWNER_LOWLEVEL;
866
867 rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd); 844 rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd);
868
869 if (rtn == SUCCESS) { 845 if (rtn == SUCCESS) {
870 scmd->device->was_reset = 1; 846 scmd->device->was_reset = 1;
871 scmd->device->expecting_cc_ua = 1; 847 scmd->device->expecting_cc_ua = 1;
@@ -938,8 +914,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
938 struct list_head *work_q, 914 struct list_head *work_q,
939 struct list_head *done_q) 915 struct list_head *done_q)
940{ 916{
941 struct list_head *lh, *lh_sf; 917 struct scsi_cmnd *scmd, *stu_scmd, *next;
942 struct scsi_cmnd *scmd, *stu_scmd;
943 struct scsi_device *sdev; 918 struct scsi_device *sdev;
944 919
945 shost_for_each_device(sdev, shost) { 920 shost_for_each_device(sdev, shost) {
@@ -960,8 +935,8 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
960 if (!scsi_eh_try_stu(stu_scmd)) { 935 if (!scsi_eh_try_stu(stu_scmd)) {
961 if (!scsi_device_online(sdev) || 936 if (!scsi_device_online(sdev) ||
962 !scsi_eh_tur(stu_scmd)) { 937 !scsi_eh_tur(stu_scmd)) {
963 list_for_each_safe(lh, lh_sf, work_q) { 938 list_for_each_entry_safe(scmd, next,
964 scmd = list_entry(lh, struct scsi_cmnd, eh_entry); 939 work_q, eh_entry) {
965 if (scmd->device == sdev) 940 if (scmd->device == sdev)
966 scsi_eh_finish_cmd(scmd, done_q); 941 scsi_eh_finish_cmd(scmd, done_q);
967 } 942 }
@@ -992,8 +967,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
992 struct list_head *work_q, 967 struct list_head *work_q,
993 struct list_head *done_q) 968 struct list_head *done_q)
994{ 969{
995 struct list_head *lh, *lh_sf; 970 struct scsi_cmnd *scmd, *bdr_scmd, *next;
996 struct scsi_cmnd *scmd, *bdr_scmd;
997 struct scsi_device *sdev; 971 struct scsi_device *sdev;
998 int rtn; 972 int rtn;
999 973
@@ -1015,11 +989,8 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
1015 if (rtn == SUCCESS) { 989 if (rtn == SUCCESS) {
1016 if (!scsi_device_online(sdev) || 990 if (!scsi_device_online(sdev) ||
1017 !scsi_eh_tur(bdr_scmd)) { 991 !scsi_eh_tur(bdr_scmd)) {
1018 list_for_each_safe(lh, lh_sf, 992 list_for_each_entry_safe(scmd, next,
1019 work_q) { 993 work_q, eh_entry) {
1020 scmd = list_entry(lh, struct
1021 scsi_cmnd,
1022 eh_entry);
1023 if (scmd->device == sdev) 994 if (scmd->device == sdev)
1024 scsi_eh_finish_cmd(scmd, 995 scsi_eh_finish_cmd(scmd,
1025 done_q); 996 done_q);
@@ -1048,7 +1019,6 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
1048 1019
1049 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n", 1020 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n",
1050 __FUNCTION__)); 1021 __FUNCTION__));
1051 scmd->owner = SCSI_OWNER_LOWLEVEL;
1052 1022
1053 if (!scmd->device->host->hostt->eh_bus_reset_handler) 1023 if (!scmd->device->host->hostt->eh_bus_reset_handler)
1054 return FAILED; 1024 return FAILED;
@@ -1077,7 +1047,6 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
1077 1047
1078 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n", 1048 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n",
1079 __FUNCTION__)); 1049 __FUNCTION__));
1080 scmd->owner = SCSI_OWNER_LOWLEVEL;
1081 1050
1082 if (!scmd->device->host->hostt->eh_host_reset_handler) 1051 if (!scmd->device->host->hostt->eh_host_reset_handler)
1083 return FAILED; 1052 return FAILED;
@@ -1104,9 +1073,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
1104 struct list_head *work_q, 1073 struct list_head *work_q,
1105 struct list_head *done_q) 1074 struct list_head *done_q)
1106{ 1075{
1107 struct list_head *lh, *lh_sf; 1076 struct scsi_cmnd *scmd, *chan_scmd, *next;
1108 struct scsi_cmnd *scmd;
1109 struct scsi_cmnd *chan_scmd;
1110 unsigned int channel; 1077 unsigned int channel;
1111 int rtn; 1078 int rtn;
1112 1079
@@ -1137,9 +1104,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
1137 channel)); 1104 channel));
1138 rtn = scsi_try_bus_reset(chan_scmd); 1105 rtn = scsi_try_bus_reset(chan_scmd);
1139 if (rtn == SUCCESS) { 1106 if (rtn == SUCCESS) {
1140 list_for_each_safe(lh, lh_sf, work_q) { 1107 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
1141 scmd = list_entry(lh, struct scsi_cmnd,
1142 eh_entry);
1143 if (channel == scmd->device->channel) 1108 if (channel == scmd->device->channel)
1144 if (!scsi_device_online(scmd->device) || 1109 if (!scsi_device_online(scmd->device) ||
1145 !scsi_eh_tur(scmd)) 1110 !scsi_eh_tur(scmd))
@@ -1164,9 +1129,8 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
1164static int scsi_eh_host_reset(struct list_head *work_q, 1129static int scsi_eh_host_reset(struct list_head *work_q,
1165 struct list_head *done_q) 1130 struct list_head *done_q)
1166{ 1131{
1132 struct scsi_cmnd *scmd, *next;
1167 int rtn; 1133 int rtn;
1168 struct list_head *lh, *lh_sf;
1169 struct scsi_cmnd *scmd;
1170 1134
1171 if (!list_empty(work_q)) { 1135 if (!list_empty(work_q)) {
1172 scmd = list_entry(work_q->next, 1136 scmd = list_entry(work_q->next,
@@ -1177,8 +1141,7 @@ static int scsi_eh_host_reset(struct list_head *work_q,
1177 1141
1178 rtn = scsi_try_host_reset(scmd); 1142 rtn = scsi_try_host_reset(scmd);
1179 if (rtn == SUCCESS) { 1143 if (rtn == SUCCESS) {
1180 list_for_each_safe(lh, lh_sf, work_q) { 1144 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
1181 scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
1182 if (!scsi_device_online(scmd->device) || 1145 if (!scsi_device_online(scmd->device) ||
1183 (!scsi_eh_try_stu(scmd) && !scsi_eh_tur(scmd)) || 1146 (!scsi_eh_try_stu(scmd) && !scsi_eh_tur(scmd)) ||
1184 !scsi_eh_tur(scmd)) 1147 !scsi_eh_tur(scmd))
@@ -1202,11 +1165,9 @@ static int scsi_eh_host_reset(struct list_head *work_q,
1202static void scsi_eh_offline_sdevs(struct list_head *work_q, 1165static void scsi_eh_offline_sdevs(struct list_head *work_q,
1203 struct list_head *done_q) 1166 struct list_head *done_q)
1204{ 1167{
1205 struct list_head *lh, *lh_sf; 1168 struct scsi_cmnd *scmd, *next;
1206 struct scsi_cmnd *scmd;
1207 1169
1208 list_for_each_safe(lh, lh_sf, work_q) { 1170 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
1209 scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
1210 printk(KERN_INFO "scsi: Device offlined - not" 1171 printk(KERN_INFO "scsi: Device offlined - not"
1211 " ready after error recovery: host" 1172 " ready after error recovery: host"
1212 " %d channel %d id %d lun %d\n", 1173 " %d channel %d id %d lun %d\n",
@@ -1215,7 +1176,7 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q,
1215 scmd->device->id, 1176 scmd->device->id,
1216 scmd->device->lun); 1177 scmd->device->lun);
1217 scsi_device_set_state(scmd->device, SDEV_OFFLINE); 1178 scsi_device_set_state(scmd->device, SDEV_OFFLINE);
1218 if (scsi_eh_eflags_chk(scmd, SCSI_EH_CANCEL_CMD)) { 1179 if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) {
1219 /* 1180 /*
1220 * FIXME: Handle lost cmds. 1181 * FIXME: Handle lost cmds.
1221 */ 1182 */
@@ -1534,12 +1495,10 @@ static void scsi_eh_ready_devs(struct Scsi_Host *shost,
1534 **/ 1495 **/
1535static void scsi_eh_flush_done_q(struct list_head *done_q) 1496static void scsi_eh_flush_done_q(struct list_head *done_q)
1536{ 1497{
1537 struct list_head *lh, *lh_sf; 1498 struct scsi_cmnd *scmd, *next;
1538 struct scsi_cmnd *scmd;
1539 1499
1540 list_for_each_safe(lh, lh_sf, done_q) { 1500 list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
1541 scmd = list_entry(lh, struct scsi_cmnd, eh_entry); 1501 list_del_init(&scmd->eh_entry);
1542 list_del_init(lh);
1543 if (scsi_device_online(scmd->device) && 1502 if (scsi_device_online(scmd->device) &&
1544 !blk_noretry_request(scmd->request) && 1503 !blk_noretry_request(scmd->request) &&
1545 (++scmd->retries < scmd->allowed)) { 1504 (++scmd->retries < scmd->allowed)) {
@@ -1818,9 +1777,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
1818 scmd->request = &req; 1777 scmd->request = &req;
1819 memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout)); 1778 memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout));
1820 scmd->request->rq_status = RQ_SCSI_BUSY; 1779 scmd->request->rq_status = RQ_SCSI_BUSY;
1821 scmd->state = SCSI_STATE_INITIALIZING; 1780
1822 scmd->owner = SCSI_OWNER_MIDLEVEL;
1823
1824 memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd)); 1781 memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd));
1825 1782
1826 scmd->scsi_done = scsi_reset_provider_done_command; 1783 scmd->scsi_done = scsi_reset_provider_done_command;
@@ -1829,7 +1786,6 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
1829 scmd->bufflen = 0; 1786 scmd->bufflen = 0;
1830 scmd->request_buffer = NULL; 1787 scmd->request_buffer = NULL;
1831 scmd->request_bufflen = 0; 1788 scmd->request_bufflen = 0;
1832 scmd->abort_reason = DID_ABORT;
1833 1789
1834 scmd->cmd_len = 0; 1790 scmd->cmd_len = 0;
1835 1791