Lines Matching refs:scmd

60 static int scsi_eh_try_stu(struct scsi_cmnd *scmd);
149 struct scsi_cmnd *scmd = in scmd_eh_abort_handler() local
151 struct scsi_device *sdev = scmd->device; in scmd_eh_abort_handler()
158 scmd_printk(KERN_INFO, scmd, in scmd_eh_abort_handler()
164 scmd_printk(KERN_INFO, scmd, in scmd_eh_abort_handler()
166 rtn = scsi_try_to_abort_cmd(shost->hostt, scmd); in scmd_eh_abort_handler()
169 scmd_printk(KERN_INFO, scmd, in scmd_eh_abort_handler()
175 set_host_byte(scmd, DID_TIME_OUT); in scmd_eh_abort_handler()
178 scmd_printk(KERN_INFO, scmd, in scmd_eh_abort_handler()
185 list_del_init(&scmd->eh_entry); in scmd_eh_abort_handler()
198 if (!scsi_noretry_cmd(scmd) && in scmd_eh_abort_handler()
199 scsi_cmd_retry_allowed(scmd) && in scmd_eh_abort_handler()
200 scsi_eh_should_retry_cmd(scmd)) { in scmd_eh_abort_handler()
202 scmd_printk(KERN_WARNING, scmd, in scmd_eh_abort_handler()
204 scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY); in scmd_eh_abort_handler()
207 scmd_printk(KERN_WARNING, scmd, in scmd_eh_abort_handler()
209 scsi_finish_command(scmd); in scmd_eh_abort_handler()
215 list_del_init(&scmd->eh_entry); in scmd_eh_abort_handler()
218 scsi_eh_scmd_add(scmd); in scmd_eh_abort_handler()
228 scsi_abort_command(struct scsi_cmnd *scmd) in scsi_abort_command() argument
230 struct scsi_device *sdev = scmd->device; in scsi_abort_command()
239 if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) { in scsi_abort_command()
244 scmd_printk(KERN_INFO, scmd, in scsi_abort_command()
246 BUG_ON(delayed_work_pending(&scmd->abort_work)); in scsi_abort_command()
253 BUG_ON(!list_empty(&scmd->eh_entry)); in scsi_abort_command()
254 list_add_tail(&scmd->eh_entry, &shost->eh_abort_list); in scsi_abort_command()
257 scmd->eh_eflags |= SCSI_EH_ABORT_SCHEDULED; in scsi_abort_command()
259 scmd_printk(KERN_INFO, scmd, "abort scheduled\n")); in scsi_abort_command()
260 queue_delayed_work(shost->tmf_work_q, &scmd->abort_work, HZ / 100); in scsi_abort_command()
272 static void scsi_eh_reset(struct scsi_cmnd *scmd) in scsi_eh_reset() argument
274 if (!blk_rq_is_passthrough(scsi_cmd_to_rq(scmd))) { in scsi_eh_reset()
275 struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd); in scsi_eh_reset()
277 sdrv->eh_reset(scmd); in scsi_eh_reset()
283 struct scsi_cmnd *scmd = container_of(head, typeof(*scmd), rcu); in scsi_eh_inc_host_failed() local
284 struct Scsi_Host *shost = scmd->device->host; in scsi_eh_inc_host_failed()
298 void scsi_eh_scmd_add(struct scsi_cmnd *scmd) in scsi_eh_scmd_add() argument
300 struct Scsi_Host *shost = scmd->device->host; in scsi_eh_scmd_add()
305 WARN_ON_ONCE(!test_bit(SCMD_STATE_INFLIGHT, &scmd->state)); in scsi_eh_scmd_add()
315 scsi_eh_reset(scmd); in scsi_eh_scmd_add()
316 list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q); in scsi_eh_scmd_add()
322 call_rcu_hurry(&scmd->rcu, scsi_eh_inc_host_failed); in scsi_eh_scmd_add()
337 struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req); in scsi_timeout() local
338 struct Scsi_Host *host = scmd->device->host; in scsi_timeout()
340 trace_scsi_dispatch_cmd_timeout(scmd); in scsi_timeout()
341 scsi_log_completion(scmd, TIMEOUT_ERROR); in scsi_timeout()
343 atomic_inc(&scmd->device->iotmo_cnt); in scsi_timeout()
348 switch (host->hostt->eh_timed_out(scmd)) { in scsi_timeout()
362 if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state)) in scsi_timeout()
364 atomic_inc(&scmd->device->iodone_cnt); in scsi_timeout()
365 if (scsi_abort_command(scmd) != SUCCESS) { in scsi_timeout()
366 set_host_byte(scmd, DID_TIME_OUT); in scsi_timeout()
367 scsi_eh_scmd_add(scmd); in scsi_timeout()
405 struct scsi_cmnd *scmd; in scsi_eh_prt_fail_stats() local
413 list_for_each_entry(scmd, work_q, eh_entry) { in scsi_eh_prt_fail_stats()
414 if (scmd->device == sdev) { in scsi_eh_prt_fail_stats()
416 if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) in scsi_eh_prt_fail_stats()
539 enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) in scsi_check_sense() argument
541 struct request *req = scsi_cmd_to_rq(scmd); in scsi_check_sense()
542 struct scsi_device *sdev = scmd->device; in scsi_check_sense()
545 if (! scsi_command_normalize_sense(scmd, &sshdr)) in scsi_check_sense()
557 scmd->device->ua_new_media_ctr++; in scsi_check_sense()
559 scmd->device->ua_por_ctr++; in scsi_check_sense()
574 if (scmd->cmnd[0] == TEST_UNIT_READY && in scsi_check_sense()
575 scmd->submitter != SUBMITTED_BY_SCSI_ERROR_HANDLER) in scsi_check_sense()
589 if (scmd->sense_buffer[2] & 0xe0) in scsi_check_sense()
598 (scmd->sense_buffer[8] == 0x4) && in scsi_check_sense()
599 (scmd->sense_buffer[11] & 0xe0)) in scsi_check_sense()
623 set_scsi_ml_byte(scmd, SCSIML_STAT_DL_TIMEOUT); in scsi_check_sense()
644 if (scmd->device->expecting_cc_ua) { in scsi_check_sense()
652 scmd->device->expecting_cc_ua = 0; in scsi_check_sense()
661 if (scmd->device->sdev_target->expecting_lun_change && in scsi_check_sense()
675 if (scmd->device->allow_restart && in scsi_check_sense()
688 set_scsi_ml_byte(scmd, SCSIML_STAT_NOSPC); in scsi_check_sense()
696 set_scsi_ml_byte(scmd, SCSIML_STAT_TGT_FAILURE); in scsi_check_sense()
703 set_scsi_ml_byte(scmd, SCSIML_STAT_MED_ERROR); in scsi_check_sense()
709 if (scmd->device->retry_hwerror) in scsi_check_sense()
712 set_scsi_ml_byte(scmd, SCSIML_STAT_TGT_FAILURE); in scsi_check_sense()
722 set_scsi_ml_byte(scmd, SCSIML_STAT_TGT_FAILURE); in scsi_check_sense()
735 set_scsi_ml_byte(scmd, SCSIML_STAT_DL_TIMEOUT); in scsi_check_sense()
810 static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd) in scsi_eh_completed_normally() argument
816 if (host_byte(scmd->result) == DID_RESET) { in scsi_eh_completed_normally()
823 return scsi_check_sense(scmd); in scsi_eh_completed_normally()
825 if (host_byte(scmd->result) != DID_OK) in scsi_eh_completed_normally()
832 switch (get_status_byte(scmd)) { in scsi_eh_completed_normally()
834 scsi_handle_queue_ramp_up(scmd->device); in scsi_eh_completed_normally()
835 if (scmd->sense_buffer && SCSI_SENSE_VALID(scmd)) in scsi_eh_completed_normally()
842 scsi_check_sense(scmd); in scsi_eh_completed_normally()
847 return scsi_check_sense(scmd); in scsi_eh_completed_normally()
856 if (scmd->cmnd[0] == TEST_UNIT_READY) in scsi_eh_completed_normally()
863 scsi_handle_queue_full(scmd->device); in scsi_eh_completed_normally()
877 void scsi_eh_done(struct scsi_cmnd *scmd) in scsi_eh_done() argument
881 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_eh_done()
882 "%s result: %x\n", __func__, scmd->result)); in scsi_eh_done()
884 eh_action = scmd->device->host->eh_action; in scsi_eh_done()
893 static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) in scsi_try_host_reset() argument
897 struct Scsi_Host *host = scmd->device->host; in scsi_try_host_reset()
906 rtn = hostt->eh_host_reset_handler(scmd); in scsi_try_host_reset()
912 scsi_report_bus_reset(host, scmd_channel(scmd)); in scsi_try_host_reset()
923 static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd) in scsi_try_bus_reset() argument
927 struct Scsi_Host *host = scmd->device->host; in scsi_try_bus_reset()
930 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_try_bus_reset()
936 rtn = hostt->eh_bus_reset_handler(scmd); in scsi_try_bus_reset()
942 scsi_report_bus_reset(host, scmd_channel(scmd)); in scsi_try_bus_reset()
965 static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) in scsi_try_target_reset() argument
969 struct Scsi_Host *host = scmd->device->host; in scsi_try_target_reset()
975 rtn = hostt->eh_target_reset_handler(scmd); in scsi_try_target_reset()
978 __starget_for_each_device(scsi_target(scmd->device), NULL, in scsi_try_target_reset()
996 static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd) in scsi_try_bus_device_reset() argument
999 const struct scsi_host_template *hostt = scmd->device->host->hostt; in scsi_try_bus_device_reset()
1004 rtn = hostt->eh_device_reset_handler(scmd); in scsi_try_bus_device_reset()
1006 __scsi_report_device_reset(scmd->device, NULL); in scsi_try_bus_device_reset()
1028 scsi_try_to_abort_cmd(const struct scsi_host_template *hostt, struct scsi_cmnd *scmd) in scsi_try_to_abort_cmd() argument
1033 return hostt->eh_abort_handler(scmd); in scsi_try_to_abort_cmd()
1036 static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) in scsi_abort_eh_cmnd() argument
1038 if (scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1039 if (scsi_try_bus_device_reset(scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1040 if (scsi_try_target_reset(scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1041 if (scsi_try_bus_reset(scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1042 scsi_try_host_reset(scmd); in scsi_abort_eh_cmnd()
1059 void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, in scsi_eh_prep_cmnd() argument
1062 struct scsi_device *sdev = scmd->device; in scsi_eh_prep_cmnd()
1071 ses->cmd_len = scmd->cmd_len; in scsi_eh_prep_cmnd()
1072 ses->data_direction = scmd->sc_data_direction; in scsi_eh_prep_cmnd()
1073 ses->sdb = scmd->sdb; in scsi_eh_prep_cmnd()
1074 ses->result = scmd->result; in scsi_eh_prep_cmnd()
1075 ses->resid_len = scmd->resid_len; in scsi_eh_prep_cmnd()
1076 ses->underflow = scmd->underflow; in scsi_eh_prep_cmnd()
1077 ses->prot_op = scmd->prot_op; in scsi_eh_prep_cmnd()
1078 ses->eh_eflags = scmd->eh_eflags; in scsi_eh_prep_cmnd()
1080 scmd->prot_op = SCSI_PROT_NORMAL; in scsi_eh_prep_cmnd()
1081 scmd->eh_eflags = 0; in scsi_eh_prep_cmnd()
1082 memcpy(ses->cmnd, scmd->cmnd, sizeof(ses->cmnd)); in scsi_eh_prep_cmnd()
1083 memset(scmd->cmnd, 0, sizeof(scmd->cmnd)); in scsi_eh_prep_cmnd()
1084 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); in scsi_eh_prep_cmnd()
1085 scmd->result = 0; in scsi_eh_prep_cmnd()
1086 scmd->resid_len = 0; in scsi_eh_prep_cmnd()
1089 scmd->sdb.length = min_t(unsigned, SCSI_SENSE_BUFFERSIZE, in scsi_eh_prep_cmnd()
1091 sg_init_one(&ses->sense_sgl, scmd->sense_buffer, in scsi_eh_prep_cmnd()
1092 scmd->sdb.length); in scsi_eh_prep_cmnd()
1093 scmd->sdb.table.sgl = &ses->sense_sgl; in scsi_eh_prep_cmnd()
1094 scmd->sc_data_direction = DMA_FROM_DEVICE; in scsi_eh_prep_cmnd()
1095 scmd->sdb.table.nents = scmd->sdb.table.orig_nents = 1; in scsi_eh_prep_cmnd()
1096 scmd->cmnd[0] = REQUEST_SENSE; in scsi_eh_prep_cmnd()
1097 scmd->cmnd[4] = scmd->sdb.length; in scsi_eh_prep_cmnd()
1098 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); in scsi_eh_prep_cmnd()
1100 scmd->sc_data_direction = DMA_NONE; in scsi_eh_prep_cmnd()
1102 BUG_ON(cmnd_size > sizeof(scmd->cmnd)); in scsi_eh_prep_cmnd()
1103 memcpy(scmd->cmnd, cmnd, cmnd_size); in scsi_eh_prep_cmnd()
1104 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); in scsi_eh_prep_cmnd()
1108 scmd->underflow = 0; in scsi_eh_prep_cmnd()
1111 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) | in scsi_eh_prep_cmnd()
1118 memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in scsi_eh_prep_cmnd()
1129 void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses) in scsi_eh_restore_cmnd() argument
1134 scmd->cmd_len = ses->cmd_len; in scsi_eh_restore_cmnd()
1135 memcpy(scmd->cmnd, ses->cmnd, sizeof(ses->cmnd)); in scsi_eh_restore_cmnd()
1136 scmd->sc_data_direction = ses->data_direction; in scsi_eh_restore_cmnd()
1137 scmd->sdb = ses->sdb; in scsi_eh_restore_cmnd()
1138 scmd->result = ses->result; in scsi_eh_restore_cmnd()
1139 scmd->resid_len = ses->resid_len; in scsi_eh_restore_cmnd()
1140 scmd->underflow = ses->underflow; in scsi_eh_restore_cmnd()
1141 scmd->prot_op = ses->prot_op; in scsi_eh_restore_cmnd()
1142 scmd->eh_eflags = ses->eh_eflags; in scsi_eh_restore_cmnd()
1160 static enum scsi_disposition scsi_send_eh_cmnd(struct scsi_cmnd *scmd, in scsi_send_eh_cmnd() argument
1163 struct scsi_device *sdev = scmd->device; in scsi_send_eh_cmnd()
1172 scsi_eh_prep_cmnd(scmd, &ses, cmnd, cmnd_size, sense_bytes); in scsi_send_eh_cmnd()
1175 scsi_log_send(scmd); in scsi_send_eh_cmnd()
1176 scmd->submitter = SUBMITTED_BY_SCSI_ERROR_HANDLER; in scsi_send_eh_cmnd()
1177 scmd->flags |= SCMD_LAST; in scsi_send_eh_cmnd()
1196 rtn = shost->hostt->queuecommand(shost, scmd); in scsi_send_eh_cmnd()
1203 scsi_eh_restore_cmnd(scmd, &ses); in scsi_send_eh_cmnd()
1219 scsi_log_completion(scmd, rtn); in scsi_send_eh_cmnd()
1221 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_send_eh_cmnd()
1235 rtn = scsi_eh_completed_normally(scmd); in scsi_send_eh_cmnd()
1236 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_send_eh_cmnd()
1252 scsi_abort_eh_cmnd(scmd); in scsi_send_eh_cmnd()
1256 scsi_eh_restore_cmnd(scmd, &ses); in scsi_send_eh_cmnd()
1270 static enum scsi_disposition scsi_request_sense(struct scsi_cmnd *scmd) in scsi_request_sense() argument
1272 return scsi_send_eh_cmnd(scmd, NULL, 0, scmd->device->eh_timeout, ~0); in scsi_request_sense()
1276 scsi_eh_action(struct scsi_cmnd *scmd, enum scsi_disposition rtn) in scsi_eh_action() argument
1278 if (!blk_rq_is_passthrough(scsi_cmd_to_rq(scmd))) { in scsi_eh_action()
1279 struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd); in scsi_eh_action()
1281 rtn = sdrv->eh_action(scmd, rtn); in scsi_eh_action()
1298 void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q) in scsi_eh_finish_cmd() argument
1300 list_move_tail(&scmd->eh_entry, done_q); in scsi_eh_finish_cmd()
1327 struct scsi_cmnd *scmd, *next; in scsi_eh_get_sense() local
1335 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_get_sense()
1336 if ((scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) || in scsi_eh_get_sense()
1337 SCSI_SENSE_VALID(scmd)) in scsi_eh_get_sense()
1340 shost = scmd->device->host; in scsi_eh_get_sense()
1343 scmd_printk(KERN_INFO, scmd, in scsi_eh_get_sense()
1348 if (!scsi_status_is_check_condition(scmd->result)) in scsi_eh_get_sense()
1357 SCSI_LOG_ERROR_RECOVERY(2, scmd_printk(KERN_INFO, scmd, in scsi_eh_get_sense()
1360 rtn = scsi_request_sense(scmd); in scsi_eh_get_sense()
1364 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_eh_get_sense()
1365 "sense requested, result %x\n", scmd->result)); in scsi_eh_get_sense()
1366 SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd)); in scsi_eh_get_sense()
1368 rtn = scsi_decide_disposition(scmd); in scsi_eh_get_sense()
1383 if (scmd->allowed == SCSI_CMD_RETRIES_NO_LIMIT) in scsi_eh_get_sense()
1384 scmd->retries = scmd->allowed = 1; in scsi_eh_get_sense()
1386 scmd->retries = scmd->allowed; in scsi_eh_get_sense()
1390 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_get_sense()
1404 static int scsi_eh_tur(struct scsi_cmnd *scmd) in scsi_eh_tur() argument
1411 rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, in scsi_eh_tur()
1412 scmd->device->eh_timeout, 0); in scsi_eh_tur()
1414 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_eh_tur()
1446 struct scsi_cmnd *scmd, *next; in scsi_eh_test_devices() local
1451 scmd = list_entry(cmd_list->next, struct scsi_cmnd, eh_entry); in scsi_eh_test_devices()
1452 sdev = scmd->device; in scsi_eh_test_devices()
1466 finish_cmds = !scsi_device_online(scmd->device) || in scsi_eh_test_devices()
1467 (try_stu && !scsi_eh_try_stu(scmd) && in scsi_eh_test_devices()
1468 !scsi_eh_tur(scmd)) || in scsi_eh_test_devices()
1469 !scsi_eh_tur(scmd); in scsi_eh_test_devices()
1471 list_for_each_entry_safe(scmd, next, cmd_list, eh_entry) in scsi_eh_test_devices()
1472 if (scmd->device == sdev) { in scsi_eh_test_devices()
1475 scsi_eh_action(scmd, SUCCESS) == SUCCESS)) in scsi_eh_test_devices()
1476 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_test_devices()
1478 list_move_tail(&scmd->eh_entry, work_q); in scsi_eh_test_devices()
1491 static int scsi_eh_try_stu(struct scsi_cmnd *scmd) in scsi_eh_try_stu() argument
1495 if (scmd->device->allow_restart) { in scsi_eh_try_stu()
1500 rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, in scsi_eh_try_stu()
1501 scmd->device->eh_timeout, 0); in scsi_eh_try_stu()
1524 struct scsi_cmnd *scmd, *stu_scmd, *next; in scsi_eh_stu() local
1537 list_for_each_entry(scmd, work_q, eh_entry) in scsi_eh_stu()
1538 if (scmd->device == sdev && SCSI_SENSE_VALID(scmd) && in scsi_eh_stu()
1539 scsi_check_sense(scmd) == FAILED ) { in scsi_eh_stu()
1540 stu_scmd = scmd; in scsi_eh_stu()
1555 list_for_each_entry_safe(scmd, next, in scsi_eh_stu()
1557 if (scmd->device == sdev && in scsi_eh_stu()
1558 scsi_eh_action(scmd, SUCCESS) == SUCCESS) in scsi_eh_stu()
1559 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_stu()
1590 struct scsi_cmnd *scmd, *bdr_scmd, *next; in scsi_eh_bus_device_reset() local
1604 list_for_each_entry(scmd, work_q, eh_entry) in scsi_eh_bus_device_reset()
1605 if (scmd->device == sdev) { in scsi_eh_bus_device_reset()
1606 bdr_scmd = scmd; in scsi_eh_bus_device_reset()
1621 list_for_each_entry_safe(scmd, next, in scsi_eh_bus_device_reset()
1623 if (scmd->device == sdev && in scsi_eh_bus_device_reset()
1624 scsi_eh_action(scmd, rtn) != FAILED) in scsi_eh_bus_device_reset()
1625 scsi_eh_finish_cmd(scmd, in scsi_eh_bus_device_reset()
1658 struct scsi_cmnd *next, *scmd; in scsi_eh_target_reset() local
1673 scmd = list_entry(tmp_list.next, struct scsi_cmnd, eh_entry); in scsi_eh_target_reset()
1674 id = scmd_id(scmd); in scsi_eh_target_reset()
1680 rtn = scsi_try_target_reset(scmd); in scsi_eh_target_reset()
1687 list_for_each_entry_safe(scmd, next, &tmp_list, eh_entry) { in scsi_eh_target_reset()
1688 if (scmd_id(scmd) != id) in scsi_eh_target_reset()
1692 list_move_tail(&scmd->eh_entry, &check_list); in scsi_eh_target_reset()
1694 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_target_reset()
1697 list_move(&scmd->eh_entry, work_q); in scsi_eh_target_reset()
1714 struct scsi_cmnd *scmd, *chan_scmd, *next; in scsi_eh_bus_reset() local
1737 list_for_each_entry(scmd, work_q, eh_entry) { in scsi_eh_bus_reset()
1738 if (channel == scmd_channel(scmd)) { in scsi_eh_bus_reset()
1739 chan_scmd = scmd; in scsi_eh_bus_reset()
1756 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_bus_reset()
1757 if (channel == scmd_channel(scmd)) { in scsi_eh_bus_reset()
1759 scsi_eh_finish_cmd(scmd, in scsi_eh_bus_reset()
1762 list_move_tail(&scmd->eh_entry, in scsi_eh_bus_reset()
1786 struct scsi_cmnd *scmd, *next; in scsi_eh_host_reset() local
1791 scmd = list_entry(work_q->next, in scsi_eh_host_reset()
1799 rtn = scsi_try_host_reset(scmd); in scsi_eh_host_reset()
1803 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_host_reset()
1804 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_host_reset()
1824 struct scsi_cmnd *scmd, *next; in scsi_eh_offline_sdevs() local
1827 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_offline_sdevs()
1828 sdev_printk(KERN_INFO, scmd->device, "Device offlined - " in scsi_eh_offline_sdevs()
1830 sdev = scmd->device; in scsi_eh_offline_sdevs()
1836 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_offline_sdevs()
1845 bool scsi_noretry_cmd(struct scsi_cmnd *scmd) in scsi_noretry_cmd() argument
1847 struct request *req = scsi_cmd_to_rq(scmd); in scsi_noretry_cmd()
1849 switch (host_byte(scmd->result)) { in scsi_noretry_cmd()
1859 if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) in scsi_noretry_cmd()
1867 if (scsi_ml_byte(scmd->result) == SCSIML_STAT_DL_TIMEOUT) in scsi_noretry_cmd()
1870 if (!scsi_status_is_check_condition(scmd->result)) in scsi_noretry_cmd()
1898 enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) in scsi_decide_disposition() argument
1906 if (!scsi_device_online(scmd->device)) { in scsi_decide_disposition()
1907 SCSI_LOG_ERROR_RECOVERY(5, scmd_printk(KERN_INFO, scmd, in scsi_decide_disposition()
1916 switch (host_byte(scmd->result)) { in scsi_decide_disposition()
1923 scmd->result &= 0xff00ffff; in scsi_decide_disposition()
1931 if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) { in scsi_decide_disposition()
1932 set_host_byte(scmd, DID_TIME_OUT); in scsi_decide_disposition()
1978 if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) in scsi_decide_disposition()
1994 if ((scmd->cmnd[0] == TEST_UNIT_READY || in scsi_decide_disposition()
1995 scmd->cmnd[0] == INQUIRY)) { in scsi_decide_disposition()
2009 switch (get_status_byte(scmd)) { in scsi_decide_disposition()
2011 scsi_handle_queue_full(scmd->device); in scsi_decide_disposition()
2026 if (scmd->cmnd[0] == REPORT_LUNS) in scsi_decide_disposition()
2027 scmd->device->sdev_target->expecting_lun_change = 0; in scsi_decide_disposition()
2028 scsi_handle_queue_ramp_up(scmd->device); in scsi_decide_disposition()
2029 if (scmd->sense_buffer && SCSI_SENSE_VALID(scmd)) in scsi_decide_disposition()
2036 scsi_check_sense(scmd); in scsi_decide_disposition()
2043 rtn = scsi_check_sense(scmd); in scsi_decide_disposition()
2061 sdev_printk(KERN_INFO, scmd->device, in scsi_decide_disposition()
2063 set_scsi_ml_byte(scmd, SCSIML_STAT_RESV_CONFLICT); in scsi_decide_disposition()
2074 if (scsi_cmd_retry_allowed(scmd) && !scsi_noretry_cmd(scmd)) { in scsi_decide_disposition()
2104 struct scsi_cmnd *scmd; in scsi_eh_lock_door() local
2110 scmd = blk_mq_rq_to_pdu(req); in scsi_eh_lock_door()
2112 scmd->cmnd[0] = ALLOW_MEDIUM_REMOVAL; in scsi_eh_lock_door()
2113 scmd->cmnd[1] = 0; in scsi_eh_lock_door()
2114 scmd->cmnd[2] = 0; in scsi_eh_lock_door()
2115 scmd->cmnd[3] = 0; in scsi_eh_lock_door()
2116 scmd->cmnd[4] = SCSI_REMOVAL_PREVENT; in scsi_eh_lock_door()
2117 scmd->cmnd[5] = 0; in scsi_eh_lock_door()
2118 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); in scsi_eh_lock_door()
2119 scmd->allowed = 5; in scsi_eh_lock_door()
2218 struct scsi_cmnd *scmd, *next; in scsi_eh_flush_done_q() local
2220 list_for_each_entry_safe(scmd, next, done_q, eh_entry) { in scsi_eh_flush_done_q()
2221 struct scsi_device *sdev = scmd->device; in scsi_eh_flush_done_q()
2223 list_del_init(&scmd->eh_entry); in scsi_eh_flush_done_q()
2224 if (scsi_device_online(sdev) && !scsi_noretry_cmd(scmd) && in scsi_eh_flush_done_q()
2225 scsi_cmd_retry_allowed(scmd) && in scsi_eh_flush_done_q()
2226 scsi_eh_should_retry_cmd(scmd)) { in scsi_eh_flush_done_q()
2228 scmd_printk(KERN_INFO, scmd, in scsi_eh_flush_done_q()
2231 scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY); in scsi_eh_flush_done_q()
2239 if (!scmd->result && in scsi_eh_flush_done_q()
2240 !(scmd->flags & SCMD_FORCE_EH_SUCCESS)) in scsi_eh_flush_done_q()
2241 scmd->result |= (DID_TIME_OUT << 16); in scsi_eh_flush_done_q()
2243 scmd_printk(KERN_INFO, scmd, in scsi_eh_flush_done_q()
2246 scsi_finish_command(scmd); in scsi_eh_flush_done_q()
2460 struct scsi_cmnd *scmd; in scsi_ioctl_reset() local
2484 scmd = (struct scsi_cmnd *)(rq + 1); in scsi_ioctl_reset()
2485 scsi_init_command(dev, scmd); in scsi_ioctl_reset()
2487 scmd->submitter = SUBMITTED_BY_SCSI_RESET_IOCTL; in scsi_ioctl_reset()
2488 scmd->flags |= SCMD_LAST; in scsi_ioctl_reset()
2489 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); in scsi_ioctl_reset()
2491 scmd->cmd_len = 0; in scsi_ioctl_reset()
2493 scmd->sc_data_direction = DMA_BIDIRECTIONAL; in scsi_ioctl_reset()
2504 rtn = scsi_try_bus_device_reset(scmd); in scsi_ioctl_reset()
2509 rtn = scsi_try_target_reset(scmd); in scsi_ioctl_reset()
2514 rtn = scsi_try_bus_reset(scmd); in scsi_ioctl_reset()
2519 rtn = scsi_try_host_reset(scmd); in scsi_ioctl_reset()