Lines Matching refs:cmd

206 static void transport_complete_task_attr(struct se_cmd *cmd);
207 static void transport_direct_request_timeout(struct se_cmd *cmd);
208 static void transport_free_dev_tasks(struct se_cmd *cmd);
209 static u32 transport_generic_get_cdb_count(struct se_cmd *cmd,
213 static int transport_generic_get_mem(struct se_cmd *cmd, u32 length,
215 static int transport_generic_remove(struct se_cmd *cmd,
217 static int transport_get_sectors(struct se_cmd *cmd);
219 static int transport_map_sg_to_mem(struct se_cmd *cmd,
222 static void transport_memcpy_se_mem_read_contig(struct se_cmd *cmd,
224 static void transport_release_fe_cmd(struct se_cmd *cmd);
225 static void transport_remove_cmd_from_queue(struct se_cmd *cmd,
227 static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq);
228 static void transport_stop_all_task_timers(struct se_cmd *cmd);
620 static void transport_all_task_dev_remove_state(struct se_cmd *cmd) in transport_all_task_dev_remove_state() argument
626 if (!T_TASK(cmd)) in transport_all_task_dev_remove_state()
629 list_for_each_entry(task, &T_TASK(cmd)->t_task_list, t_list) { in transport_all_task_dev_remove_state()
643 CMD_TFO(cmd)->tfo_get_task_tag(cmd), dev, task); in transport_all_task_dev_remove_state()
647 atomic_dec(&T_TASK(cmd)->t_task_cdbs_ex_left); in transport_all_task_dev_remove_state()
660 struct se_cmd *cmd, in transport_cmd_check_stop() argument
666 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_cmd_check_stop()
671 if (atomic_read(&T_TASK(cmd)->transport_lun_stop)) { in transport_cmd_check_stop()
674 CMD_TFO(cmd)->get_task_tag(cmd)); in transport_cmd_check_stop()
676 cmd->deferred_t_state = cmd->t_state; in transport_cmd_check_stop()
677 cmd->t_state = TRANSPORT_DEFERRED_CMD; in transport_cmd_check_stop()
678 atomic_set(&T_TASK(cmd)->t_transport_active, 0); in transport_cmd_check_stop()
680 transport_all_task_dev_remove_state(cmd); in transport_cmd_check_stop()
681 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_cmd_check_stop()
683 complete(&T_TASK(cmd)->transport_lun_stop_comp); in transport_cmd_check_stop()
690 if (atomic_read(&T_TASK(cmd)->t_transport_stop)) { in transport_cmd_check_stop()
693 CMD_TFO(cmd)->get_task_tag(cmd)); in transport_cmd_check_stop()
695 cmd->deferred_t_state = cmd->t_state; in transport_cmd_check_stop()
696 cmd->t_state = TRANSPORT_DEFERRED_CMD; in transport_cmd_check_stop()
698 transport_all_task_dev_remove_state(cmd); in transport_cmd_check_stop()
705 cmd->se_lun = NULL; in transport_cmd_check_stop()
706 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_cmd_check_stop()
708 complete(&T_TASK(cmd)->t_transport_stop_comp); in transport_cmd_check_stop()
712 atomic_set(&T_TASK(cmd)->t_transport_active, 0); in transport_cmd_check_stop()
714 transport_all_task_dev_remove_state(cmd); in transport_cmd_check_stop()
719 cmd->se_lun = NULL; in transport_cmd_check_stop()
725 if (CMD_TFO(cmd)->check_stop_free != NULL) { in transport_cmd_check_stop()
727 &T_TASK(cmd)->t_state_lock, flags); in transport_cmd_check_stop()
729 CMD_TFO(cmd)->check_stop_free(cmd); in transport_cmd_check_stop()
733 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_cmd_check_stop()
737 cmd->t_state = t_state; in transport_cmd_check_stop()
738 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_cmd_check_stop()
743 static int transport_cmd_check_stop_to_fabric(struct se_cmd *cmd) in transport_cmd_check_stop_to_fabric() argument
745 return transport_cmd_check_stop(cmd, 2, 0); in transport_cmd_check_stop_to_fabric()
748 static void transport_lun_remove_cmd(struct se_cmd *cmd) in transport_lun_remove_cmd() argument
750 struct se_lun *lun = SE_LUN(cmd); in transport_lun_remove_cmd()
756 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_lun_remove_cmd()
757 if (!(atomic_read(&T_TASK(cmd)->transport_dev_active))) { in transport_lun_remove_cmd()
758 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_lun_remove_cmd()
761 atomic_set(&T_TASK(cmd)->transport_dev_active, 0); in transport_lun_remove_cmd()
762 transport_all_task_dev_remove_state(cmd); in transport_lun_remove_cmd()
763 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_lun_remove_cmd()
765 transport_free_dev_tasks(cmd); in transport_lun_remove_cmd()
769 if (atomic_read(&T_TASK(cmd)->transport_lun_active)) { in transport_lun_remove_cmd()
770 list_del(&cmd->se_lun_list); in transport_lun_remove_cmd()
771 atomic_set(&T_TASK(cmd)->transport_lun_active, 0); in transport_lun_remove_cmd()
774 CMD_TFO(cmd)->get_task_tag(cmd), lun->unpacked_lun); in transport_lun_remove_cmd()
780 void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) in transport_cmd_finish_abort() argument
782 transport_remove_cmd_from_queue(cmd, SE_DEV(cmd)->dev_queue_obj); in transport_cmd_finish_abort()
783 transport_lun_remove_cmd(cmd); in transport_cmd_finish_abort()
785 if (transport_cmd_check_stop_to_fabric(cmd)) in transport_cmd_finish_abort()
788 transport_generic_remove(cmd, 0, 0); in transport_cmd_finish_abort()
791 void transport_cmd_finish_abort_tmr(struct se_cmd *cmd) in transport_cmd_finish_abort_tmr() argument
793 transport_remove_cmd_from_queue(cmd, SE_DEV(cmd)->dev_queue_obj); in transport_cmd_finish_abort_tmr()
795 if (transport_cmd_check_stop_to_fabric(cmd)) in transport_cmd_finish_abort_tmr()
798 transport_generic_remove(cmd, 0, 0); in transport_cmd_finish_abort_tmr()
802 struct se_cmd *cmd, in transport_add_cmd_to_queue() argument
805 struct se_device *dev = cmd->se_dev; in transport_add_cmd_to_queue()
818 qr->cmd = (void *)cmd; in transport_add_cmd_to_queue()
822 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_add_cmd_to_queue()
823 cmd->t_state = t_state; in transport_add_cmd_to_queue()
824 atomic_set(&T_TASK(cmd)->t_transport_active, 1); in transport_add_cmd_to_queue()
825 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_add_cmd_to_queue()
830 atomic_inc(&T_TASK(cmd)->t_transport_queue_active); in transport_add_cmd_to_queue()
844 struct se_cmd *cmd; in __transport_get_qr_from_queue() local
853 if (qr->cmd) { in __transport_get_qr_from_queue()
854 cmd = (struct se_cmd *)qr->cmd; in __transport_get_qr_from_queue()
855 atomic_dec(&T_TASK(cmd)->t_transport_queue_active); in __transport_get_qr_from_queue()
866 struct se_cmd *cmd; in transport_get_qr_from_queue() local
879 if (qr->cmd) { in transport_get_qr_from_queue()
880 cmd = (struct se_cmd *)qr->cmd; in transport_get_qr_from_queue()
881 atomic_dec(&T_TASK(cmd)->t_transport_queue_active); in transport_get_qr_from_queue()
890 static void transport_remove_cmd_from_queue(struct se_cmd *cmd, in transport_remove_cmd_from_queue() argument
898 if (!(atomic_read(&T_TASK(cmd)->t_transport_queue_active))) { in transport_remove_cmd_from_queue()
904 q_cmd = (struct se_cmd *)qr->cmd; in transport_remove_cmd_from_queue()
905 if (q_cmd != cmd) in transport_remove_cmd_from_queue()
915 if (atomic_read(&T_TASK(cmd)->t_transport_queue_active)) { in transport_remove_cmd_from_queue()
917 CMD_TFO(cmd)->get_task_tag(cmd), in transport_remove_cmd_from_queue()
918 atomic_read(&T_TASK(cmd)->t_transport_queue_active)); in transport_remove_cmd_from_queue()
926 void transport_complete_sync_cache(struct se_cmd *cmd, int good) in transport_complete_sync_cache() argument
928 struct se_task *task = list_entry(T_TASK(cmd)->t_task_list.next, in transport_complete_sync_cache()
932 cmd->scsi_status = SAM_STAT_GOOD; in transport_complete_sync_cache()
952 struct se_cmd *cmd = TASK_CMD(task); in transport_complete_task() local
958 T_TASK(cmd)->t_task_cdb[0], dev); in transport_complete_task()
967 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_complete_task()
977 cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE; in transport_complete_task()
993 atomic_dec(&T_TASK(cmd)->t_se_count); in transport_complete_task()
996 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_complete_task()
1008 &T_TASK(cmd)->t_task_cdbs_timeout_left))) { in transport_complete_task()
1009 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, in transport_complete_task()
1014 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_complete_task()
1016 transport_add_cmd_to_queue(cmd, t_state); in transport_complete_task()
1019 atomic_dec(&T_TASK(cmd)->t_task_cdbs_timeout_left); in transport_complete_task()
1026 if (!(atomic_dec_and_test(&T_TASK(cmd)->t_task_cdbs_left))) { in transport_complete_task()
1028 T_TASK(cmd)->t_tasks_failed = 1; in transport_complete_task()
1030 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_complete_task()
1034 if (!success || T_TASK(cmd)->t_tasks_failed) { in transport_complete_task()
1039 cmd->transport_error_status = in transport_complete_task()
1043 atomic_set(&T_TASK(cmd)->t_transport_complete, 1); in transport_complete_task()
1046 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_complete_task()
1048 transport_add_cmd_to_queue(cmd, t_state); in transport_complete_task()
1133 static void transport_add_tasks_to_state_queue(struct se_cmd *cmd) in transport_add_tasks_to_state_queue() argument
1139 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_add_tasks_to_state_queue()
1140 list_for_each_entry(task, &T_TASK(cmd)->t_task_list, t_list) { in transport_add_tasks_to_state_queue()
1156 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_add_tasks_to_state_queue()
1159 static void transport_add_tasks_from_cmd(struct se_cmd *cmd) in transport_add_tasks_from_cmd() argument
1161 struct se_device *dev = SE_DEV(cmd); in transport_add_tasks_from_cmd()
1166 list_for_each_entry(task, &T_TASK(cmd)->t_task_list, t_list) { in transport_add_tasks_from_cmd()
1219 unsigned char *transport_dump_cmd_direction(struct se_cmd *cmd) in transport_dump_cmd_direction() argument
1221 switch (cmd->data_direction) { in transport_dump_cmd_direction()
1276 struct se_cmd *cmd = NULL; in transport_release_all_cmds() local
1285 cmd = (struct se_cmd *)qr->cmd; in transport_release_all_cmds()
1294 CMD_TFO(cmd)->get_task_tag(cmd), in transport_release_all_cmds()
1295 CMD_TFO(cmd)->get_cmd_state(cmd), t_state); in transport_release_all_cmds()
1297 transport_release_fe_cmd(cmd); in transport_release_all_cmds()
1787 transport_generic_get_task(struct se_cmd *cmd, in transport_generic_get_task() argument
1791 struct se_device *dev = SE_DEV(cmd); in transport_generic_get_task()
1794 task = dev->transport->alloc_task(cmd); in transport_generic_get_task()
1804 task->task_no = T_TASK(cmd)->t_tasks_no++; in transport_generic_get_task()
1805 task->task_se_cmd = cmd; in transport_generic_get_task()
1809 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_get_task()
1810 list_add_tail(&task->t_list, &T_TASK(cmd)->t_task_list); in transport_generic_get_task()
1811 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_get_task()
1818 void transport_device_setup_cmd(struct se_cmd *cmd) in transport_device_setup_cmd() argument
1820 cmd->se_dev = SE_LUN(cmd)->lun_se_dev; in transport_device_setup_cmd()
1829 struct se_cmd *cmd, in transport_init_se_cmd() argument
1837 INIT_LIST_HEAD(&cmd->se_lun_list); in transport_init_se_cmd()
1838 INIT_LIST_HEAD(&cmd->se_delayed_list); in transport_init_se_cmd()
1839 INIT_LIST_HEAD(&cmd->se_ordered_list); in transport_init_se_cmd()
1843 cmd->t_task = &cmd->t_task_backstore; in transport_init_se_cmd()
1845 INIT_LIST_HEAD(&T_TASK(cmd)->t_task_list); in transport_init_se_cmd()
1846 init_completion(&T_TASK(cmd)->transport_lun_fe_stop_comp); in transport_init_se_cmd()
1847 init_completion(&T_TASK(cmd)->transport_lun_stop_comp); in transport_init_se_cmd()
1848 init_completion(&T_TASK(cmd)->t_transport_stop_comp); in transport_init_se_cmd()
1849 spin_lock_init(&T_TASK(cmd)->t_state_lock); in transport_init_se_cmd()
1850 atomic_set(&T_TASK(cmd)->transport_dev_active, 1); in transport_init_se_cmd()
1852 cmd->se_tfo = tfo; in transport_init_se_cmd()
1853 cmd->se_sess = se_sess; in transport_init_se_cmd()
1854 cmd->data_length = data_length; in transport_init_se_cmd()
1855 cmd->data_direction = data_direction; in transport_init_se_cmd()
1856 cmd->sam_task_attr = task_attr; in transport_init_se_cmd()
1857 cmd->sense_buffer = sense_buffer; in transport_init_se_cmd()
1861 static int transport_check_alloc_task_attr(struct se_cmd *cmd) in transport_check_alloc_task_attr() argument
1867 if (SE_DEV(cmd)->dev_task_attr_type != SAM_TASK_ATTR_EMULATED) in transport_check_alloc_task_attr()
1870 if (cmd->sam_task_attr == TASK_ATTR_ACA) { in transport_check_alloc_task_attr()
1879 cmd->se_ordered_id = atomic_inc_return(&SE_DEV(cmd)->dev_ordered_id); in transport_check_alloc_task_attr()
1882 cmd->se_ordered_id, cmd->sam_task_attr, in transport_check_alloc_task_attr()
1883 TRANSPORT(cmd->se_dev)->name); in transport_check_alloc_task_attr()
1907 struct se_cmd *cmd, in transport_generic_allocate_tasks() argument
1917 cmd->transport_wait_for_tasks = &transport_generic_wait_for_tasks; in transport_generic_allocate_tasks()
1919 transport_device_setup_cmd(cmd); in transport_generic_allocate_tasks()
1935 if (scsi_command_size(cdb) > sizeof(T_TASK(cmd)->__t_task_cdb)) { in transport_generic_allocate_tasks()
1936 T_TASK(cmd)->t_task_cdb = kzalloc(scsi_command_size(cdb), in transport_generic_allocate_tasks()
1938 if (!(T_TASK(cmd)->t_task_cdb)) { in transport_generic_allocate_tasks()
1942 (unsigned long)sizeof(T_TASK(cmd)->__t_task_cdb)); in transport_generic_allocate_tasks()
1946 T_TASK(cmd)->t_task_cdb = &T_TASK(cmd)->__t_task_cdb[0]; in transport_generic_allocate_tasks()
1950 memcpy(T_TASK(cmd)->t_task_cdb, cdb, scsi_command_size(cdb)); in transport_generic_allocate_tasks()
1957 ret = transport_generic_cmd_sequencer(cmd, cdb); in transport_generic_allocate_tasks()
1963 if (transport_check_alloc_task_attr(cmd) < 0) { in transport_generic_allocate_tasks()
1964 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_generic_allocate_tasks()
1965 cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; in transport_generic_allocate_tasks()
1968 spin_lock(&cmd->se_lun->lun_sep_lock); in transport_generic_allocate_tasks()
1969 if (cmd->se_lun->lun_sep) in transport_generic_allocate_tasks()
1970 cmd->se_lun->lun_sep->sep_stats.cmd_pdus++; in transport_generic_allocate_tasks()
1971 spin_unlock(&cmd->se_lun->lun_sep_lock); in transport_generic_allocate_tasks()
1981 struct se_cmd *cmd) in transport_generic_handle_cdb() argument
1983 if (!SE_LUN(cmd)) { in transport_generic_handle_cdb()
1989 transport_add_cmd_to_queue(cmd, TRANSPORT_NEW_CMD); in transport_generic_handle_cdb()
2000 struct se_cmd *cmd) in transport_generic_handle_cdb_map() argument
2002 if (!SE_LUN(cmd)) { in transport_generic_handle_cdb_map()
2008 transport_add_cmd_to_queue(cmd, TRANSPORT_NEW_CMD_MAP); in transport_generic_handle_cdb_map()
2018 struct se_cmd *cmd) in transport_generic_handle_data() argument
2035 if (transport_check_aborted_status(cmd, 1) != 0) in transport_generic_handle_data()
2038 transport_add_cmd_to_queue(cmd, TRANSPORT_PROCESS_WRITE); in transport_generic_handle_data()
2048 struct se_cmd *cmd) in transport_generic_handle_tmr() argument
2053 cmd->transport_wait_for_tasks = &transport_generic_wait_for_tasks; in transport_generic_handle_tmr()
2054 transport_device_setup_cmd(cmd); in transport_generic_handle_tmr()
2056 transport_add_cmd_to_queue(cmd, TRANSPORT_PROCESS_TMR); in transport_generic_handle_tmr()
2061 static int transport_stop_tasks_for_cmd(struct se_cmd *cmd) in transport_stop_tasks_for_cmd() argument
2068 CMD_TFO(cmd)->get_task_tag(cmd)); in transport_stop_tasks_for_cmd()
2073 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_stop_tasks_for_cmd()
2075 &T_TASK(cmd)->t_task_list, t_list) { in transport_stop_tasks_for_cmd()
2084 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, in transport_stop_tasks_for_cmd()
2091 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_stop_tasks_for_cmd()
2101 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, in transport_stop_tasks_for_cmd()
2110 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_stop_tasks_for_cmd()
2111 atomic_dec(&T_TASK(cmd)->t_task_cdbs_left); in transport_stop_tasks_for_cmd()
2122 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_stop_tasks_for_cmd()
2141 struct se_cmd *cmd, in transport_generic_request_failure() argument
2147 " CDB: 0x%02x\n", cmd, CMD_TFO(cmd)->get_task_tag(cmd), in transport_generic_request_failure()
2148 T_TASK(cmd)->t_task_cdb[0]); in transport_generic_request_failure()
2151 CMD_TFO(cmd)->get_cmd_state(cmd), in transport_generic_request_failure()
2152 cmd->t_state, cmd->deferred_t_state, in transport_generic_request_failure()
2153 cmd->transport_error_status); in transport_generic_request_failure()
2157 " t_transport_sent: %d\n", T_TASK(cmd)->t_task_cdbs, in transport_generic_request_failure()
2158 atomic_read(&T_TASK(cmd)->t_task_cdbs_left), in transport_generic_request_failure()
2159 atomic_read(&T_TASK(cmd)->t_task_cdbs_sent), in transport_generic_request_failure()
2160 atomic_read(&T_TASK(cmd)->t_task_cdbs_ex_left), in transport_generic_request_failure()
2161 atomic_read(&T_TASK(cmd)->t_transport_active), in transport_generic_request_failure()
2162 atomic_read(&T_TASK(cmd)->t_transport_stop), in transport_generic_request_failure()
2163 atomic_read(&T_TASK(cmd)->t_transport_sent)); in transport_generic_request_failure()
2165 transport_stop_all_task_timers(cmd); in transport_generic_request_failure()
2172 if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) in transport_generic_request_failure()
2173 transport_complete_task_attr(cmd); in transport_generic_request_failure()
2176 transport_direct_request_timeout(cmd); in transport_generic_request_failure()
2177 cmd->transport_error_status = PYX_TRANSPORT_LU_COMM_FAILURE; in transport_generic_request_failure()
2180 switch (cmd->transport_error_status) { in transport_generic_request_failure()
2182 cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; in transport_generic_request_failure()
2185 cmd->scsi_sense_reason = TCM_SECTOR_COUNT_TOO_MANY; in transport_generic_request_failure()
2188 cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; in transport_generic_request_failure()
2191 cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; in transport_generic_request_failure()
2195 transport_new_cmd_failure(cmd); in transport_generic_request_failure()
2201 CMD_TFO(cmd)->fall_back_to_erl0(cmd->se_sess); in transport_generic_request_failure()
2202 CMD_TFO(cmd)->stop_session(cmd->se_sess, 0, 0); in transport_generic_request_failure()
2207 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; in transport_generic_request_failure()
2210 cmd->scsi_sense_reason = TCM_UNKNOWN_MODE_PAGE; in transport_generic_request_failure()
2213 cmd->scsi_sense_reason = TCM_WRITE_PROTECTED; in transport_generic_request_failure()
2222 cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT; in transport_generic_request_failure()
2230 if (SE_SESS(cmd) && in transport_generic_request_failure()
2231 DEV_ATTRIB(cmd->se_dev)->emulate_ua_intlck_ctrl == 2) in transport_generic_request_failure()
2232 core_scsi3_ua_allocate(SE_SESS(cmd)->se_node_acl, in transport_generic_request_failure()
2233 cmd->orig_fe_lun, 0x2C, in transport_generic_request_failure()
2236 CMD_TFO(cmd)->queue_status(cmd); in transport_generic_request_failure()
2245 T_TASK(cmd)->t_task_cdb[0], in transport_generic_request_failure()
2246 cmd->transport_error_status); in transport_generic_request_failure()
2247 cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; in transport_generic_request_failure()
2252 transport_new_cmd_failure(cmd); in transport_generic_request_failure()
2254 transport_send_check_condition_and_sense(cmd, in transport_generic_request_failure()
2255 cmd->scsi_sense_reason, 0); in transport_generic_request_failure()
2257 transport_lun_remove_cmd(cmd); in transport_generic_request_failure()
2258 if (!(transport_cmd_check_stop_to_fabric(cmd))) in transport_generic_request_failure()
2262 static void transport_direct_request_timeout(struct se_cmd *cmd) in transport_direct_request_timeout() argument
2266 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_direct_request_timeout()
2267 if (!(atomic_read(&T_TASK(cmd)->t_transport_timeout))) { in transport_direct_request_timeout()
2268 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_direct_request_timeout()
2271 if (atomic_read(&T_TASK(cmd)->t_task_cdbs_timeout_left)) { in transport_direct_request_timeout()
2272 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_direct_request_timeout()
2276 atomic_sub(atomic_read(&T_TASK(cmd)->t_transport_timeout), in transport_direct_request_timeout()
2277 &T_TASK(cmd)->t_se_count); in transport_direct_request_timeout()
2278 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_direct_request_timeout()
2281 static void transport_generic_request_timeout(struct se_cmd *cmd) in transport_generic_request_timeout() argument
2289 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_request_timeout()
2290 if (atomic_read(&T_TASK(cmd)->t_transport_timeout) > 1) { in transport_generic_request_timeout()
2291 int tmp = (atomic_read(&T_TASK(cmd)->t_transport_timeout) - 1); in transport_generic_request_timeout()
2293 atomic_sub(tmp, &T_TASK(cmd)->t_se_count); in transport_generic_request_timeout()
2295 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_request_timeout()
2297 transport_generic_remove(cmd, 0, 0); in transport_generic_request_timeout()
2301 transport_generic_allocate_buf(struct se_cmd *cmd, u32 data_length) in transport_generic_allocate_buf() argument
2311 T_TASK(cmd)->t_tasks_se_num = 0; in transport_generic_allocate_buf()
2312 T_TASK(cmd)->t_task_buf = buf; in transport_generic_allocate_buf()
2365 struct se_cmd *cmd = TASK_CMD(task); in transport_task_timeout_handler() local
2368 DEBUG_TT("transport task timeout fired! task: %p cmd: %p\n", task, cmd); in transport_task_timeout_handler()
2370 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_task_timeout_handler()
2372 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_task_timeout_handler()
2382 " == 0\n", task, cmd); in transport_task_timeout_handler()
2383 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_task_timeout_handler()
2387 atomic_inc(&T_TASK(cmd)->t_se_count); in transport_task_timeout_handler()
2388 atomic_inc(&T_TASK(cmd)->t_transport_timeout); in transport_task_timeout_handler()
2389 T_TASK(cmd)->t_tasks_failed = 1; in transport_task_timeout_handler()
2397 " == 1\n", task, cmd); in transport_task_timeout_handler()
2398 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_task_timeout_handler()
2403 if (!(atomic_dec_and_test(&T_TASK(cmd)->t_task_cdbs_left))) { in transport_task_timeout_handler()
2405 " t_task_cdbs_left\n", task, cmd); in transport_task_timeout_handler()
2406 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_task_timeout_handler()
2410 task, cmd); in transport_task_timeout_handler()
2412 cmd->t_state = TRANSPORT_COMPLETE_FAILURE; in transport_task_timeout_handler()
2413 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_task_timeout_handler()
2415 transport_add_cmd_to_queue(cmd, TRANSPORT_COMPLETE_FAILURE); in transport_task_timeout_handler()
2453 struct se_cmd *cmd = TASK_CMD(task); in __transport_stop_task_timer() local
2459 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, *flags); in __transport_stop_task_timer()
2463 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, *flags); in __transport_stop_task_timer()
2468 static void transport_stop_all_task_timers(struct se_cmd *cmd) in transport_stop_all_task_timers() argument
2473 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_stop_all_task_timers()
2475 &T_TASK(cmd)->t_task_list, t_list) in transport_stop_all_task_timers()
2477 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_stop_all_task_timers()
2499 static inline int transport_execute_task_attr(struct se_cmd *cmd) in transport_execute_task_attr() argument
2501 if (SE_DEV(cmd)->dev_task_attr_type != SAM_TASK_ATTR_EMULATED) in transport_execute_task_attr()
2507 if (cmd->sam_task_attr == TASK_ATTR_HOQ) { in transport_execute_task_attr()
2508 atomic_inc(&SE_DEV(cmd)->dev_hoq_count); in transport_execute_task_attr()
2512 T_TASK(cmd)->t_task_cdb[0], in transport_execute_task_attr()
2513 cmd->se_ordered_id); in transport_execute_task_attr()
2515 } else if (cmd->sam_task_attr == TASK_ATTR_ORDERED) { in transport_execute_task_attr()
2516 spin_lock(&SE_DEV(cmd)->ordered_cmd_lock); in transport_execute_task_attr()
2517 list_add_tail(&cmd->se_ordered_list, in transport_execute_task_attr()
2518 &SE_DEV(cmd)->ordered_cmd_list); in transport_execute_task_attr()
2519 spin_unlock(&SE_DEV(cmd)->ordered_cmd_lock); in transport_execute_task_attr()
2521 atomic_inc(&SE_DEV(cmd)->dev_ordered_sync); in transport_execute_task_attr()
2526 T_TASK(cmd)->t_task_cdb[0], in transport_execute_task_attr()
2527 cmd->se_ordered_id); in transport_execute_task_attr()
2533 if (!(atomic_read(&SE_DEV(cmd)->simple_cmds))) in transport_execute_task_attr()
2539 atomic_inc(&SE_DEV(cmd)->simple_cmds); in transport_execute_task_attr()
2547 if (atomic_read(&SE_DEV(cmd)->dev_ordered_sync) != 0) { in transport_execute_task_attr()
2552 spin_lock(&SE_DEV(cmd)->delayed_cmd_lock); in transport_execute_task_attr()
2553 cmd->se_cmd_flags |= SCF_DELAYED_CMD_FROM_SAM_ATTR; in transport_execute_task_attr()
2554 list_add_tail(&cmd->se_delayed_list, in transport_execute_task_attr()
2555 &SE_DEV(cmd)->delayed_cmd_list); in transport_execute_task_attr()
2556 spin_unlock(&SE_DEV(cmd)->delayed_cmd_lock); in transport_execute_task_attr()
2560 T_TASK(cmd)->t_task_cdb[0], cmd->sam_task_attr, in transport_execute_task_attr()
2561 cmd->se_ordered_id); in transport_execute_task_attr()
2578 static int transport_execute_tasks(struct se_cmd *cmd) in transport_execute_tasks() argument
2582 if (!(cmd->se_cmd_flags & SCF_SE_DISABLE_ONLINE_CHECK)) { in transport_execute_tasks()
2583 if (se_dev_check_online(cmd->se_orig_obj_ptr) != 0) { in transport_execute_tasks()
2584 cmd->transport_error_status = in transport_execute_tasks()
2586 transport_generic_request_failure(cmd, NULL, 0, 1); in transport_execute_tasks()
2594 if (!(transport_cmd_check_stop(cmd, 0, TRANSPORT_PROCESSING))) { in transport_execute_tasks()
2599 add_tasks = transport_execute_task_attr(cmd); in transport_execute_tasks()
2608 transport_add_tasks_from_cmd(cmd); in transport_execute_tasks()
2615 __transport_execute_tasks(SE_DEV(cmd)); in transport_execute_tasks()
2628 struct se_cmd *cmd = NULL; in __transport_execute_tasks() local
2658 cmd = TASK_CMD(task); in __transport_execute_tasks()
2660 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in __transport_execute_tasks()
2663 atomic_inc(&T_TASK(cmd)->t_task_cdbs_sent); in __transport_execute_tasks()
2665 if (atomic_read(&T_TASK(cmd)->t_task_cdbs_sent) == in __transport_execute_tasks()
2666 T_TASK(cmd)->t_task_cdbs) in __transport_execute_tasks()
2667 atomic_set(&cmd->transport_sent, 1); in __transport_execute_tasks()
2670 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in __transport_execute_tasks()
2676 if (cmd->transport_emulate_cdb) { in __transport_execute_tasks()
2677 error = cmd->transport_emulate_cdb(cmd); in __transport_execute_tasks()
2679 cmd->transport_error_status = error; in __transport_execute_tasks()
2681 atomic_set(&cmd->transport_sent, 0); in __transport_execute_tasks()
2682 transport_stop_tasks_for_cmd(cmd); in __transport_execute_tasks()
2683 transport_generic_request_failure(cmd, dev, 0, 1); in __transport_execute_tasks()
2692 if (!(cmd->se_cmd_flags & SCF_EMULATE_CDB_ASYNC)) { in __transport_execute_tasks()
2693 cmd->scsi_status = SAM_STAT_GOOD; in __transport_execute_tasks()
2715 cmd->transport_error_status = error; in __transport_execute_tasks()
2717 atomic_set(&cmd->transport_sent, 0); in __transport_execute_tasks()
2718 transport_stop_tasks_for_cmd(cmd); in __transport_execute_tasks()
2719 transport_generic_request_failure(cmd, dev, 0, 1); in __transport_execute_tasks()
2747 struct se_cmd *cmd, in transport_get_sectors_6() argument
2750 struct se_device *dev = SE_LUN(cmd)->lun_se_dev; in transport_get_sectors_6()
2775 struct se_cmd *cmd, in transport_get_sectors_10() argument
2778 struct se_device *dev = SE_LUN(cmd)->lun_se_dev; in transport_get_sectors_10()
2805 struct se_cmd *cmd, in transport_get_sectors_12() argument
2808 struct se_device *dev = SE_LUN(cmd)->lun_se_dev; in transport_get_sectors_12()
2835 struct se_cmd *cmd, in transport_get_sectors_16() argument
2838 struct se_device *dev = SE_LUN(cmd)->lun_se_dev; in transport_get_sectors_16()
2863 struct se_cmd *cmd, in transport_get_sectors_32() argument
2878 struct se_cmd *cmd) in transport_get_size() argument
2880 struct se_device *dev = SE_DEV(cmd); in transport_get_size()
2925 static void transport_xor_callback(struct se_cmd *cmd) in transport_xor_callback() argument
2942 buf = kmalloc(cmd->data_length, GFP_KERNEL); in transport_xor_callback()
2951 transport_memcpy_se_mem_read_contig(cmd, buf, T_TASK(cmd)->t_mem_list); in transport_xor_callback()
2958 list_for_each_entry(se_mem, T_TASK(cmd)->t_mem_bidi_list, se_list) { in transport_xor_callback()
2976 static int transport_get_sense_data(struct se_cmd *cmd) in transport_get_sense_data() argument
2978 unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL; in transport_get_sense_data()
2984 if (!SE_LUN(cmd)) { in transport_get_sense_data()
2988 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_get_sense_data()
2989 if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { in transport_get_sense_data()
2990 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_get_sense_data()
2995 &T_TASK(cmd)->t_task_list, t_list) { in transport_get_sense_data()
3014 CMD_TFO(cmd)->get_task_tag(cmd), task->task_no); in transport_get_sense_data()
3017 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_get_sense_data()
3019 offset = CMD_TFO(cmd)->set_fabric_sense_len(cmd, in transport_get_sense_data()
3024 cmd->scsi_status = task->task_scsi_status; in transport_get_sense_data()
3026 cmd->scsi_sense_length = in transport_get_sense_data()
3032 cmd->scsi_status); in transport_get_sense_data()
3035 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_get_sense_data()
3040 static int transport_allocate_resources(struct se_cmd *cmd) in transport_allocate_resources() argument
3042 u32 length = cmd->data_length; in transport_allocate_resources()
3044 if ((cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) || in transport_allocate_resources()
3045 (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB)) in transport_allocate_resources()
3046 return transport_generic_get_mem(cmd, length, PAGE_SIZE); in transport_allocate_resources()
3047 else if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB) in transport_allocate_resources()
3048 return transport_generic_allocate_buf(cmd, length); in transport_allocate_resources()
3054 transport_handle_reservation_conflict(struct se_cmd *cmd) in transport_handle_reservation_conflict() argument
3056 cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks; in transport_handle_reservation_conflict()
3057 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_handle_reservation_conflict()
3058 cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT; in transport_handle_reservation_conflict()
3059 cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT; in transport_handle_reservation_conflict()
3067 if (SE_SESS(cmd) && in transport_handle_reservation_conflict()
3068 DEV_ATTRIB(cmd->se_dev)->emulate_ua_intlck_ctrl == 2) in transport_handle_reservation_conflict()
3069 core_scsi3_ua_allocate(SE_SESS(cmd)->se_node_acl, in transport_handle_reservation_conflict()
3070 cmd->orig_fe_lun, 0x2C, in transport_handle_reservation_conflict()
3086 struct se_cmd *cmd, in transport_generic_cmd_sequencer() argument
3089 struct se_device *dev = SE_DEV(cmd); in transport_generic_cmd_sequencer()
3098 if (core_scsi3_ua_check(cmd, cdb) < 0) { in transport_generic_cmd_sequencer()
3099 cmd->transport_wait_for_tasks = in transport_generic_cmd_sequencer()
3101 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_generic_cmd_sequencer()
3102 cmd->scsi_sense_reason = TCM_CHECK_CONDITION_UNIT_ATTENTION; in transport_generic_cmd_sequencer()
3108 ret = T10_ALUA(su_dev)->alua_state_check(cmd, cdb, &alua_ascq); in transport_generic_cmd_sequencer()
3110 cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks; in transport_generic_cmd_sequencer()
3120 CMD_TFO(cmd)->get_fabric_name(), alua_ascq); in transport_generic_cmd_sequencer()
3122 transport_set_sense_codes(cmd, 0x04, alua_ascq); in transport_generic_cmd_sequencer()
3123 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_generic_cmd_sequencer()
3124 cmd->scsi_sense_reason = TCM_CHECK_CONDITION_NOT_READY; in transport_generic_cmd_sequencer()
3132 if (T10_PR_OPS(su_dev)->t10_reservation_check(cmd, &pr_reg_type) != 0) { in transport_generic_cmd_sequencer()
3134 cmd, cdb, pr_reg_type) != 0) in transport_generic_cmd_sequencer()
3135 return transport_handle_reservation_conflict(cmd); in transport_generic_cmd_sequencer()
3145 sectors = transport_get_sectors_6(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3148 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3149 cmd->transport_split_cdb = &split_cdb_XX_6; in transport_generic_cmd_sequencer()
3150 T_TASK(cmd)->t_task_lba = transport_lba_21(cdb); in transport_generic_cmd_sequencer()
3151 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3154 sectors = transport_get_sectors_10(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3157 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3158 cmd->transport_split_cdb = &split_cdb_XX_10; in transport_generic_cmd_sequencer()
3159 T_TASK(cmd)->t_task_lba = transport_lba_32(cdb); in transport_generic_cmd_sequencer()
3160 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3163 sectors = transport_get_sectors_12(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3166 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3167 cmd->transport_split_cdb = &split_cdb_XX_12; in transport_generic_cmd_sequencer()
3168 T_TASK(cmd)->t_task_lba = transport_lba_32(cdb); in transport_generic_cmd_sequencer()
3169 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3172 sectors = transport_get_sectors_16(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3175 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3176 cmd->transport_split_cdb = &split_cdb_XX_16; in transport_generic_cmd_sequencer()
3177 T_TASK(cmd)->t_task_lba = transport_lba_64(cdb); in transport_generic_cmd_sequencer()
3178 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3181 sectors = transport_get_sectors_6(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3184 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3185 cmd->transport_split_cdb = &split_cdb_XX_6; in transport_generic_cmd_sequencer()
3186 T_TASK(cmd)->t_task_lba = transport_lba_21(cdb); in transport_generic_cmd_sequencer()
3187 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3190 sectors = transport_get_sectors_10(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3193 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3194 cmd->transport_split_cdb = &split_cdb_XX_10; in transport_generic_cmd_sequencer()
3195 T_TASK(cmd)->t_task_lba = transport_lba_32(cdb); in transport_generic_cmd_sequencer()
3196 T_TASK(cmd)->t_tasks_fua = (cdb[1] & 0x8); in transport_generic_cmd_sequencer()
3197 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3200 sectors = transport_get_sectors_12(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3203 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3204 cmd->transport_split_cdb = &split_cdb_XX_12; in transport_generic_cmd_sequencer()
3205 T_TASK(cmd)->t_task_lba = transport_lba_32(cdb); in transport_generic_cmd_sequencer()
3206 T_TASK(cmd)->t_tasks_fua = (cdb[1] & 0x8); in transport_generic_cmd_sequencer()
3207 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3210 sectors = transport_get_sectors_16(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3213 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3214 cmd->transport_split_cdb = &split_cdb_XX_16; in transport_generic_cmd_sequencer()
3215 T_TASK(cmd)->t_task_lba = transport_lba_64(cdb); in transport_generic_cmd_sequencer()
3216 T_TASK(cmd)->t_tasks_fua = (cdb[1] & 0x8); in transport_generic_cmd_sequencer()
3217 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3220 if ((cmd->data_direction != DMA_TO_DEVICE) || in transport_generic_cmd_sequencer()
3221 !(T_TASK(cmd)->t_tasks_bidi)) in transport_generic_cmd_sequencer()
3223 sectors = transport_get_sectors_10(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3226 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3227 cmd->transport_split_cdb = &split_cdb_XX_10; in transport_generic_cmd_sequencer()
3228 T_TASK(cmd)->t_task_lba = transport_lba_32(cdb); in transport_generic_cmd_sequencer()
3229 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3240 cmd->transport_complete_callback = &transport_xor_callback; in transport_generic_cmd_sequencer()
3241 T_TASK(cmd)->t_tasks_fua = (cdb[1] & 0x8); in transport_generic_cmd_sequencer()
3254 sectors = transport_get_sectors_32(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3257 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3262 cmd->transport_split_cdb = &split_cdb_XX_32; in transport_generic_cmd_sequencer()
3263 T_TASK(cmd)->t_task_lba = transport_lba_64_ext(cdb); in transport_generic_cmd_sequencer()
3264 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; in transport_generic_cmd_sequencer()
3276 cmd->transport_complete_callback = &transport_xor_callback; in transport_generic_cmd_sequencer()
3277 T_TASK(cmd)->t_tasks_fua = (cdb[10] & 0x8); in transport_generic_cmd_sequencer()
3280 sectors = transport_get_sectors_32(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3283 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3284 T_TASK(cmd)->t_task_lba = get_unaligned_be64(&cdb[12]); in transport_generic_cmd_sequencer()
3285 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; in transport_generic_cmd_sequencer()
3322 cmd->transport_emulate_cdb = in transport_generic_cmd_sequencer()
3334 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3338 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; in transport_generic_cmd_sequencer()
3342 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; in transport_generic_cmd_sequencer()
3346 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3354 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3358 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3365 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; in transport_generic_cmd_sequencer()
3369 cmd->transport_emulate_cdb = in transport_generic_cmd_sequencer()
3374 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3379 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; in transport_generic_cmd_sequencer()
3383 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3392 cmd->transport_emulate_cdb = in transport_generic_cmd_sequencer()
3405 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3413 if (SE_DEV(cmd)->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) in transport_generic_cmd_sequencer()
3414 cmd->sam_task_attr = TASK_ATTR_HOQ; in transport_generic_cmd_sequencer()
3415 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3419 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3423 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3429 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3440 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3445 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3452 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3457 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3461 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3465 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3469 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3480 size = cmd->data_length; in transport_generic_cmd_sequencer()
3489 cmd->transport_emulate_cdb = in transport_generic_cmd_sequencer()
3493 cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; in transport_generic_cmd_sequencer()
3504 size = cmd->data_length; in transport_generic_cmd_sequencer()
3506 cmd->transport_emulate_cdb = in transport_generic_cmd_sequencer()
3510 cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; in transport_generic_cmd_sequencer()
3518 sectors = transport_get_sectors_10(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3519 T_TASK(cmd)->t_task_lba = transport_lba_32(cdb); in transport_generic_cmd_sequencer()
3521 sectors = transport_get_sectors_16(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3522 T_TASK(cmd)->t_task_lba = transport_lba_64(cdb); in transport_generic_cmd_sequencer()
3527 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3528 cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; in transport_generic_cmd_sequencer()
3539 cmd->se_cmd_flags |= SCF_EMULATE_CDB_ASYNC; in transport_generic_cmd_sequencer()
3544 if (transport_get_sectors(cmd) < 0) in transport_generic_cmd_sequencer()
3559 cmd->se_cmd_flags |= SCF_EMULATE_SYNC_UNMAP; in transport_generic_cmd_sequencer()
3561 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3564 sectors = transport_get_sectors_16(cdb, cmd, &sector_ret); in transport_generic_cmd_sequencer()
3567 size = transport_get_size(sectors, cdb, cmd); in transport_generic_cmd_sequencer()
3568 T_TASK(cmd)->t_task_lba = get_unaligned_be16(&cdb[2]); in transport_generic_cmd_sequencer()
3595 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; in transport_generic_cmd_sequencer()
3611 cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; in transport_generic_cmd_sequencer()
3614 cmd->transport_emulate_cdb = in transport_generic_cmd_sequencer()
3621 if (SE_DEV(cmd)->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) in transport_generic_cmd_sequencer()
3622 cmd->sam_task_attr = TASK_ATTR_HOQ; in transport_generic_cmd_sequencer()
3623 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; in transport_generic_cmd_sequencer()
3628 CMD_TFO(cmd)->get_fabric_name(), cdb[0]); in transport_generic_cmd_sequencer()
3629 cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks; in transport_generic_cmd_sequencer()
3633 if (size != cmd->data_length) { in transport_generic_cmd_sequencer()
3636 " 0x%02x\n", CMD_TFO(cmd)->get_fabric_name(), in transport_generic_cmd_sequencer()
3637 cmd->data_length, size, cdb[0]); in transport_generic_cmd_sequencer()
3639 cmd->cmd_spdtl = size; in transport_generic_cmd_sequencer()
3641 if (cmd->data_direction == DMA_TO_DEVICE) { in transport_generic_cmd_sequencer()
3658 if (size > cmd->data_length) { in transport_generic_cmd_sequencer()
3659 cmd->se_cmd_flags |= SCF_OVERFLOW_BIT; in transport_generic_cmd_sequencer()
3660 cmd->residual_count = (size - cmd->data_length); in transport_generic_cmd_sequencer()
3662 cmd->se_cmd_flags |= SCF_UNDERFLOW_BIT; in transport_generic_cmd_sequencer()
3663 cmd->residual_count = (cmd->data_length - size); in transport_generic_cmd_sequencer()
3665 cmd->data_length = size; in transport_generic_cmd_sequencer()
3668 transport_set_supported_SAM_opcode(cmd); in transport_generic_cmd_sequencer()
3672 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_generic_cmd_sequencer()
3673 cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; in transport_generic_cmd_sequencer()
3676 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_generic_cmd_sequencer()
3677 cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; in transport_generic_cmd_sequencer()
3688 struct se_cmd *cmd, in transport_memcpy_write_contig() argument
3692 u32 i = 0, length = 0, total_length = cmd->data_length; in transport_memcpy_write_contig()
3718 struct se_cmd *cmd, in transport_memcpy_read_contig() argument
3722 u32 i = 0, length = 0, total_length = cmd->data_length; in transport_memcpy_read_contig()
3744 struct se_cmd *cmd, in transport_memcpy_se_mem_read_contig() argument
3750 u32 length = 0, total_length = cmd->data_length; in transport_memcpy_se_mem_read_contig()
3774 static void transport_complete_task_attr(struct se_cmd *cmd) in transport_complete_task_attr() argument
3776 struct se_device *dev = SE_DEV(cmd); in transport_complete_task_attr()
3780 if (cmd->sam_task_attr == TASK_ATTR_SIMPLE) { in transport_complete_task_attr()
3786 cmd->se_ordered_id); in transport_complete_task_attr()
3787 } else if (cmd->sam_task_attr == TASK_ATTR_HOQ) { in transport_complete_task_attr()
3793 cmd->se_ordered_id); in transport_complete_task_attr()
3794 } else if (cmd->sam_task_attr == TASK_ATTR_ORDERED) { in transport_complete_task_attr()
3796 list_del(&cmd->se_ordered_list); in transport_complete_task_attr()
3803 " %u\n", dev->dev_cur_ordered_id, cmd->se_ordered_id); in transport_complete_task_attr()
3839 static void transport_generic_complete_ok(struct se_cmd *cmd) in transport_generic_complete_ok() argument
3847 if (SE_DEV(cmd)->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) in transport_generic_complete_ok()
3848 transport_complete_task_attr(cmd); in transport_generic_complete_ok()
3853 if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { in transport_generic_complete_ok()
3854 if (transport_get_sense_data(cmd) < 0) in transport_generic_complete_ok()
3861 if (cmd->scsi_status) { in transport_generic_complete_ok()
3863 cmd, reason, 1); in transport_generic_complete_ok()
3864 transport_lun_remove_cmd(cmd); in transport_generic_complete_ok()
3865 transport_cmd_check_stop_to_fabric(cmd); in transport_generic_complete_ok()
3873 if (cmd->transport_complete_callback) in transport_generic_complete_ok()
3874 cmd->transport_complete_callback(cmd); in transport_generic_complete_ok()
3876 switch (cmd->data_direction) { in transport_generic_complete_ok()
3878 spin_lock(&cmd->se_lun->lun_sep_lock); in transport_generic_complete_ok()
3879 if (SE_LUN(cmd)->lun_sep) { in transport_generic_complete_ok()
3880 SE_LUN(cmd)->lun_sep->sep_stats.tx_data_octets += in transport_generic_complete_ok()
3881 cmd->data_length; in transport_generic_complete_ok()
3883 spin_unlock(&cmd->se_lun->lun_sep_lock); in transport_generic_complete_ok()
3889 if (cmd->se_cmd_flags & SCF_PASSTHROUGH_CONTIG_TO_SG) in transport_generic_complete_ok()
3890 transport_memcpy_write_contig(cmd, in transport_generic_complete_ok()
3891 T_TASK(cmd)->t_task_pt_sgl, in transport_generic_complete_ok()
3892 T_TASK(cmd)->t_task_buf); in transport_generic_complete_ok()
3894 CMD_TFO(cmd)->queue_data_in(cmd); in transport_generic_complete_ok()
3897 spin_lock(&cmd->se_lun->lun_sep_lock); in transport_generic_complete_ok()
3898 if (SE_LUN(cmd)->lun_sep) { in transport_generic_complete_ok()
3899 SE_LUN(cmd)->lun_sep->sep_stats.rx_data_octets += in transport_generic_complete_ok()
3900 cmd->data_length; in transport_generic_complete_ok()
3902 spin_unlock(&cmd->se_lun->lun_sep_lock); in transport_generic_complete_ok()
3906 if (T_TASK(cmd)->t_mem_bidi_list != NULL) { in transport_generic_complete_ok()
3907 spin_lock(&cmd->se_lun->lun_sep_lock); in transport_generic_complete_ok()
3908 if (SE_LUN(cmd)->lun_sep) { in transport_generic_complete_ok()
3909 SE_LUN(cmd)->lun_sep->sep_stats.tx_data_octets += in transport_generic_complete_ok()
3910 cmd->data_length; in transport_generic_complete_ok()
3912 spin_unlock(&cmd->se_lun->lun_sep_lock); in transport_generic_complete_ok()
3913 CMD_TFO(cmd)->queue_data_in(cmd); in transport_generic_complete_ok()
3918 CMD_TFO(cmd)->queue_status(cmd); in transport_generic_complete_ok()
3924 transport_lun_remove_cmd(cmd); in transport_generic_complete_ok()
3925 transport_cmd_check_stop_to_fabric(cmd); in transport_generic_complete_ok()
3928 static void transport_free_dev_tasks(struct se_cmd *cmd) in transport_free_dev_tasks() argument
3933 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_free_dev_tasks()
3935 &T_TASK(cmd)->t_task_list, t_list) { in transport_free_dev_tasks()
3944 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_free_dev_tasks()
3950 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_free_dev_tasks()
3952 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_free_dev_tasks()
3955 static inline void transport_free_pages(struct se_cmd *cmd) in transport_free_pages() argument
3960 if (cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC) in transport_free_pages()
3962 if (cmd->se_dev->transport->do_se_mem_map) in transport_free_pages()
3965 if (T_TASK(cmd)->t_task_buf) { in transport_free_pages()
3966 kfree(T_TASK(cmd)->t_task_buf); in transport_free_pages()
3967 T_TASK(cmd)->t_task_buf = NULL; in transport_free_pages()
3974 if (cmd->se_cmd_flags & SCF_CMD_PASSTHROUGH_NOALLOC) in transport_free_pages()
3977 if (!(T_TASK(cmd)->t_tasks_se_num)) in transport_free_pages()
3981 T_TASK(cmd)->t_mem_list, se_list) { in transport_free_pages()
3993 if (T_TASK(cmd)->t_mem_bidi_list && T_TASK(cmd)->t_tasks_se_bidi_num) { in transport_free_pages()
3995 T_TASK(cmd)->t_mem_bidi_list, se_list) { in transport_free_pages()
4008 kfree(T_TASK(cmd)->t_mem_bidi_list); in transport_free_pages()
4009 T_TASK(cmd)->t_mem_bidi_list = NULL; in transport_free_pages()
4010 kfree(T_TASK(cmd)->t_mem_list); in transport_free_pages()
4011 T_TASK(cmd)->t_mem_list = NULL; in transport_free_pages()
4012 T_TASK(cmd)->t_tasks_se_num = 0; in transport_free_pages()
4015 static inline void transport_release_tasks(struct se_cmd *cmd) in transport_release_tasks() argument
4017 transport_free_dev_tasks(cmd); in transport_release_tasks()
4020 static inline int transport_dec_and_check(struct se_cmd *cmd) in transport_dec_and_check() argument
4024 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_dec_and_check()
4025 if (atomic_read(&T_TASK(cmd)->t_fe_count)) { in transport_dec_and_check()
4026 if (!(atomic_dec_and_test(&T_TASK(cmd)->t_fe_count))) { in transport_dec_and_check()
4027 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, in transport_dec_and_check()
4033 if (atomic_read(&T_TASK(cmd)->t_se_count)) { in transport_dec_and_check()
4034 if (!(atomic_dec_and_test(&T_TASK(cmd)->t_se_count))) { in transport_dec_and_check()
4035 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, in transport_dec_and_check()
4040 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_dec_and_check()
4045 static void transport_release_fe_cmd(struct se_cmd *cmd) in transport_release_fe_cmd() argument
4049 if (transport_dec_and_check(cmd)) in transport_release_fe_cmd()
4052 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_release_fe_cmd()
4053 if (!(atomic_read(&T_TASK(cmd)->transport_dev_active))) { in transport_release_fe_cmd()
4054 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_release_fe_cmd()
4057 atomic_set(&T_TASK(cmd)->transport_dev_active, 0); in transport_release_fe_cmd()
4058 transport_all_task_dev_remove_state(cmd); in transport_release_fe_cmd()
4059 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_release_fe_cmd()
4061 transport_release_tasks(cmd); in transport_release_fe_cmd()
4063 transport_free_pages(cmd); in transport_release_fe_cmd()
4064 transport_free_se_cmd(cmd); in transport_release_fe_cmd()
4065 CMD_TFO(cmd)->release_cmd_direct(cmd); in transport_release_fe_cmd()
4069 struct se_cmd *cmd, in transport_generic_remove() argument
4075 if (!(T_TASK(cmd))) in transport_generic_remove()
4078 if (transport_dec_and_check(cmd)) { in transport_generic_remove()
4080 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_remove()
4081 transport_all_task_dev_remove_state(cmd); in transport_generic_remove()
4082 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, in transport_generic_remove()
4088 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_remove()
4089 if (!(atomic_read(&T_TASK(cmd)->transport_dev_active))) { in transport_generic_remove()
4090 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_remove()
4093 atomic_set(&T_TASK(cmd)->transport_dev_active, 0); in transport_generic_remove()
4094 transport_all_task_dev_remove_state(cmd); in transport_generic_remove()
4095 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); in transport_generic_remove()
4097 transport_release_tasks(cmd); in transport_generic_remove()
4099 transport_free_pages(cmd); in transport_generic_remove()
4103 transport_release_cmd_to_pool(cmd); in transport_generic_remove()
4105 transport_free_se_cmd(cmd); in transport_generic_remove()
4106 CMD_TFO(cmd)->release_cmd_direct(cmd); in transport_generic_remove()
4124 struct se_cmd *cmd, in transport_generic_map_mem_to_cmd() argument
4139 if (!(cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM)) { in transport_generic_map_mem_to_cmd()
4146 T_TASK(cmd)->t_mem_list = (struct list_head *)mem; in transport_generic_map_mem_to_cmd()
4147 T_TASK(cmd)->t_tasks_se_num = sg_mem_num; in transport_generic_map_mem_to_cmd()
4148 cmd->se_cmd_flags |= SCF_CMD_PASSTHROUGH_NOALLOC; in transport_generic_map_mem_to_cmd()
4155 if ((cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) || in transport_generic_map_mem_to_cmd()
4156 (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB)) { in transport_generic_map_mem_to_cmd()
4162 T_TASK(cmd)->t_mem_list = transport_init_se_mem_list(); in transport_generic_map_mem_to_cmd()
4163 if (!(T_TASK(cmd)->t_mem_list)) in transport_generic_map_mem_to_cmd()
4166 ret = transport_map_sg_to_mem(cmd, in transport_generic_map_mem_to_cmd()
4167 T_TASK(cmd)->t_mem_list, mem, &se_mem_cnt_out); in transport_generic_map_mem_to_cmd()
4171 T_TASK(cmd)->t_tasks_se_num = se_mem_cnt_out; in transport_generic_map_mem_to_cmd()
4176 T_TASK(cmd)->t_mem_bidi_list = transport_init_se_mem_list(); in transport_generic_map_mem_to_cmd()
4177 if (!(T_TASK(cmd)->t_mem_bidi_list)) { in transport_generic_map_mem_to_cmd()
4178 kfree(T_TASK(cmd)->t_mem_list); in transport_generic_map_mem_to_cmd()
4183 ret = transport_map_sg_to_mem(cmd, in transport_generic_map_mem_to_cmd()
4184 T_TASK(cmd)->t_mem_bidi_list, mem_bidi_in, in transport_generic_map_mem_to_cmd()
4187 kfree(T_TASK(cmd)->t_mem_list); in transport_generic_map_mem_to_cmd()
4191 T_TASK(cmd)->t_tasks_se_bidi_num = se_mem_cnt_out; in transport_generic_map_mem_to_cmd()
4193 cmd->se_cmd_flags |= SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC; in transport_generic_map_mem_to_cmd()
4195 } else if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB) { in transport_generic_map_mem_to_cmd()
4210 cmd->se_cmd_flags |= SCF_PASSTHROUGH_CONTIG_TO_SG; in transport_generic_map_mem_to_cmd()
4211 T_TASK(cmd)->t_task_pt_sgl = mem; in transport_generic_map_mem_to_cmd()
4224 static int transport_get_sectors(struct se_cmd *cmd) in transport_get_sectors() argument
4226 struct se_device *dev = SE_DEV(cmd); in transport_get_sectors()
4228 T_TASK(cmd)->t_tasks_sectors = in transport_get_sectors()
4229 (cmd->data_length / DEV_ATTRIB(dev)->block_size); in transport_get_sectors()
4230 if (!(T_TASK(cmd)->t_tasks_sectors)) in transport_get_sectors()
4231 T_TASK(cmd)->t_tasks_sectors = 1; in transport_get_sectors()
4236 if ((T_TASK(cmd)->t_task_lba + T_TASK(cmd)->t_tasks_sectors) > in transport_get_sectors()
4240 T_TASK(cmd)->t_task_lba, T_TASK(cmd)->t_tasks_sectors, in transport_get_sectors()
4242 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_get_sectors()
4243 cmd->scsi_sense_reason = TCM_SECTOR_COUNT_TOO_MANY; in transport_get_sectors()
4250 static int transport_new_cmd_obj(struct se_cmd *cmd) in transport_new_cmd_obj() argument
4252 struct se_device *dev = SE_DEV(cmd); in transport_new_cmd_obj()
4255 if (!(cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)) { in transport_new_cmd_obj()
4257 T_TASK(cmd)->t_task_cdbs++; in transport_new_cmd_obj()
4266 if ((T_TASK(cmd)->t_mem_bidi_list != NULL) && in transport_new_cmd_obj()
4268 rc = transport_generic_get_cdb_count(cmd, in transport_new_cmd_obj()
4269 T_TASK(cmd)->t_task_lba, in transport_new_cmd_obj()
4270 T_TASK(cmd)->t_tasks_sectors, in transport_new_cmd_obj()
4271 DMA_FROM_DEVICE, T_TASK(cmd)->t_mem_bidi_list, in transport_new_cmd_obj()
4274 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_new_cmd_obj()
4275 cmd->scsi_sense_reason = in transport_new_cmd_obj()
4285 task_cdbs = transport_generic_get_cdb_count(cmd, in transport_new_cmd_obj()
4286 T_TASK(cmd)->t_task_lba, in transport_new_cmd_obj()
4287 T_TASK(cmd)->t_tasks_sectors, in transport_new_cmd_obj()
4288 cmd->data_direction, T_TASK(cmd)->t_mem_list, in transport_new_cmd_obj()
4291 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; in transport_new_cmd_obj()
4292 cmd->scsi_sense_reason = in transport_new_cmd_obj()
4296 T_TASK(cmd)->t_task_cdbs += task_cdbs; in transport_new_cmd_obj()
4300 " %u, t_task_cdbs: %u\n", obj_ptr, cmd->data_length, in transport_new_cmd_obj()
4301 T_TASK(cmd)->t_task_lba, T_TASK(cmd)->t_tasks_sectors, in transport_new_cmd_obj()
4302 T_TASK(cmd)->t_task_cdbs); in transport_new_cmd_obj()
4306 atomic_set(&T_TASK(cmd)->t_task_cdbs_left, task_cdbs); in transport_new_cmd_obj()
4307 atomic_set(&T_TASK(cmd)->t_task_cdbs_ex_left, task_cdbs); in transport_new_cmd_obj()
4308 atomic_set(&T_TASK(cmd)->t_task_cdbs_timeout_left, task_cdbs); in transport_new_cmd_obj()
4327 transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size) in transport_generic_get_mem() argument
4332 T_TASK(cmd)->t_mem_list = transport_init_se_mem_list(); in transport_generic_get_mem()
4333 if (!(T_TASK(cmd)->t_mem_list)) in transport_generic_get_mem()
4339 if (cmd->se_dev->transport->do_se_mem_map) in transport_generic_get_mem()
4345 if (T_TASK(cmd)->t_tasks_bidi) { in transport_generic_get_mem()
4346 T_TASK(cmd)->t_mem_bidi_list = transport_init_se_mem_list(); in transport_generic_get_mem()
4347 if (!(T_TASK(cmd)->t_mem_bidi_list)) { in transport_generic_get_mem()
4348 kfree(T_TASK(cmd)->t_mem_list); in transport_generic_get_mem()
4377 list_add_tail(&se_mem->se_list, T_TASK(cmd)->t_mem_list); in transport_generic_get_mem()
4378 T_TASK(cmd)->t_tasks_se_num++; in transport_generic_get_mem()
4388 T_TASK(cmd)->t_tasks_se_num); in transport_generic_get_mem()
4571 struct se_cmd *cmd, in transport_map_sg_to_mem() argument
4578 u32 sg_count = 1, cmd_size = cmd->data_length; in transport_map_sg_to_mem()
4739 void transport_do_task_sg_chain(struct se_cmd *cmd) in transport_do_task_sg_chain() argument
4745 struct target_core_fabric_ops *tfo = CMD_TFO(cmd); in transport_do_task_sg_chain()
4759 list_for_each_entry(task, &T_TASK(cmd)->t_task_list, t_list) { in transport_do_task_sg_chain()
4770 &T_TASK(cmd)->t_task_list))) { in transport_do_task_sg_chain()
4794 if (!(list_is_last(&task->t_list, &T_TASK(cmd)->t_task_list))) { in transport_do_task_sg_chain()
4809 T_TASK(cmd)->t_tasks_sg_chained = sg_first; in transport_do_task_sg_chain()
4810 T_TASK(cmd)->t_tasks_sg_chained_no = sg_count; in transport_do_task_sg_chain()
4813 " t_tasks_sg_chained_no: %u\n", T_TASK(cmd)->t_tasks_sg_chained, in transport_do_task_sg_chain()
4814 T_TASK(cmd)->t_tasks_sg_chained_no); in transport_do_task_sg_chain()
4816 for_each_sg(T_TASK(cmd)->t_tasks_sg_chained, sg, in transport_do_task_sg_chain()
4817 T_TASK(cmd)->t_tasks_sg_chained_no, i) { in transport_do_task_sg_chain()
4889 struct se_cmd *cmd, in transport_generic_get_cdb_count() argument
4900 struct se_device *dev = SE_DEV(cmd); in transport_generic_get_cdb_count()
4919 if ((T_TASK(cmd)->t_mem_bidi_list != NULL) && in transport_generic_get_cdb_count()
4920 !(list_empty(T_TASK(cmd)->t_mem_bidi_list)) && in transport_generic_get_cdb_count()
4922 se_mem_bidi = list_entry(T_TASK(cmd)->t_mem_bidi_list->next, in transport_generic_get_cdb_count()
4927 CMD_TFO(cmd)->get_task_tag(cmd), lba, sectors, in transport_generic_get_cdb_count()
4930 task = transport_generic_get_task(cmd, data_direction); in transport_generic_get_cdb_count()
4945 memcpy(cdb, T_TASK(cmd)->t_task_cdb, in transport_generic_get_cdb_count()
4946 scsi_command_size(T_TASK(cmd)->t_task_cdb)); in transport_generic_get_cdb_count()
4947 cmd->transport_split_cdb(task->task_lba, in transport_generic_get_cdb_count()
4974 T_TASK(cmd)->t_mem_bidi_list, NULL, in transport_generic_get_cdb_count()
4997 atomic_inc(&T_TASK(cmd)->t_fe_count); in transport_generic_get_cdb_count()
4998 atomic_inc(&T_TASK(cmd)->t_se_count); in transport_generic_get_cdb_count()
5002 CMD_TFO(cmd)->get_task_tag(cmd), (data_direction == DMA_TO_DEVICE) in transport_generic_get_cdb_count()
5011 transport_map_control_cmd_to_task(struct se_cmd *cmd) in transport_map_control_cmd_to_task() argument
5013 struct se_device *dev = SE_DEV(cmd); in transport_map_control_cmd_to_task()
5018 task = transport_generic_get_task(cmd, cmd->data_direction); in transport_map_control_cmd_to_task()
5024 memcpy(cdb, cmd->t_task->t_task_cdb, in transport_map_control_cmd_to_task()
5025 scsi_command_size(cmd->t_task->t_task_cdb)); in transport_map_control_cmd_to_task()
5027 task->task_size = cmd->data_length; in transport_map_control_cmd_to_task()
5029 (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) ? 1 : 0; in transport_map_control_cmd_to_task()
5031 atomic_inc(&cmd->t_task->t_fe_count); in transport_map_control_cmd_to_task()
5032 atomic_inc(&cmd->t_task->t_se_count); in transport_map_control_cmd_to_task()
5034 if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) { in transport_map_control_cmd_to_task()
5038 if (!list_empty(T_TASK(cmd)->t_mem_list)) in transport_map_control_cmd_to_task()
5039 se_mem = list_entry(T_TASK(cmd)->t_mem_list->next, in transport_map_control_cmd_to_task()
5043 cmd->t_task->t_mem_list, NULL, se_mem, in transport_map_control_cmd_to_task()
5051 } else if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB) { in transport_map_control_cmd_to_task()
5055 } else if (cmd->se_cmd_flags & SCF_SCSI_NON_DATA_CDB) { in transport_map_control_cmd_to_task()
5074 static int transport_generic_new_cmd(struct se_cmd *cmd) in transport_generic_new_cmd() argument
5078 struct se_device *dev = SE_DEV(cmd); in transport_generic_new_cmd()
5087 if (!(cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC)) { in transport_generic_new_cmd()
5088 ret = transport_allocate_resources(cmd); in transport_generic_new_cmd()
5093 ret = transport_get_sectors(cmd); in transport_generic_new_cmd()
5097 ret = transport_new_cmd_obj(cmd); in transport_generic_new_cmd()
5106 se_tpg = SE_LUN(cmd)->lun_sep->sep_tpg; in transport_generic_new_cmd()
5108 ret = TPG_TFO(se_tpg)->alloc_cmd_iovecs(cmd); in transport_generic_new_cmd()
5113 if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) { in transport_generic_new_cmd()
5114 list_for_each_entry(task, &T_TASK(cmd)->t_task_list, t_list) { in transport_generic_new_cmd()
5125 ret = transport_map_control_cmd_to_task(cmd); in transport_generic_new_cmd()
5137 if (cmd->data_direction == DMA_TO_DEVICE) { in transport_generic_new_cmd()
5138 transport_add_tasks_to_state_queue(cmd); in transport_generic_new_cmd()
5139 return transport_generic_write_pending(cmd); in transport_generic_new_cmd()
5145 transport_execute_tasks(cmd); in transport_generic_new_cmd()
5153 void transport_generic_process_write(struct se_cmd *cmd) argument
5160 if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
5161 if (!T_TASK(cmd)->t_tasks_se_num) {
5163 (unsigned char *)T_TASK(cmd)->t_task_buf;
5165 dst = kzalloc(cmd->cmd_spdtl), GFP_KERNEL);
5169 transport_generic_request_failure(cmd, NULL,
5173 memcpy(dst, buf, cmd->cmd_spdtl);
5175 kfree(T_TASK(cmd)->t_task_buf);
5176 T_TASK(cmd)->t_task_buf = dst;
5179 (struct scatterlist *sg)T_TASK(cmd)->t_task_buf;
5183 T_TASK(cmd)->t_tasks_se_num,
5188 transport_generic_request_failure(cmd, NULL,
5193 memcpy(orig_sg, T_TASK(cmd)->t_task_buf,
5195 T_TASK(cmd)->t_tasks_se_num);
5197 cmd->data_length = cmd->cmd_spdtl;
5202 if (transport_generic_new_cmd(cmd) < 0) {
5203 transport_generic_request_failure(cmd, NULL,
5209 transport_memcpy_write_sg(cmd, orig_sg);
5213 transport_execute_tasks(cmd);
5221 static int transport_generic_write_pending(struct se_cmd *cmd) argument
5226 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5227 cmd->t_state = TRANSPORT_WRITE_PENDING;
5228 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5235 if (cmd->se_cmd_flags & SCF_PASSTHROUGH_CONTIG_TO_SG)
5236 transport_memcpy_read_contig(cmd,
5237 T_TASK(cmd)->t_task_buf,
5238 T_TASK(cmd)->t_task_pt_sgl);
5246 transport_cmd_check_stop(cmd, 1, 0);
5252 ret = CMD_TFO(cmd)->write_pending(cmd);
5263 void transport_release_cmd_to_pool(struct se_cmd *cmd) argument
5265 BUG_ON(!T_TASK(cmd));
5266 BUG_ON(!CMD_TFO(cmd));
5268 transport_free_se_cmd(cmd);
5269 CMD_TFO(cmd)->release_cmd_to_pool(cmd);
5278 struct se_cmd *cmd, argument
5283 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) || !T_TASK(cmd))
5284 transport_release_cmd_to_pool(cmd);
5286 core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd);
5288 if (SE_LUN(cmd)) {
5291 " SE_LUN(cmd)\n", cmd,
5292 CMD_TFO(cmd)->get_task_tag(cmd));
5294 transport_lun_remove_cmd(cmd);
5297 if (wait_for_tasks && cmd->transport_wait_for_tasks)
5298 cmd->transport_wait_for_tasks(cmd, 0, 0);
5300 transport_generic_remove(cmd, release_to_pool,
5307 struct se_cmd *cmd, argument
5319 static int transport_lun_wait_for_tasks(struct se_cmd *cmd, struct se_lun *lun) argument
5327 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5328 if (atomic_read(&T_TASK(cmd)->t_transport_stop)) {
5329 atomic_set(&T_TASK(cmd)->transport_lun_stop, 0);
5331 " TRUE, skipping\n", CMD_TFO(cmd)->get_task_tag(cmd));
5332 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5333 transport_cmd_check_stop(cmd, 1, 0);
5336 atomic_set(&T_TASK(cmd)->transport_lun_fe_stop, 1);
5337 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5339 wake_up_interruptible(&SE_DEV(cmd)->dev_queue_obj->thread_wq);
5341 ret = transport_stop_tasks_for_cmd(cmd);
5344 " %d\n", cmd, T_TASK(cmd)->t_task_cdbs, ret);
5347 CMD_TFO(cmd)->get_task_tag(cmd));
5348 wait_for_completion(&T_TASK(cmd)->transport_lun_stop_comp);
5350 CMD_TFO(cmd)->get_task_tag(cmd));
5352 transport_remove_cmd_from_queue(cmd, SE_DEV(cmd)->dev_queue_obj);
5366 struct se_cmd *cmd = NULL; local
5374 cmd = list_entry(lun->lun_cmd_list.next,
5376 list_del(&cmd->se_lun_list);
5378 if (!(T_TASK(cmd))) {
5381 CMD_TFO(cmd)->get_task_tag(cmd),
5382 CMD_TFO(cmd)->get_cmd_state(cmd), cmd->t_state);
5385 atomic_set(&T_TASK(cmd)->transport_lun_active, 0);
5391 spin_lock(&T_TASK(cmd)->t_state_lock);
5394 SE_LUN(cmd)->unpacked_lun,
5395 CMD_TFO(cmd)->get_task_tag(cmd));
5396 atomic_set(&T_TASK(cmd)->transport_lun_stop, 1);
5397 spin_unlock(&T_TASK(cmd)->t_state_lock);
5401 if (!(SE_LUN(cmd))) {
5403 CMD_TFO(cmd)->get_task_tag(cmd),
5404 CMD_TFO(cmd)->get_cmd_state(cmd), cmd->t_state);
5412 "_lun_wait_for_tasks()\n", SE_LUN(cmd)->unpacked_lun,
5413 CMD_TFO(cmd)->get_task_tag(cmd));
5415 if (transport_lun_wait_for_tasks(cmd, SE_LUN(cmd)) < 0) {
5422 SE_LUN(cmd)->unpacked_lun,
5423 CMD_TFO(cmd)->get_task_tag(cmd));
5425 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, cmd_flags);
5426 if (!(atomic_read(&T_TASK(cmd)->transport_dev_active))) {
5427 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, cmd_flags);
5430 atomic_set(&T_TASK(cmd)->transport_dev_active, 0);
5431 transport_all_task_dev_remove_state(cmd);
5432 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, cmd_flags);
5434 transport_free_dev_tasks(cmd);
5442 transport_send_check_condition_and_sense(cmd,
5449 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, cmd_flags);
5450 if (atomic_read(&T_TASK(cmd)->transport_lun_fe_stop)) {
5454 cmd, CMD_TFO(cmd)->get_task_tag(cmd));
5456 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock,
5458 transport_cmd_check_stop(cmd, 1, 0);
5459 complete(&T_TASK(cmd)->transport_lun_fe_stop_comp);
5464 lun->unpacked_lun, CMD_TFO(cmd)->get_task_tag(cmd));
5466 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, cmd_flags);
5503 struct se_cmd *cmd, argument
5509 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_tmr_req))
5512 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5520 if (atomic_read(&T_TASK(cmd)->transport_lun_stop)) {
5525 CMD_TFO(cmd)->get_task_tag(cmd));
5533 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5534 complete(&T_TASK(cmd)->transport_lun_stop_comp);
5535 wait_for_completion(&T_TASK(cmd)->transport_lun_fe_stop_comp);
5536 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5538 transport_all_task_dev_remove_state(cmd);
5547 CMD_TFO(cmd)->get_task_tag(cmd));
5549 atomic_set(&T_TASK(cmd)->transport_lun_stop, 0);
5551 if (!atomic_read(&T_TASK(cmd)->t_transport_active) ||
5552 atomic_read(&T_TASK(cmd)->t_transport_aborted))
5555 atomic_set(&T_TASK(cmd)->t_transport_stop, 1);
5559 " = TRUE\n", cmd, CMD_TFO(cmd)->get_task_tag(cmd),
5560 CMD_TFO(cmd)->get_cmd_state(cmd), cmd->t_state,
5561 cmd->deferred_t_state);
5563 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5565 wake_up_interruptible(&SE_DEV(cmd)->dev_queue_obj->thread_wq);
5567 wait_for_completion(&T_TASK(cmd)->t_transport_stop_comp);
5569 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5570 atomic_set(&T_TASK(cmd)->t_transport_active, 0);
5571 atomic_set(&T_TASK(cmd)->t_transport_stop, 0);
5575 CMD_TFO(cmd)->get_task_tag(cmd));
5577 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5581 transport_generic_free_cmd(cmd, 0, 0, session_reinstatement);
5585 struct se_cmd *cmd, argument
5589 *asc = cmd->scsi_asc;
5590 *ascq = cmd->scsi_ascq;
5596 struct se_cmd *cmd, argument
5600 cmd->scsi_asc = asc;
5601 cmd->scsi_ascq = ascq;
5607 struct se_cmd *cmd, argument
5611 unsigned char *buffer = cmd->sense_buffer;
5616 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5617 if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) {
5618 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5621 cmd->se_cmd_flags |= SCF_SENT_CHECK_CONDITION;
5622 spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags);
5628 cmd->se_cmd_flags |= SCF_EMULATED_TASK_SENSE;
5635 offset = CMD_TFO(cmd)->set_fabric_sense_len(cmd,
5738 core_scsi3_ua_for_check_condition(cmd, &asc, &ascq);
5747 transport_get_sense_codes(cmd, &asc, &ascq);
5764 cmd->scsi_status = SAM_STAT_CHECK_CONDITION;
5769 cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER + offset;
5772 CMD_TFO(cmd)->queue_status(cmd);
5777 int transport_check_aborted_status(struct se_cmd *cmd, int send_status) argument
5781 if (atomic_read(&T_TASK(cmd)->t_transport_aborted) != 0) {
5783 (cmd->se_cmd_flags & SCF_SENT_DELAYED_TAS))
5788 T_TASK(cmd)->t_task_cdb[0],
5789 CMD_TFO(cmd)->get_task_tag(cmd));
5791 cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS;
5792 CMD_TFO(cmd)->queue_status(cmd);
5799 void transport_send_task_abort(struct se_cmd *cmd) argument
5807 if (cmd->data_direction == DMA_TO_DEVICE) {
5808 if (CMD_TFO(cmd)->write_pending_status(cmd) != 0) {
5809 atomic_inc(&T_TASK(cmd)->t_transport_aborted);
5811 cmd->scsi_status = SAM_STAT_TASK_ABORTED;
5812 transport_new_cmd_failure(cmd);
5816 cmd->scsi_status = SAM_STAT_TASK_ABORTED;
5819 " ITT: 0x%08x\n", T_TASK(cmd)->t_task_cdb[0],
5820 CMD_TFO(cmd)->get_task_tag(cmd));
5822 CMD_TFO(cmd)->queue_status(cmd);
5829 int transport_generic_do_tmr(struct se_cmd *cmd) argument
5832 struct se_device *dev = SE_DEV(cmd);
5833 struct se_tmr_req *tmr = cmd->se_tmr_req;
5864 cmd->t_state = TRANSPORT_ISTATE_PROCESSING;
5865 CMD_TFO(cmd)->queue_tm_rsp(cmd);
5867 transport_cmd_check_stop(cmd, 2, 0);
5894 struct se_cmd *cmd; local
5908 cmd = TASK_CMD(task);
5910 if (!T_TASK(cmd)) {
5912 " %p ITT: 0x%08x\n", task, cmd,
5913 CMD_TFO(cmd)->get_task_tag(cmd));
5918 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5922 " %d/%d cdb: 0x%02x\n", cmd, task,
5923 CMD_TFO(cmd)->get_task_tag(cmd), cmd->cmd_sn,
5924 CMD_TFO(cmd)->get_cmd_state(cmd), cmd->deferred_i_state,
5925 cmd->t_state, cmd->deferred_t_state,
5926 T_TASK(cmd)->t_task_cdb[0]);
5930 CMD_TFO(cmd)->get_task_tag(cmd),
5931 T_TASK(cmd)->t_task_cdbs,
5932 atomic_read(&T_TASK(cmd)->t_task_cdbs_left),
5933 atomic_read(&T_TASK(cmd)->t_task_cdbs_sent),
5934 atomic_read(&T_TASK(cmd)->t_transport_active),
5935 atomic_read(&T_TASK(cmd)->t_transport_stop),
5936 atomic_read(&T_TASK(cmd)->t_transport_sent));
5941 &T_TASK(cmd)->t_state_lock, flags);
5949 spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags);
5950 atomic_dec(&T_TASK(cmd)->t_task_cdbs_left);
5960 if (!(atomic_dec_and_test(&T_TASK(cmd)->t_task_cdbs_ex_left))) {
5962 &T_TASK(cmd)->t_state_lock, flags);
5966 atomic_read(&T_TASK(cmd)->t_task_cdbs_ex_left));
5972 if (atomic_read(&T_TASK(cmd)->t_transport_active)) {
5976 if (atomic_read(&T_TASK(cmd)->t_fe_count)) {
5978 &T_TASK(cmd)->t_state_lock, flags);
5980 cmd, TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE,
5982 transport_remove_cmd_from_queue(cmd,
5983 SE_DEV(cmd)->dev_queue_obj);
5985 transport_lun_remove_cmd(cmd);
5986 transport_cmd_check_stop(cmd, 1, 0);
5989 &T_TASK(cmd)->t_state_lock, flags);
5991 transport_remove_cmd_from_queue(cmd,
5992 SE_DEV(cmd)->dev_queue_obj);
5994 transport_lun_remove_cmd(cmd);
5996 if (transport_cmd_check_stop(cmd, 1, 0))
5997 transport_generic_remove(cmd, 0, 0);
6006 if (atomic_read(&T_TASK(cmd)->t_fe_count)) {
6008 &T_TASK(cmd)->t_state_lock, flags);
6009 transport_send_check_condition_and_sense(cmd,
6011 transport_remove_cmd_from_queue(cmd,
6012 SE_DEV(cmd)->dev_queue_obj);
6014 transport_lun_remove_cmd(cmd);
6015 transport_cmd_check_stop(cmd, 1, 0);
6018 &T_TASK(cmd)->t_state_lock, flags);
6020 transport_remove_cmd_from_queue(cmd,
6021 SE_DEV(cmd)->dev_queue_obj);
6022 transport_lun_remove_cmd(cmd);
6024 if (transport_cmd_check_stop(cmd, 1, 0))
6025 transport_generic_remove(cmd, 0, 0);
6038 cmd = (struct se_cmd *)qr->cmd;
6043 cmd, state);
6045 if (atomic_read(&T_TASK(cmd)->t_fe_count)) {
6046 transport_send_check_condition_and_sense(cmd,
6049 transport_lun_remove_cmd(cmd);
6050 transport_cmd_check_stop(cmd, 1, 0);
6052 transport_lun_remove_cmd(cmd);
6053 if (transport_cmd_check_stop(cmd, 1, 0))
6054 transport_generic_remove(cmd, 0, 0);
6068 struct se_cmd *cmd; local
6096 cmd = (struct se_cmd *)qr->cmd;
6102 if (!(CMD_TFO(cmd)->new_cmd_map)) {
6107 ret = CMD_TFO(cmd)->new_cmd_map(cmd);
6109 cmd->transport_error_status = ret;
6110 transport_generic_request_failure(cmd, NULL,
6111 0, (cmd->data_direction !=
6117 ret = transport_generic_new_cmd(cmd);
6119 cmd->transport_error_status = ret;
6120 transport_generic_request_failure(cmd, NULL,
6121 0, (cmd->data_direction !=
6126 transport_generic_process_write(cmd);
6129 transport_stop_all_task_timers(cmd);
6130 transport_generic_complete_ok(cmd);
6133 transport_generic_remove(cmd, 1, 0);
6136 transport_generic_do_tmr(cmd);
6139 transport_generic_request_failure(cmd, NULL, 1, 1);
6142 transport_stop_all_task_timers(cmd);
6143 transport_generic_request_timeout(cmd);
6148 " %u\n", t_state, cmd->deferred_t_state,
6149 CMD_TFO(cmd)->get_task_tag(cmd),
6150 CMD_TFO(cmd)->get_cmd_state(cmd),
6151 SE_LUN(cmd)->unpacked_lun);