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()
297 void scsi_eh_scmd_add(struct scsi_cmnd *scmd) in scsi_eh_scmd_add() argument
299 struct Scsi_Host *shost = scmd->device->host; in scsi_eh_scmd_add()
313 scsi_eh_reset(scmd); in scsi_eh_scmd_add()
314 list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q); in scsi_eh_scmd_add()
320 call_rcu_hurry(&scmd->rcu, scsi_eh_inc_host_failed); in scsi_eh_scmd_add()
335 struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req); in scsi_timeout() local
336 struct Scsi_Host *host = scmd->device->host; in scsi_timeout()
338 trace_scsi_dispatch_cmd_timeout(scmd); in scsi_timeout()
339 scsi_log_completion(scmd, TIMEOUT_ERROR); in scsi_timeout()
341 atomic_inc(&scmd->device->iotmo_cnt); in scsi_timeout()
346 switch (host->hostt->eh_timed_out(scmd)) { in scsi_timeout()
360 if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state)) in scsi_timeout()
362 atomic_inc(&scmd->device->iodone_cnt); in scsi_timeout()
363 if (scsi_abort_command(scmd) != SUCCESS) { in scsi_timeout()
364 set_host_byte(scmd, DID_TIME_OUT); in scsi_timeout()
365 scsi_eh_scmd_add(scmd); in scsi_timeout()
403 struct scsi_cmnd *scmd; in scsi_eh_prt_fail_stats() local
411 list_for_each_entry(scmd, work_q, eh_entry) { in scsi_eh_prt_fail_stats()
412 if (scmd->device == sdev) { in scsi_eh_prt_fail_stats()
414 if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) in scsi_eh_prt_fail_stats()
537 enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) in scsi_check_sense() argument
539 struct request *req = scsi_cmd_to_rq(scmd); in scsi_check_sense()
540 struct scsi_device *sdev = scmd->device; in scsi_check_sense()
543 if (! scsi_command_normalize_sense(scmd, &sshdr)) in scsi_check_sense()
560 if (scmd->cmnd[0] == TEST_UNIT_READY && in scsi_check_sense()
561 scmd->submitter != SUBMITTED_BY_SCSI_ERROR_HANDLER) in scsi_check_sense()
575 if (scmd->sense_buffer[2] & 0xe0) in scsi_check_sense()
584 (scmd->sense_buffer[8] == 0x4) && in scsi_check_sense()
585 (scmd->sense_buffer[11] & 0xe0)) in scsi_check_sense()
609 set_scsi_ml_byte(scmd, SCSIML_STAT_DL_TIMEOUT); in scsi_check_sense()
630 if (scmd->device->expecting_cc_ua) { in scsi_check_sense()
638 scmd->device->expecting_cc_ua = 0; in scsi_check_sense()
647 if (scmd->device->sdev_target->expecting_lun_change && in scsi_check_sense()
660 if (scmd->device->allow_restart && in scsi_check_sense()
673 set_scsi_ml_byte(scmd, SCSIML_STAT_NOSPC); in scsi_check_sense()
681 set_scsi_ml_byte(scmd, SCSIML_STAT_TGT_FAILURE); in scsi_check_sense()
688 set_scsi_ml_byte(scmd, SCSIML_STAT_MED_ERROR); in scsi_check_sense()
694 if (scmd->device->retry_hwerror) in scsi_check_sense()
697 set_scsi_ml_byte(scmd, SCSIML_STAT_TGT_FAILURE); in scsi_check_sense()
707 set_scsi_ml_byte(scmd, SCSIML_STAT_TGT_FAILURE); in scsi_check_sense()
713 set_scsi_ml_byte(scmd, SCSIML_STAT_DL_TIMEOUT); in scsi_check_sense()
788 static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd) in scsi_eh_completed_normally() argument
794 if (host_byte(scmd->result) == DID_RESET) { in scsi_eh_completed_normally()
801 return scsi_check_sense(scmd); in scsi_eh_completed_normally()
803 if (host_byte(scmd->result) != DID_OK) in scsi_eh_completed_normally()
810 switch (get_status_byte(scmd)) { in scsi_eh_completed_normally()
812 scsi_handle_queue_ramp_up(scmd->device); in scsi_eh_completed_normally()
813 if (scmd->sense_buffer && SCSI_SENSE_VALID(scmd)) in scsi_eh_completed_normally()
820 scsi_check_sense(scmd); in scsi_eh_completed_normally()
825 return scsi_check_sense(scmd); in scsi_eh_completed_normally()
834 if (scmd->cmnd[0] == TEST_UNIT_READY) in scsi_eh_completed_normally()
841 scsi_handle_queue_full(scmd->device); in scsi_eh_completed_normally()
855 void scsi_eh_done(struct scsi_cmnd *scmd) in scsi_eh_done() argument
859 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_eh_done()
860 "%s result: %x\n", __func__, scmd->result)); in scsi_eh_done()
862 eh_action = scmd->device->host->eh_action; in scsi_eh_done()
871 static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) in scsi_try_host_reset() argument
875 struct Scsi_Host *host = scmd->device->host; in scsi_try_host_reset()
884 rtn = hostt->eh_host_reset_handler(scmd); in scsi_try_host_reset()
890 scsi_report_bus_reset(host, scmd_channel(scmd)); in scsi_try_host_reset()
901 static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd) in scsi_try_bus_reset() argument
905 struct Scsi_Host *host = scmd->device->host; in scsi_try_bus_reset()
908 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_try_bus_reset()
914 rtn = hostt->eh_bus_reset_handler(scmd); in scsi_try_bus_reset()
920 scsi_report_bus_reset(host, scmd_channel(scmd)); in scsi_try_bus_reset()
943 static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) in scsi_try_target_reset() argument
947 struct Scsi_Host *host = scmd->device->host; in scsi_try_target_reset()
953 rtn = hostt->eh_target_reset_handler(scmd); in scsi_try_target_reset()
956 __starget_for_each_device(scsi_target(scmd->device), NULL, in scsi_try_target_reset()
974 static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd) in scsi_try_bus_device_reset() argument
977 const struct scsi_host_template *hostt = scmd->device->host->hostt; in scsi_try_bus_device_reset()
982 rtn = hostt->eh_device_reset_handler(scmd); in scsi_try_bus_device_reset()
984 __scsi_report_device_reset(scmd->device, NULL); in scsi_try_bus_device_reset()
1006 scsi_try_to_abort_cmd(const struct scsi_host_template *hostt, struct scsi_cmnd *scmd) in scsi_try_to_abort_cmd() argument
1011 return hostt->eh_abort_handler(scmd); in scsi_try_to_abort_cmd()
1014 static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) in scsi_abort_eh_cmnd() argument
1016 if (scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1017 if (scsi_try_bus_device_reset(scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1018 if (scsi_try_target_reset(scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1019 if (scsi_try_bus_reset(scmd) != SUCCESS) in scsi_abort_eh_cmnd()
1020 scsi_try_host_reset(scmd); in scsi_abort_eh_cmnd()
1037 void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, in scsi_eh_prep_cmnd() argument
1040 struct scsi_device *sdev = scmd->device; in scsi_eh_prep_cmnd()
1049 ses->cmd_len = scmd->cmd_len; in scsi_eh_prep_cmnd()
1050 ses->data_direction = scmd->sc_data_direction; in scsi_eh_prep_cmnd()
1051 ses->sdb = scmd->sdb; in scsi_eh_prep_cmnd()
1052 ses->result = scmd->result; in scsi_eh_prep_cmnd()
1053 ses->resid_len = scmd->resid_len; in scsi_eh_prep_cmnd()
1054 ses->underflow = scmd->underflow; in scsi_eh_prep_cmnd()
1055 ses->prot_op = scmd->prot_op; in scsi_eh_prep_cmnd()
1056 ses->eh_eflags = scmd->eh_eflags; in scsi_eh_prep_cmnd()
1058 scmd->prot_op = SCSI_PROT_NORMAL; in scsi_eh_prep_cmnd()
1059 scmd->eh_eflags = 0; in scsi_eh_prep_cmnd()
1060 memcpy(ses->cmnd, scmd->cmnd, sizeof(ses->cmnd)); in scsi_eh_prep_cmnd()
1061 memset(scmd->cmnd, 0, sizeof(scmd->cmnd)); in scsi_eh_prep_cmnd()
1062 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); in scsi_eh_prep_cmnd()
1063 scmd->result = 0; in scsi_eh_prep_cmnd()
1064 scmd->resid_len = 0; in scsi_eh_prep_cmnd()
1067 scmd->sdb.length = min_t(unsigned, SCSI_SENSE_BUFFERSIZE, in scsi_eh_prep_cmnd()
1069 sg_init_one(&ses->sense_sgl, scmd->sense_buffer, in scsi_eh_prep_cmnd()
1070 scmd->sdb.length); in scsi_eh_prep_cmnd()
1071 scmd->sdb.table.sgl = &ses->sense_sgl; in scsi_eh_prep_cmnd()
1072 scmd->sc_data_direction = DMA_FROM_DEVICE; in scsi_eh_prep_cmnd()
1073 scmd->sdb.table.nents = scmd->sdb.table.orig_nents = 1; in scsi_eh_prep_cmnd()
1074 scmd->cmnd[0] = REQUEST_SENSE; in scsi_eh_prep_cmnd()
1075 scmd->cmnd[4] = scmd->sdb.length; in scsi_eh_prep_cmnd()
1076 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); in scsi_eh_prep_cmnd()
1078 scmd->sc_data_direction = DMA_NONE; in scsi_eh_prep_cmnd()
1080 BUG_ON(cmnd_size > sizeof(scmd->cmnd)); in scsi_eh_prep_cmnd()
1081 memcpy(scmd->cmnd, cmnd, cmnd_size); in scsi_eh_prep_cmnd()
1082 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); in scsi_eh_prep_cmnd()
1086 scmd->underflow = 0; in scsi_eh_prep_cmnd()
1089 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) | in scsi_eh_prep_cmnd()
1096 memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in scsi_eh_prep_cmnd()
1107 void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses) in scsi_eh_restore_cmnd() argument
1112 scmd->cmd_len = ses->cmd_len; in scsi_eh_restore_cmnd()
1113 memcpy(scmd->cmnd, ses->cmnd, sizeof(ses->cmnd)); in scsi_eh_restore_cmnd()
1114 scmd->sc_data_direction = ses->data_direction; in scsi_eh_restore_cmnd()
1115 scmd->sdb = ses->sdb; in scsi_eh_restore_cmnd()
1116 scmd->result = ses->result; in scsi_eh_restore_cmnd()
1117 scmd->resid_len = ses->resid_len; in scsi_eh_restore_cmnd()
1118 scmd->underflow = ses->underflow; in scsi_eh_restore_cmnd()
1119 scmd->prot_op = ses->prot_op; in scsi_eh_restore_cmnd()
1120 scmd->eh_eflags = ses->eh_eflags; in scsi_eh_restore_cmnd()
1138 static enum scsi_disposition scsi_send_eh_cmnd(struct scsi_cmnd *scmd, in scsi_send_eh_cmnd() argument
1141 struct scsi_device *sdev = scmd->device; in scsi_send_eh_cmnd()
1150 scsi_eh_prep_cmnd(scmd, &ses, cmnd, cmnd_size, sense_bytes); in scsi_send_eh_cmnd()
1153 scsi_log_send(scmd); in scsi_send_eh_cmnd()
1154 scmd->submitter = SUBMITTED_BY_SCSI_ERROR_HANDLER; in scsi_send_eh_cmnd()
1173 rtn = shost->hostt->queuecommand(shost, scmd); in scsi_send_eh_cmnd()
1180 scsi_eh_restore_cmnd(scmd, &ses); in scsi_send_eh_cmnd()
1196 scsi_log_completion(scmd, rtn); in scsi_send_eh_cmnd()
1198 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_send_eh_cmnd()
1212 rtn = scsi_eh_completed_normally(scmd); in scsi_send_eh_cmnd()
1213 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_send_eh_cmnd()
1229 scsi_abort_eh_cmnd(scmd); in scsi_send_eh_cmnd()
1233 scsi_eh_restore_cmnd(scmd, &ses); in scsi_send_eh_cmnd()
1247 static enum scsi_disposition scsi_request_sense(struct scsi_cmnd *scmd) in scsi_request_sense() argument
1249 return scsi_send_eh_cmnd(scmd, NULL, 0, scmd->device->eh_timeout, ~0); in scsi_request_sense()
1253 scsi_eh_action(struct scsi_cmnd *scmd, enum scsi_disposition rtn) in scsi_eh_action() argument
1255 if (!blk_rq_is_passthrough(scsi_cmd_to_rq(scmd))) { in scsi_eh_action()
1256 struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd); in scsi_eh_action()
1258 rtn = sdrv->eh_action(scmd, rtn); in scsi_eh_action()
1275 void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q) in scsi_eh_finish_cmd() argument
1277 list_move_tail(&scmd->eh_entry, done_q); in scsi_eh_finish_cmd()
1304 struct scsi_cmnd *scmd, *next; in scsi_eh_get_sense() local
1312 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_get_sense()
1313 if ((scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) || in scsi_eh_get_sense()
1314 SCSI_SENSE_VALID(scmd)) in scsi_eh_get_sense()
1317 shost = scmd->device->host; in scsi_eh_get_sense()
1320 scmd_printk(KERN_INFO, scmd, in scsi_eh_get_sense()
1325 if (!scsi_status_is_check_condition(scmd->result)) in scsi_eh_get_sense()
1334 SCSI_LOG_ERROR_RECOVERY(2, scmd_printk(KERN_INFO, scmd, in scsi_eh_get_sense()
1337 rtn = scsi_request_sense(scmd); in scsi_eh_get_sense()
1341 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_eh_get_sense()
1342 "sense requested, result %x\n", scmd->result)); in scsi_eh_get_sense()
1343 SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd)); in scsi_eh_get_sense()
1345 rtn = scsi_decide_disposition(scmd); in scsi_eh_get_sense()
1360 if (scmd->allowed == SCSI_CMD_RETRIES_NO_LIMIT) in scsi_eh_get_sense()
1361 scmd->retries = scmd->allowed = 1; in scsi_eh_get_sense()
1363 scmd->retries = scmd->allowed; in scsi_eh_get_sense()
1367 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_get_sense()
1381 static int scsi_eh_tur(struct scsi_cmnd *scmd) in scsi_eh_tur() argument
1388 rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, in scsi_eh_tur()
1389 scmd->device->eh_timeout, 0); in scsi_eh_tur()
1391 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, in scsi_eh_tur()
1423 struct scsi_cmnd *scmd, *next; in scsi_eh_test_devices() local
1428 scmd = list_entry(cmd_list->next, struct scsi_cmnd, eh_entry); in scsi_eh_test_devices()
1429 sdev = scmd->device; in scsi_eh_test_devices()
1443 finish_cmds = !scsi_device_online(scmd->device) || in scsi_eh_test_devices()
1444 (try_stu && !scsi_eh_try_stu(scmd) && in scsi_eh_test_devices()
1445 !scsi_eh_tur(scmd)) || in scsi_eh_test_devices()
1446 !scsi_eh_tur(scmd); in scsi_eh_test_devices()
1448 list_for_each_entry_safe(scmd, next, cmd_list, eh_entry) in scsi_eh_test_devices()
1449 if (scmd->device == sdev) { in scsi_eh_test_devices()
1452 scsi_eh_action(scmd, SUCCESS) == SUCCESS)) in scsi_eh_test_devices()
1453 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_test_devices()
1455 list_move_tail(&scmd->eh_entry, work_q); in scsi_eh_test_devices()
1468 static int scsi_eh_try_stu(struct scsi_cmnd *scmd) in scsi_eh_try_stu() argument
1472 if (scmd->device->allow_restart) { in scsi_eh_try_stu()
1477 rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, in scsi_eh_try_stu()
1478 scmd->device->eh_timeout, 0); in scsi_eh_try_stu()
1501 struct scsi_cmnd *scmd, *stu_scmd, *next; in scsi_eh_stu() local
1514 list_for_each_entry(scmd, work_q, eh_entry) in scsi_eh_stu()
1515 if (scmd->device == sdev && SCSI_SENSE_VALID(scmd) && in scsi_eh_stu()
1516 scsi_check_sense(scmd) == FAILED ) { in scsi_eh_stu()
1517 stu_scmd = scmd; in scsi_eh_stu()
1532 list_for_each_entry_safe(scmd, next, in scsi_eh_stu()
1534 if (scmd->device == sdev && in scsi_eh_stu()
1535 scsi_eh_action(scmd, SUCCESS) == SUCCESS) in scsi_eh_stu()
1536 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_stu()
1567 struct scsi_cmnd *scmd, *bdr_scmd, *next; in scsi_eh_bus_device_reset() local
1581 list_for_each_entry(scmd, work_q, eh_entry) in scsi_eh_bus_device_reset()
1582 if (scmd->device == sdev) { in scsi_eh_bus_device_reset()
1583 bdr_scmd = scmd; in scsi_eh_bus_device_reset()
1598 list_for_each_entry_safe(scmd, next, in scsi_eh_bus_device_reset()
1600 if (scmd->device == sdev && in scsi_eh_bus_device_reset()
1601 scsi_eh_action(scmd, rtn) != FAILED) in scsi_eh_bus_device_reset()
1602 scsi_eh_finish_cmd(scmd, in scsi_eh_bus_device_reset()
1635 struct scsi_cmnd *next, *scmd; in scsi_eh_target_reset() local
1650 scmd = list_entry(tmp_list.next, struct scsi_cmnd, eh_entry); in scsi_eh_target_reset()
1651 id = scmd_id(scmd); in scsi_eh_target_reset()
1657 rtn = scsi_try_target_reset(scmd); in scsi_eh_target_reset()
1664 list_for_each_entry_safe(scmd, next, &tmp_list, eh_entry) { in scsi_eh_target_reset()
1665 if (scmd_id(scmd) != id) in scsi_eh_target_reset()
1669 list_move_tail(&scmd->eh_entry, &check_list); in scsi_eh_target_reset()
1671 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_target_reset()
1674 list_move(&scmd->eh_entry, work_q); in scsi_eh_target_reset()
1691 struct scsi_cmnd *scmd, *chan_scmd, *next; in scsi_eh_bus_reset() local
1714 list_for_each_entry(scmd, work_q, eh_entry) { in scsi_eh_bus_reset()
1715 if (channel == scmd_channel(scmd)) { in scsi_eh_bus_reset()
1716 chan_scmd = scmd; in scsi_eh_bus_reset()
1733 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_bus_reset()
1734 if (channel == scmd_channel(scmd)) { in scsi_eh_bus_reset()
1736 scsi_eh_finish_cmd(scmd, in scsi_eh_bus_reset()
1739 list_move_tail(&scmd->eh_entry, in scsi_eh_bus_reset()
1763 struct scsi_cmnd *scmd, *next; in scsi_eh_host_reset() local
1768 scmd = list_entry(work_q->next, in scsi_eh_host_reset()
1776 rtn = scsi_try_host_reset(scmd); in scsi_eh_host_reset()
1780 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_host_reset()
1781 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_host_reset()
1801 struct scsi_cmnd *scmd, *next; in scsi_eh_offline_sdevs() local
1804 list_for_each_entry_safe(scmd, next, work_q, eh_entry) { in scsi_eh_offline_sdevs()
1805 sdev_printk(KERN_INFO, scmd->device, "Device offlined - " in scsi_eh_offline_sdevs()
1807 sdev = scmd->device; in scsi_eh_offline_sdevs()
1813 scsi_eh_finish_cmd(scmd, done_q); in scsi_eh_offline_sdevs()
1822 bool scsi_noretry_cmd(struct scsi_cmnd *scmd) in scsi_noretry_cmd() argument
1824 struct request *req = scsi_cmd_to_rq(scmd); in scsi_noretry_cmd()
1826 switch (host_byte(scmd->result)) { in scsi_noretry_cmd()
1836 if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) in scsi_noretry_cmd()
1844 if (scsi_ml_byte(scmd->result) == SCSIML_STAT_DL_TIMEOUT) in scsi_noretry_cmd()
1847 if (!scsi_status_is_check_condition(scmd->result)) in scsi_noretry_cmd()
1875 enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) in scsi_decide_disposition() argument
1883 if (!scsi_device_online(scmd->device)) { in scsi_decide_disposition()
1884 SCSI_LOG_ERROR_RECOVERY(5, scmd_printk(KERN_INFO, scmd, in scsi_decide_disposition()
1893 switch (host_byte(scmd->result)) { in scsi_decide_disposition()
1900 scmd->result &= 0xff00ffff; in scsi_decide_disposition()
1908 if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) { in scsi_decide_disposition()
1909 set_host_byte(scmd, DID_TIME_OUT); in scsi_decide_disposition()
1955 if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) in scsi_decide_disposition()
1971 if ((scmd->cmnd[0] == TEST_UNIT_READY || in scsi_decide_disposition()
1972 scmd->cmnd[0] == INQUIRY)) { in scsi_decide_disposition()
1986 switch (get_status_byte(scmd)) { in scsi_decide_disposition()
1988 scsi_handle_queue_full(scmd->device); in scsi_decide_disposition()
2003 if (scmd->cmnd[0] == REPORT_LUNS) in scsi_decide_disposition()
2004 scmd->device->sdev_target->expecting_lun_change = 0; in scsi_decide_disposition()
2005 scsi_handle_queue_ramp_up(scmd->device); in scsi_decide_disposition()
2006 if (scmd->sense_buffer && SCSI_SENSE_VALID(scmd)) in scsi_decide_disposition()
2013 scsi_check_sense(scmd); in scsi_decide_disposition()
2020 rtn = scsi_check_sense(scmd); in scsi_decide_disposition()
2038 sdev_printk(KERN_INFO, scmd->device, in scsi_decide_disposition()
2040 set_scsi_ml_byte(scmd, SCSIML_STAT_RESV_CONFLICT); in scsi_decide_disposition()
2051 if (scsi_cmd_retry_allowed(scmd) && !scsi_noretry_cmd(scmd)) { in scsi_decide_disposition()
2081 struct scsi_cmnd *scmd; in scsi_eh_lock_door() local
2087 scmd = blk_mq_rq_to_pdu(req); in scsi_eh_lock_door()
2089 scmd->cmnd[0] = ALLOW_MEDIUM_REMOVAL; in scsi_eh_lock_door()
2090 scmd->cmnd[1] = 0; in scsi_eh_lock_door()
2091 scmd->cmnd[2] = 0; in scsi_eh_lock_door()
2092 scmd->cmnd[3] = 0; in scsi_eh_lock_door()
2093 scmd->cmnd[4] = SCSI_REMOVAL_PREVENT; in scsi_eh_lock_door()
2094 scmd->cmnd[5] = 0; in scsi_eh_lock_door()
2095 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); in scsi_eh_lock_door()
2096 scmd->allowed = 5; in scsi_eh_lock_door()
2195 struct scsi_cmnd *scmd, *next; in scsi_eh_flush_done_q() local
2197 list_for_each_entry_safe(scmd, next, done_q, eh_entry) { in scsi_eh_flush_done_q()
2198 list_del_init(&scmd->eh_entry); in scsi_eh_flush_done_q()
2199 if (scsi_device_online(scmd->device) && in scsi_eh_flush_done_q()
2200 !scsi_noretry_cmd(scmd) && scsi_cmd_retry_allowed(scmd) && in scsi_eh_flush_done_q()
2201 scsi_eh_should_retry_cmd(scmd)) { in scsi_eh_flush_done_q()
2203 scmd_printk(KERN_INFO, scmd, in scsi_eh_flush_done_q()
2206 scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY); in scsi_eh_flush_done_q()
2213 if (!scmd->result && in scsi_eh_flush_done_q()
2214 !(scmd->flags & SCMD_FORCE_EH_SUCCESS)) in scsi_eh_flush_done_q()
2215 scmd->result |= (DID_TIME_OUT << 16); in scsi_eh_flush_done_q()
2217 scmd_printk(KERN_INFO, scmd, in scsi_eh_flush_done_q()
2220 scsi_finish_command(scmd); in scsi_eh_flush_done_q()
2434 struct scsi_cmnd *scmd; in scsi_ioctl_reset() local
2458 scmd = (struct scsi_cmnd *)(rq + 1); in scsi_ioctl_reset()
2459 scsi_init_command(dev, scmd); in scsi_ioctl_reset()
2461 scmd->submitter = SUBMITTED_BY_SCSI_RESET_IOCTL; in scsi_ioctl_reset()
2462 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); in scsi_ioctl_reset()
2464 scmd->cmd_len = 0; in scsi_ioctl_reset()
2466 scmd->sc_data_direction = DMA_BIDIRECTIONAL; in scsi_ioctl_reset()
2477 rtn = scsi_try_bus_device_reset(scmd); in scsi_ioctl_reset()
2482 rtn = scsi_try_target_reset(scmd); in scsi_ioctl_reset()
2487 rtn = scsi_try_bus_reset(scmd); in scsi_ioctl_reset()
2492 rtn = scsi_try_host_reset(scmd); in scsi_ioctl_reset()