Lines Matching refs:session
88 struct Scsi_Host *shost = conn->session->host; in iscsi_conn_queue_work()
96 static void __iscsi_update_cmdsn(struct iscsi_session *session, in __iscsi_update_cmdsn() argument
106 if (exp_cmdsn != session->exp_cmdsn && in __iscsi_update_cmdsn()
107 !iscsi_sna_lt(exp_cmdsn, session->exp_cmdsn)) in __iscsi_update_cmdsn()
108 session->exp_cmdsn = exp_cmdsn; in __iscsi_update_cmdsn()
110 if (max_cmdsn != session->max_cmdsn && in __iscsi_update_cmdsn()
111 !iscsi_sna_lt(max_cmdsn, session->max_cmdsn)) in __iscsi_update_cmdsn()
112 session->max_cmdsn = max_cmdsn; in __iscsi_update_cmdsn()
115 void iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr) in iscsi_update_cmdsn() argument
117 __iscsi_update_cmdsn(session, be32_to_cpu(hdr->exp_cmdsn), in iscsi_update_cmdsn()
210 ISCSI_DBG_SESSION(task->conn->session, in iscsi_prep_ecdb_ahs()
233 struct iscsi_session *session = task->conn->session; in iscsi_check_tmf_restrictions() local
234 struct iscsi_tm *tmf = &session->tmhdr; in iscsi_check_tmf_restrictions()
237 if (session->tmf_state == TMF_INITIAL) in iscsi_check_tmf_restrictions()
257 iscsi_session_printk(KERN_INFO, session, in iscsi_check_tmf_restrictions()
266 if (session->fast_abort) { in iscsi_check_tmf_restrictions()
267 iscsi_session_printk(KERN_INFO, session, in iscsi_check_tmf_restrictions()
282 ISCSI_DBG_SESSION(session, in iscsi_check_tmf_restrictions()
305 struct iscsi_session *session = conn->session; in iscsi_prep_scsi_cmd_pdu() local
316 if (conn->session->tt->alloc_pdu) { in iscsi_prep_scsi_cmd_pdu()
317 rc = conn->session->tt->alloc_pdu(task, ISCSI_OP_SCSI_CMD); in iscsi_prep_scsi_cmd_pdu()
325 if (session->tt->parse_pdu_itt) in iscsi_prep_scsi_cmd_pdu()
329 task->conn->session->age); in iscsi_prep_scsi_cmd_pdu()
376 if (session->imm_data_en) { in iscsi_prep_scsi_cmd_pdu()
377 if (transfer_length >= session->first_burst) in iscsi_prep_scsi_cmd_pdu()
378 task->imm_count = min(session->first_burst, in iscsi_prep_scsi_cmd_pdu()
387 if (!session->initial_r2t_en) { in iscsi_prep_scsi_cmd_pdu()
388 r2t->data_length = min(session->first_burst, in iscsi_prep_scsi_cmd_pdu()
415 hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn); in iscsi_prep_scsi_cmd_pdu()
417 if (session->tt->init_task && session->tt->init_task(task)) in iscsi_prep_scsi_cmd_pdu()
421 session->cmdsn++; in iscsi_prep_scsi_cmd_pdu()
424 ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x " in iscsi_prep_scsi_cmd_pdu()
429 session->cmdsn, in iscsi_prep_scsi_cmd_pdu()
430 session->max_cmdsn - session->exp_cmdsn + 1); in iscsi_prep_scsi_cmd_pdu()
445 struct iscsi_session *session = conn->session; in iscsi_free_task() local
449 ISCSI_DBG_SESSION(session, "freeing task itt 0x%x state %d sc %p\n", in iscsi_free_task()
452 session->tt->cleanup_task(task); in iscsi_free_task()
461 kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*)); in iscsi_free_task()
490 struct iscsi_session *session = task->conn->session; in iscsi_put_task() local
493 spin_lock_bh(&session->back_lock); in iscsi_put_task()
495 spin_unlock_bh(&session->back_lock); in iscsi_put_task()
510 ISCSI_DBG_SESSION(conn->session, in iscsi_complete_task()
544 ISCSI_DBG_SESSION(conn->session, "[itt 0x%x]\n", task->itt); in iscsi_complete_scsi_task()
547 __iscsi_update_cmdsn(conn->session, exp_cmdsn, max_cmdsn); in iscsi_complete_scsi_task()
594 spin_lock_bh(&conn->session->back_lock); in fail_scsi_task()
596 spin_unlock_bh(&conn->session->back_lock); in fail_scsi_task()
605 conn->session->queued_cmdsn--; in fail_scsi_task()
617 spin_unlock_bh(&conn->session->back_lock); in fail_scsi_task()
623 struct iscsi_session *session = conn->session; in iscsi_prep_mgmt_task() local
628 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) in iscsi_prep_mgmt_task()
636 nop->cmdsn = cpu_to_be32(session->cmdsn); in iscsi_prep_mgmt_task()
648 session->queued_cmdsn++; in iscsi_prep_mgmt_task()
649 session->cmdsn++; in iscsi_prep_mgmt_task()
653 if (session->tt->init_task && session->tt->init_task(task)) in iscsi_prep_mgmt_task()
657 session->state = ISCSI_STATE_LOGGING_OUT; in iscsi_prep_mgmt_task()
660 ISCSI_DBG_SESSION(session, "mgmtpdu [op 0x%x hdr->itt 0x%x " in iscsi_prep_mgmt_task()
670 struct iscsi_session *session = conn->session; in __iscsi_conn_send_pdu() local
671 struct iscsi_host *ihost = shost_priv(session->host); in __iscsi_conn_send_pdu()
676 if (session->state == ISCSI_STATE_TERMINATE) in __iscsi_conn_send_pdu()
699 if (session->state != ISCSI_STATE_LOGGED_IN) in __iscsi_conn_send_pdu()
710 if (!kfifo_out(&session->cmdpool.queue, in __iscsi_conn_send_pdu()
731 if (conn->session->tt->alloc_pdu) { in __iscsi_conn_send_pdu()
732 if (conn->session->tt->alloc_pdu(task, hdr->opcode)) { in __iscsi_conn_send_pdu()
744 if (session->tt->parse_pdu_itt) in __iscsi_conn_send_pdu()
748 task->conn->session->age); in __iscsi_conn_send_pdu()
758 if (session->tt->xmit_task(task)) in __iscsi_conn_send_pdu()
769 spin_lock(&session->back_lock); in __iscsi_conn_send_pdu()
771 spin_unlock(&session->back_lock); in __iscsi_conn_send_pdu()
779 struct iscsi_session *session = conn->session; in iscsi_conn_send_pdu() local
782 spin_lock_bh(&session->frwd_lock); in iscsi_conn_send_pdu()
785 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_send_pdu()
806 struct iscsi_session *session = conn->session; in iscsi_scsi_cmd_rsp() local
809 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); in iscsi_scsi_cmd_rsp()
823 BUG_ON(!session->tt->check_protection); in iscsi_scsi_cmd_rsp()
825 ascq = session->tt->check_protection(task, §or); in iscsi_scsi_cmd_rsp()
861 ISCSI_DBG_SESSION(session, "copied %d bytes of sense\n", in iscsi_scsi_cmd_rsp()
884 ISCSI_DBG_SESSION(session, "cmd rsp done [sc %p res %d itt 0x%x]\n", in iscsi_scsi_cmd_rsp()
909 iscsi_update_cmdsn(conn->session, (struct iscsi_nopin *)hdr); in iscsi_data_in_rsp()
924 ISCSI_DBG_SESSION(conn->session, "data in with status done " in iscsi_data_in_rsp()
934 struct iscsi_session *session = conn->session; in iscsi_tmf_rsp() local
939 if (session->tmf_state != TMF_QUEUED) in iscsi_tmf_rsp()
943 session->tmf_state = TMF_SUCCESS; in iscsi_tmf_rsp()
945 session->tmf_state = TMF_NOT_FOUND; in iscsi_tmf_rsp()
947 session->tmf_state = TMF_FAILED; in iscsi_tmf_rsp()
948 wake_up(&session->ehwait); in iscsi_tmf_rsp()
1066 spin_unlock(&conn->session->back_lock); in iscsi_handle_reject()
1067 spin_lock(&conn->session->frwd_lock); in iscsi_handle_reject()
1070 spin_unlock(&conn->session->frwd_lock); in iscsi_handle_reject()
1071 spin_lock(&conn->session->back_lock); in iscsi_handle_reject()
1112 struct iscsi_session *session = conn->session; in iscsi_itt_to_task() local
1118 if (session->tt->parse_pdu_itt) in iscsi_itt_to_task()
1119 session->tt->parse_pdu_itt(conn, itt, &i, NULL); in iscsi_itt_to_task()
1122 if (i >= session->cmds_max) in iscsi_itt_to_task()
1125 return session->cmds[i]; in iscsi_itt_to_task()
1143 struct iscsi_session *session = conn->session; in __iscsi_complete_pdu() local
1158 ISCSI_DBG_SESSION(session, "[op 0x%x cid %d itt 0x%x len %d]\n", in __iscsi_complete_pdu()
1162 iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); in __iscsi_complete_pdu()
1175 spin_unlock(&session->back_lock); in __iscsi_complete_pdu()
1176 spin_lock(&session->frwd_lock); in __iscsi_complete_pdu()
1178 spin_unlock(&session->frwd_lock); in __iscsi_complete_pdu()
1179 spin_lock(&session->back_lock); in __iscsi_complete_pdu()
1230 iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); in __iscsi_complete_pdu()
1239 iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); in __iscsi_complete_pdu()
1246 iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); in __iscsi_complete_pdu()
1256 iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); in __iscsi_complete_pdu()
1286 spin_lock(&conn->session->back_lock); in iscsi_complete_pdu()
1288 spin_unlock(&conn->session->back_lock); in iscsi_complete_pdu()
1295 struct iscsi_session *session = conn->session; in iscsi_verify_itt() local
1301 if (session->tt->parse_pdu_itt) in iscsi_verify_itt()
1302 session->tt->parse_pdu_itt(conn, itt, &i, &age); in iscsi_verify_itt()
1308 if (age != session->age) { in iscsi_verify_itt()
1311 (__force u32)itt, session->age); in iscsi_verify_itt()
1315 if (i >= session->cmds_max) { in iscsi_verify_itt()
1318 "%u.\n", i, session->cmds_max); in iscsi_verify_itt()
1345 if (task->sc->SCp.phase != conn->session->age) { in iscsi_itt_to_ctask()
1346 iscsi_session_printk(KERN_ERR, conn->session, in iscsi_itt_to_ctask()
1348 task->sc->SCp.phase, conn->session->age); in iscsi_itt_to_ctask()
1356 void iscsi_session_failure(struct iscsi_session *session, in iscsi_session_failure() argument
1361 spin_lock_bh(&session->frwd_lock); in iscsi_session_failure()
1362 conn = session->leadconn; in iscsi_session_failure()
1363 if (session->state == ISCSI_STATE_TERMINATE || !conn) { in iscsi_session_failure()
1364 spin_unlock_bh(&session->frwd_lock); in iscsi_session_failure()
1369 spin_unlock_bh(&session->frwd_lock); in iscsi_session_failure()
1385 struct iscsi_session *session = conn->session; in iscsi_conn_failure() local
1387 spin_lock_bh(&session->frwd_lock); in iscsi_conn_failure()
1388 if (session->state == ISCSI_STATE_FAILED) { in iscsi_conn_failure()
1389 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_failure()
1394 session->state = ISCSI_STATE_FAILED; in iscsi_conn_failure()
1395 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_failure()
1405 struct iscsi_session *session = conn->session; in iscsi_check_cmdsn_window_closed() local
1410 if (!iscsi_sna_lte(session->queued_cmdsn, session->max_cmdsn)) { in iscsi_check_cmdsn_window_closed()
1411 ISCSI_DBG_SESSION(session, "iSCSI CmdSN closed. ExpCmdSn " in iscsi_check_cmdsn_window_closed()
1413 session->exp_cmdsn, session->max_cmdsn, in iscsi_check_cmdsn_window_closed()
1414 session->cmdsn, session->queued_cmdsn); in iscsi_check_cmdsn_window_closed()
1425 spin_lock_bh(&conn->session->back_lock); in iscsi_xmit_task()
1452 spin_unlock_bh(&conn->session->back_lock); in iscsi_xmit_task()
1455 spin_unlock_bh(&conn->session->back_lock); in iscsi_xmit_task()
1457 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_xmit_task()
1458 rc = conn->session->tt->xmit_task(task); in iscsi_xmit_task()
1459 spin_lock_bh(&conn->session->frwd_lock); in iscsi_xmit_task()
1465 spin_lock(&conn->session->back_lock); in iscsi_xmit_task()
1476 spin_unlock(&conn->session->back_lock); in iscsi_xmit_task()
1494 spin_lock_bh(&conn->session->frwd_lock); in iscsi_requeue_task()
1505 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_requeue_task()
1523 spin_lock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1525 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n"); in iscsi_data_xmit()
1526 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1548 spin_lock_bh(&conn->session->back_lock); in iscsi_data_xmit()
1550 spin_unlock_bh(&conn->session->back_lock); in iscsi_data_xmit()
1563 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) { in iscsi_data_xmit()
1591 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) in iscsi_data_xmit()
1607 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1611 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1633 if (!kfifo_out(&conn->session->cmdpool.queue, in iscsi_alloc_task()
1637 sc->SCp.phase = conn->session->age; in iscsi_alloc_task()
1670 struct iscsi_session *session; in iscsi_queuecommand() local
1680 session = cls_session->dd_data; in iscsi_queuecommand()
1681 spin_lock_bh(&session->frwd_lock); in iscsi_queuecommand()
1689 if (session->state != ISCSI_STATE_LOGGED_IN) { in iscsi_queuecommand()
1696 switch (session->state) { in iscsi_queuecommand()
1731 conn = session->leadconn; in iscsi_queuecommand()
1766 if (session->tt->xmit_task(task)) { in iscsi_queuecommand()
1767 session->cmdsn--; in iscsi_queuecommand()
1776 session->queued_cmdsn++; in iscsi_queuecommand()
1777 spin_unlock_bh(&session->frwd_lock); in iscsi_queuecommand()
1781 spin_lock_bh(&session->back_lock); in iscsi_queuecommand()
1783 spin_unlock_bh(&session->back_lock); in iscsi_queuecommand()
1785 spin_unlock_bh(&session->frwd_lock); in iscsi_queuecommand()
1786 ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n", in iscsi_queuecommand()
1791 spin_lock_bh(&session->back_lock); in iscsi_queuecommand()
1793 spin_unlock_bh(&session->back_lock); in iscsi_queuecommand()
1795 spin_unlock_bh(&session->frwd_lock); in iscsi_queuecommand()
1796 ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n", in iscsi_queuecommand()
1807 struct iscsi_session *session = cls_session->dd_data; in iscsi_target_alloc() local
1809 starget->can_queue = session->scsi_cmds_max; in iscsi_target_alloc()
1816 struct iscsi_session *session = from_timer(session, t, tmf_timer); in iscsi_tmf_timedout() local
1818 spin_lock(&session->frwd_lock); in iscsi_tmf_timedout()
1819 if (session->tmf_state == TMF_QUEUED) { in iscsi_tmf_timedout()
1820 session->tmf_state = TMF_TIMEDOUT; in iscsi_tmf_timedout()
1821 ISCSI_DBG_EH(session, "tmf timedout\n"); in iscsi_tmf_timedout()
1823 wake_up(&session->ehwait); in iscsi_tmf_timedout()
1825 spin_unlock(&session->frwd_lock); in iscsi_tmf_timedout()
1831 __must_hold(&session->frwd_lock) in iscsi_exec_task_mgmt_fn()
1833 struct iscsi_session *session = conn->session; in iscsi_exec_task_mgmt_fn() local
1839 spin_unlock_bh(&session->frwd_lock); in iscsi_exec_task_mgmt_fn()
1842 spin_lock_bh(&session->frwd_lock); in iscsi_exec_task_mgmt_fn()
1846 session->tmf_timer.expires = timeout * HZ + jiffies; in iscsi_exec_task_mgmt_fn()
1847 add_timer(&session->tmf_timer); in iscsi_exec_task_mgmt_fn()
1848 ISCSI_DBG_EH(session, "tmf set timeout\n"); in iscsi_exec_task_mgmt_fn()
1850 spin_unlock_bh(&session->frwd_lock); in iscsi_exec_task_mgmt_fn()
1851 mutex_unlock(&session->eh_mutex); in iscsi_exec_task_mgmt_fn()
1861 wait_event_interruptible(session->ehwait, age != session->age || in iscsi_exec_task_mgmt_fn()
1862 session->state != ISCSI_STATE_LOGGED_IN || in iscsi_exec_task_mgmt_fn()
1863 session->tmf_state != TMF_QUEUED); in iscsi_exec_task_mgmt_fn()
1866 del_timer_sync(&session->tmf_timer); in iscsi_exec_task_mgmt_fn()
1868 mutex_lock(&session->eh_mutex); in iscsi_exec_task_mgmt_fn()
1869 spin_lock_bh(&session->frwd_lock); in iscsi_exec_task_mgmt_fn()
1871 if (age != session->age || in iscsi_exec_task_mgmt_fn()
1872 session->state != ISCSI_STATE_LOGGED_IN) in iscsi_exec_task_mgmt_fn()
1882 struct iscsi_session *session = conn->session; in fail_scsi_tasks() local
1886 spin_lock_bh(&session->back_lock); in fail_scsi_tasks()
1887 for (i = 0; i < session->cmds_max; i++) { in fail_scsi_tasks()
1888 task = session->cmds[i]; in fail_scsi_tasks()
1896 spin_unlock_bh(&session->back_lock); in fail_scsi_tasks()
1898 ISCSI_DBG_SESSION(session, in fail_scsi_tasks()
1903 spin_unlock_bh(&session->frwd_lock); in fail_scsi_tasks()
1905 spin_lock_bh(&session->frwd_lock); in fail_scsi_tasks()
1907 spin_lock_bh(&session->back_lock); in fail_scsi_tasks()
1910 spin_unlock_bh(&session->back_lock); in fail_scsi_tasks()
1926 spin_lock_bh(&conn->session->frwd_lock); in iscsi_suspend_queue()
1928 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_suspend_queue()
1942 struct Scsi_Host *shost = conn->session->host; in iscsi_suspend_tx()
1978 struct iscsi_session *session; in iscsi_eh_cmd_timed_out() local
1983 session = cls_session->dd_data; in iscsi_eh_cmd_timed_out()
1985 ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc); in iscsi_eh_cmd_timed_out()
1987 spin_lock_bh(&session->frwd_lock); in iscsi_eh_cmd_timed_out()
1988 spin_lock(&session->back_lock); in iscsi_eh_cmd_timed_out()
1996 spin_unlock(&session->back_lock); in iscsi_eh_cmd_timed_out()
2000 spin_unlock(&session->back_lock); in iscsi_eh_cmd_timed_out()
2002 if (session->state != ISCSI_STATE_LOGGED_IN) { in iscsi_eh_cmd_timed_out()
2012 ISCSI_DBG_EH(session, "sc on shutdown, handled\n"); in iscsi_eh_cmd_timed_out()
2024 conn = session->leadconn; in iscsi_eh_cmd_timed_out()
2039 ISCSI_DBG_EH(session, "Command making progress. Asking " in iscsi_eh_cmd_timed_out()
2059 spin_lock(&session->back_lock); in iscsi_eh_cmd_timed_out()
2060 for (i = 0; i < conn->session->cmds_max; i++) { in iscsi_eh_cmd_timed_out()
2061 running_task = conn->session->cmds[i]; in iscsi_eh_cmd_timed_out()
2085 ISCSI_DBG_EH(session, "Command has not made progress " in iscsi_eh_cmd_timed_out()
2092 spin_unlock(&session->back_lock); in iscsi_eh_cmd_timed_out()
2097 spin_unlock(&session->back_lock); in iscsi_eh_cmd_timed_out()
2119 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_cmd_timed_out()
2125 ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? in iscsi_eh_cmd_timed_out()
2134 struct iscsi_session *session = conn->session; in iscsi_check_transport_timeouts() local
2137 spin_lock(&session->frwd_lock); in iscsi_check_transport_timeouts()
2138 if (session->state != ISCSI_STATE_LOGGED_IN) in iscsi_check_transport_timeouts()
2154 spin_unlock(&session->frwd_lock); in iscsi_check_transport_timeouts()
2172 spin_unlock(&session->frwd_lock); in iscsi_check_transport_timeouts()
2190 struct iscsi_session *session; in iscsi_eh_abort() local
2197 session = cls_session->dd_data; in iscsi_eh_abort()
2199 ISCSI_DBG_EH(session, "aborting sc %p\n", sc); in iscsi_eh_abort()
2201 mutex_lock(&session->eh_mutex); in iscsi_eh_abort()
2202 spin_lock_bh(&session->frwd_lock); in iscsi_eh_abort()
2208 ISCSI_DBG_EH(session, "sc never reached iscsi layer or " in iscsi_eh_abort()
2210 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2211 mutex_unlock(&session->eh_mutex); in iscsi_eh_abort()
2219 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN || in iscsi_eh_abort()
2220 sc->SCp.phase != session->age) { in iscsi_eh_abort()
2221 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2222 mutex_unlock(&session->eh_mutex); in iscsi_eh_abort()
2223 ISCSI_DBG_EH(session, "failing abort due to dropped " in iscsi_eh_abort()
2228 conn = session->leadconn; in iscsi_eh_abort()
2230 age = session->age; in iscsi_eh_abort()
2232 spin_lock(&session->back_lock); in iscsi_eh_abort()
2236 ISCSI_DBG_EH(session, "sc completed while abort in progress\n"); in iscsi_eh_abort()
2238 spin_unlock(&session->back_lock); in iscsi_eh_abort()
2239 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2240 mutex_unlock(&session->eh_mutex); in iscsi_eh_abort()
2243 ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt); in iscsi_eh_abort()
2245 spin_unlock(&session->back_lock); in iscsi_eh_abort()
2253 if (session->tmf_state != TMF_INITIAL) in iscsi_eh_abort()
2255 session->tmf_state = TMF_QUEUED; in iscsi_eh_abort()
2257 hdr = &session->tmhdr; in iscsi_eh_abort()
2260 if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout)) in iscsi_eh_abort()
2263 switch (session->tmf_state) { in iscsi_eh_abort()
2265 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2276 spin_lock_bh(&session->frwd_lock); in iscsi_eh_abort()
2278 session->tmf_state = TMF_INITIAL; in iscsi_eh_abort()
2280 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2284 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2289 session->tmf_state = TMF_INITIAL; in iscsi_eh_abort()
2292 ISCSI_DBG_EH(session, "sc completed while abort in " in iscsi_eh_abort()
2298 session->tmf_state = TMF_INITIAL; in iscsi_eh_abort()
2303 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2305 ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n", in iscsi_eh_abort()
2308 mutex_unlock(&session->eh_mutex); in iscsi_eh_abort()
2312 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_abort()
2314 ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc, in iscsi_eh_abort()
2317 mutex_unlock(&session->eh_mutex); in iscsi_eh_abort()
2335 struct iscsi_session *session; in iscsi_eh_device_reset() local
2341 session = cls_session->dd_data; in iscsi_eh_device_reset()
2343 ISCSI_DBG_EH(session, "LU Reset [sc %p lun %llu]\n", sc, in iscsi_eh_device_reset()
2346 mutex_lock(&session->eh_mutex); in iscsi_eh_device_reset()
2347 spin_lock_bh(&session->frwd_lock); in iscsi_eh_device_reset()
2352 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) in iscsi_eh_device_reset()
2354 conn = session->leadconn; in iscsi_eh_device_reset()
2357 if (session->tmf_state != TMF_INITIAL) in iscsi_eh_device_reset()
2359 session->tmf_state = TMF_QUEUED; in iscsi_eh_device_reset()
2361 hdr = &session->tmhdr; in iscsi_eh_device_reset()
2364 if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age, in iscsi_eh_device_reset()
2365 session->lu_reset_timeout)) { in iscsi_eh_device_reset()
2370 switch (session->tmf_state) { in iscsi_eh_device_reset()
2374 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_device_reset()
2378 session->tmf_state = TMF_INITIAL; in iscsi_eh_device_reset()
2383 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_device_reset()
2387 spin_lock_bh(&session->frwd_lock); in iscsi_eh_device_reset()
2390 session->tmf_state = TMF_INITIAL; in iscsi_eh_device_reset()
2391 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_device_reset()
2397 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_device_reset()
2399 ISCSI_DBG_EH(session, "dev reset result = %s\n", in iscsi_eh_device_reset()
2401 mutex_unlock(&session->eh_mutex); in iscsi_eh_device_reset()
2408 struct iscsi_session *session = cls_session->dd_data; in iscsi_session_recovery_timedout() local
2410 spin_lock_bh(&session->frwd_lock); in iscsi_session_recovery_timedout()
2411 if (session->state != ISCSI_STATE_LOGGED_IN) { in iscsi_session_recovery_timedout()
2412 session->state = ISCSI_STATE_RECOVERY_FAILED; in iscsi_session_recovery_timedout()
2413 wake_up(&session->ehwait); in iscsi_session_recovery_timedout()
2415 spin_unlock_bh(&session->frwd_lock); in iscsi_session_recovery_timedout()
2429 struct iscsi_session *session; in iscsi_eh_session_reset() local
2433 session = cls_session->dd_data; in iscsi_eh_session_reset()
2434 conn = session->leadconn; in iscsi_eh_session_reset()
2436 mutex_lock(&session->eh_mutex); in iscsi_eh_session_reset()
2437 spin_lock_bh(&session->frwd_lock); in iscsi_eh_session_reset()
2438 if (session->state == ISCSI_STATE_TERMINATE) { in iscsi_eh_session_reset()
2440 ISCSI_DBG_EH(session, in iscsi_eh_session_reset()
2442 "%s [age %d]\n", session->targetname, in iscsi_eh_session_reset()
2443 session->age); in iscsi_eh_session_reset()
2444 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_session_reset()
2445 mutex_unlock(&session->eh_mutex); in iscsi_eh_session_reset()
2449 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_session_reset()
2450 mutex_unlock(&session->eh_mutex); in iscsi_eh_session_reset()
2457 ISCSI_DBG_EH(session, "wait for relogin\n"); in iscsi_eh_session_reset()
2458 wait_event_interruptible(session->ehwait, in iscsi_eh_session_reset()
2459 session->state == ISCSI_STATE_TERMINATE || in iscsi_eh_session_reset()
2460 session->state == ISCSI_STATE_LOGGED_IN || in iscsi_eh_session_reset()
2461 session->state == ISCSI_STATE_RECOVERY_FAILED); in iscsi_eh_session_reset()
2465 mutex_lock(&session->eh_mutex); in iscsi_eh_session_reset()
2466 spin_lock_bh(&session->frwd_lock); in iscsi_eh_session_reset()
2467 if (session->state == ISCSI_STATE_LOGGED_IN) { in iscsi_eh_session_reset()
2468 ISCSI_DBG_EH(session, in iscsi_eh_session_reset()
2470 session->targetname, conn->persistent_address); in iscsi_eh_session_reset()
2473 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_session_reset()
2474 mutex_unlock(&session->eh_mutex); in iscsi_eh_session_reset()
2497 struct iscsi_session *session; in iscsi_eh_target_reset() local
2503 session = cls_session->dd_data; in iscsi_eh_target_reset()
2505 ISCSI_DBG_EH(session, "tgt Reset [sc %p tgt %s]\n", sc, in iscsi_eh_target_reset()
2506 session->targetname); in iscsi_eh_target_reset()
2508 mutex_lock(&session->eh_mutex); in iscsi_eh_target_reset()
2509 spin_lock_bh(&session->frwd_lock); in iscsi_eh_target_reset()
2514 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) in iscsi_eh_target_reset()
2516 conn = session->leadconn; in iscsi_eh_target_reset()
2519 if (session->tmf_state != TMF_INITIAL) in iscsi_eh_target_reset()
2521 session->tmf_state = TMF_QUEUED; in iscsi_eh_target_reset()
2523 hdr = &session->tmhdr; in iscsi_eh_target_reset()
2526 if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age, in iscsi_eh_target_reset()
2527 session->tgt_reset_timeout)) { in iscsi_eh_target_reset()
2532 switch (session->tmf_state) { in iscsi_eh_target_reset()
2536 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_target_reset()
2540 session->tmf_state = TMF_INITIAL; in iscsi_eh_target_reset()
2545 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_target_reset()
2549 spin_lock_bh(&session->frwd_lock); in iscsi_eh_target_reset()
2552 session->tmf_state = TMF_INITIAL; in iscsi_eh_target_reset()
2553 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_target_reset()
2559 spin_unlock_bh(&session->frwd_lock); in iscsi_eh_target_reset()
2561 ISCSI_DBG_EH(session, "tgt %s reset result = %s\n", session->targetname, in iscsi_eh_target_reset()
2563 mutex_unlock(&session->eh_mutex); in iscsi_eh_target_reset()
2843 struct iscsi_session *session; in iscsi_session_setup() local
2865 session = cls_session->dd_data; in iscsi_session_setup()
2866 session->cls_session = cls_session; in iscsi_session_setup()
2867 session->host = shost; in iscsi_session_setup()
2868 session->state = ISCSI_STATE_FREE; in iscsi_session_setup()
2869 session->fast_abort = 1; in iscsi_session_setup()
2870 session->tgt_reset_timeout = 30; in iscsi_session_setup()
2871 session->lu_reset_timeout = 15; in iscsi_session_setup()
2872 session->abort_timeout = 10; in iscsi_session_setup()
2873 session->scsi_cmds_max = scsi_cmds; in iscsi_session_setup()
2874 session->cmds_max = scsi_cmds + ISCSI_MGMT_CMDS_MAX; in iscsi_session_setup()
2875 session->queued_cmdsn = session->cmdsn = initial_cmdsn; in iscsi_session_setup()
2876 session->exp_cmdsn = initial_cmdsn + 1; in iscsi_session_setup()
2877 session->max_cmdsn = initial_cmdsn + 1; in iscsi_session_setup()
2878 session->max_r2t = 1; in iscsi_session_setup()
2879 session->tt = iscsit; in iscsi_session_setup()
2880 session->dd_data = cls_session->dd_data + sizeof(*session); in iscsi_session_setup()
2882 session->tmf_state = TMF_INITIAL; in iscsi_session_setup()
2883 timer_setup(&session->tmf_timer, iscsi_tmf_timedout, 0); in iscsi_session_setup()
2884 mutex_init(&session->eh_mutex); in iscsi_session_setup()
2886 spin_lock_init(&session->frwd_lock); in iscsi_session_setup()
2887 spin_lock_init(&session->back_lock); in iscsi_session_setup()
2890 if (iscsi_pool_init(&session->cmdpool, session->cmds_max, in iscsi_session_setup()
2891 (void***)&session->cmds, in iscsi_session_setup()
2896 for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { in iscsi_session_setup()
2897 struct iscsi_task *task = session->cmds[cmd_i]; in iscsi_session_setup()
2917 iscsi_pool_free(&session->cmdpool); in iscsi_session_setup()
2932 struct iscsi_session *session = cls_session->dd_data; in iscsi_session_teardown() local
2934 struct Scsi_Host *shost = session->host; in iscsi_session_teardown()
2936 iscsi_pool_free(&session->cmdpool); in iscsi_session_teardown()
2940 kfree(session->password); in iscsi_session_teardown()
2941 kfree(session->password_in); in iscsi_session_teardown()
2942 kfree(session->username); in iscsi_session_teardown()
2943 kfree(session->username_in); in iscsi_session_teardown()
2944 kfree(session->targetname); in iscsi_session_teardown()
2945 kfree(session->targetalias); in iscsi_session_teardown()
2946 kfree(session->initiatorname); in iscsi_session_teardown()
2947 kfree(session->boot_root); in iscsi_session_teardown()
2948 kfree(session->boot_nic); in iscsi_session_teardown()
2949 kfree(session->boot_target); in iscsi_session_teardown()
2950 kfree(session->ifacename); in iscsi_session_teardown()
2951 kfree(session->portal_type); in iscsi_session_teardown()
2952 kfree(session->discovery_parent_type); in iscsi_session_teardown()
2971 struct iscsi_session *session = cls_session->dd_data; in iscsi_conn_setup() local
2984 conn->session = session; in iscsi_conn_setup()
2998 spin_lock_bh(&session->frwd_lock); in iscsi_conn_setup()
2999 if (!kfifo_out(&session->cmdpool.queue, in iscsi_conn_setup()
3002 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_setup()
3005 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_setup()
3013 init_waitqueue_head(&session->ehwait); in iscsi_conn_setup()
3018 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task, in iscsi_conn_setup()
3036 struct iscsi_session *session = conn->session; in iscsi_conn_teardown() local
3042 mutex_lock(&session->eh_mutex); in iscsi_conn_teardown()
3043 spin_lock_bh(&session->frwd_lock); in iscsi_conn_teardown()
3045 if (session->leadconn == conn) { in iscsi_conn_teardown()
3049 session->state = ISCSI_STATE_TERMINATE; in iscsi_conn_teardown()
3050 wake_up(&session->ehwait); in iscsi_conn_teardown()
3052 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_teardown()
3057 spin_lock_bh(&session->frwd_lock); in iscsi_conn_teardown()
3061 spin_lock_bh(&session->back_lock); in iscsi_conn_teardown()
3062 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task, in iscsi_conn_teardown()
3064 spin_unlock_bh(&session->back_lock); in iscsi_conn_teardown()
3065 if (session->leadconn == conn) in iscsi_conn_teardown()
3066 session->leadconn = NULL; in iscsi_conn_teardown()
3067 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_teardown()
3068 mutex_unlock(&session->eh_mutex); in iscsi_conn_teardown()
3079 struct iscsi_session *session = conn->session; in iscsi_conn_start() local
3081 if (!session) { in iscsi_conn_start()
3087 if ((session->imm_data_en || !session->initial_r2t_en) && in iscsi_conn_start()
3088 session->first_burst > session->max_burst) { in iscsi_conn_start()
3091 session->first_burst, session->max_burst); in iscsi_conn_start()
3107 spin_lock_bh(&session->frwd_lock); in iscsi_conn_start()
3109 session->state = ISCSI_STATE_LOGGED_IN; in iscsi_conn_start()
3110 session->queued_cmdsn = session->cmdsn; in iscsi_conn_start()
3125 session->tmf_state = TMF_INITIAL; in iscsi_conn_start()
3126 session->age++; in iscsi_conn_start()
3127 if (session->age == 16) in iscsi_conn_start()
3128 session->age = 0; in iscsi_conn_start()
3136 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_start()
3138 iscsi_unblock_session(session->cls_session); in iscsi_conn_start()
3139 wake_up(&session->ehwait); in iscsi_conn_start()
3145 fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) in fail_mgmt_tasks() argument
3150 for (i = 0; i < conn->session->cmds_max; i++) { in fail_mgmt_tasks()
3151 task = conn->session->cmds[i]; in fail_mgmt_tasks()
3158 ISCSI_DBG_SESSION(conn->session, in fail_mgmt_tasks()
3162 spin_lock_bh(&session->back_lock); in fail_mgmt_tasks()
3164 spin_unlock_bh(&session->back_lock); in fail_mgmt_tasks()
3172 spin_unlock_bh(&session->back_lock); in fail_mgmt_tasks()
3179 struct iscsi_session *session = conn->session; in iscsi_conn_stop() local
3182 mutex_lock(&session->eh_mutex); in iscsi_conn_stop()
3183 spin_lock_bh(&session->frwd_lock); in iscsi_conn_stop()
3185 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_stop()
3186 mutex_unlock(&session->eh_mutex); in iscsi_conn_stop()
3196 session->state = ISCSI_STATE_TERMINATE; in iscsi_conn_stop()
3198 session->state = ISCSI_STATE_IN_RECOVERY; in iscsi_conn_stop()
3202 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_stop()
3207 spin_lock_bh(&session->frwd_lock); in iscsi_conn_stop()
3209 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_stop()
3220 if (session->state == ISCSI_STATE_IN_RECOVERY && in iscsi_conn_stop()
3222 ISCSI_DBG_SESSION(session, "blocking session\n"); in iscsi_conn_stop()
3223 iscsi_block_session(session->cls_session); in iscsi_conn_stop()
3230 spin_lock_bh(&session->frwd_lock); in iscsi_conn_stop()
3232 fail_mgmt_tasks(session, conn); in iscsi_conn_stop()
3233 memset(&session->tmhdr, 0, sizeof(session->tmhdr)); in iscsi_conn_stop()
3234 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_stop()
3235 mutex_unlock(&session->eh_mutex); in iscsi_conn_stop()
3242 struct iscsi_session *session = cls_session->dd_data; in iscsi_conn_bind() local
3245 spin_lock_bh(&session->frwd_lock); in iscsi_conn_bind()
3247 session->leadconn = conn; in iscsi_conn_bind()
3248 spin_unlock_bh(&session->frwd_lock); in iscsi_conn_bind()
3254 spin_lock_bh(&session->back_lock); in iscsi_conn_bind()
3255 session->max_cmdsn = session->exp_cmdsn = session->cmdsn + 1; in iscsi_conn_bind()
3256 spin_unlock_bh(&session->back_lock); in iscsi_conn_bind()
3289 struct iscsi_session *session = conn->session; in iscsi_set_param() local
3294 sscanf(buf, "%d", &session->fast_abort); in iscsi_set_param()
3297 sscanf(buf, "%d", &session->abort_timeout); in iscsi_set_param()
3300 sscanf(buf, "%d", &session->lu_reset_timeout); in iscsi_set_param()
3303 sscanf(buf, "%d", &session->tgt_reset_timeout); in iscsi_set_param()
3324 sscanf(buf, "%d", &session->initial_r2t_en); in iscsi_set_param()
3327 sscanf(buf, "%hu", &session->max_r2t); in iscsi_set_param()
3330 sscanf(buf, "%d", &session->imm_data_en); in iscsi_set_param()
3333 sscanf(buf, "%d", &session->first_burst); in iscsi_set_param()
3336 sscanf(buf, "%d", &session->max_burst); in iscsi_set_param()
3339 sscanf(buf, "%d", &session->pdu_inorder_en); in iscsi_set_param()
3342 sscanf(buf, "%d", &session->dataseq_inorder_en); in iscsi_set_param()
3345 sscanf(buf, "%d", &session->erl); in iscsi_set_param()
3351 return iscsi_switch_str_param(&session->username, buf); in iscsi_set_param()
3353 return iscsi_switch_str_param(&session->username_in, buf); in iscsi_set_param()
3355 return iscsi_switch_str_param(&session->password, buf); in iscsi_set_param()
3357 return iscsi_switch_str_param(&session->password_in, buf); in iscsi_set_param()
3359 return iscsi_switch_str_param(&session->targetname, buf); in iscsi_set_param()
3361 return iscsi_switch_str_param(&session->targetalias, buf); in iscsi_set_param()
3363 sscanf(buf, "%d", &session->tpgt); in iscsi_set_param()
3371 return iscsi_switch_str_param(&session->ifacename, buf); in iscsi_set_param()
3373 return iscsi_switch_str_param(&session->initiatorname, buf); in iscsi_set_param()
3375 return iscsi_switch_str_param(&session->boot_root, buf); in iscsi_set_param()
3377 return iscsi_switch_str_param(&session->boot_nic, buf); in iscsi_set_param()
3379 return iscsi_switch_str_param(&session->boot_target, buf); in iscsi_set_param()
3381 return iscsi_switch_str_param(&session->portal_type, buf); in iscsi_set_param()
3383 return iscsi_switch_str_param(&session->discovery_parent_type, in iscsi_set_param()
3387 session->discovery_sess = !!val; in iscsi_set_param()
3402 struct iscsi_session *session = cls_session->dd_data; in iscsi_session_get_param() local
3407 len = sysfs_emit(buf, "%d\n", session->fast_abort); in iscsi_session_get_param()
3410 len = sysfs_emit(buf, "%d\n", session->abort_timeout); in iscsi_session_get_param()
3413 len = sysfs_emit(buf, "%d\n", session->lu_reset_timeout); in iscsi_session_get_param()
3416 len = sysfs_emit(buf, "%d\n", session->tgt_reset_timeout); in iscsi_session_get_param()
3419 len = sysfs_emit(buf, "%d\n", session->initial_r2t_en); in iscsi_session_get_param()
3422 len = sysfs_emit(buf, "%hu\n", session->max_r2t); in iscsi_session_get_param()
3425 len = sysfs_emit(buf, "%d\n", session->imm_data_en); in iscsi_session_get_param()
3428 len = sysfs_emit(buf, "%u\n", session->first_burst); in iscsi_session_get_param()
3431 len = sysfs_emit(buf, "%u\n", session->max_burst); in iscsi_session_get_param()
3434 len = sysfs_emit(buf, "%d\n", session->pdu_inorder_en); in iscsi_session_get_param()
3437 len = sysfs_emit(buf, "%d\n", session->dataseq_inorder_en); in iscsi_session_get_param()
3440 len = sysfs_emit(buf, "%d\n", session->def_taskmgmt_tmo); in iscsi_session_get_param()
3443 len = sysfs_emit(buf, "%d\n", session->erl); in iscsi_session_get_param()
3446 len = sysfs_emit(buf, "%s\n", session->targetname); in iscsi_session_get_param()
3449 len = sysfs_emit(buf, "%s\n", session->targetalias); in iscsi_session_get_param()
3452 len = sysfs_emit(buf, "%d\n", session->tpgt); in iscsi_session_get_param()
3455 len = sysfs_emit(buf, "%s\n", session->username); in iscsi_session_get_param()
3458 len = sysfs_emit(buf, "%s\n", session->username_in); in iscsi_session_get_param()
3461 len = sysfs_emit(buf, "%s\n", session->password); in iscsi_session_get_param()
3464 len = sysfs_emit(buf, "%s\n", session->password_in); in iscsi_session_get_param()
3467 len = sysfs_emit(buf, "%s\n", session->ifacename); in iscsi_session_get_param()
3470 len = sysfs_emit(buf, "%s\n", session->initiatorname); in iscsi_session_get_param()
3473 len = sysfs_emit(buf, "%s\n", session->boot_root); in iscsi_session_get_param()
3476 len = sysfs_emit(buf, "%s\n", session->boot_nic); in iscsi_session_get_param()
3479 len = sysfs_emit(buf, "%s\n", session->boot_target); in iscsi_session_get_param()
3482 len = sysfs_emit(buf, "%u\n", session->auto_snd_tgt_disable); in iscsi_session_get_param()
3485 len = sysfs_emit(buf, "%u\n", session->discovery_sess); in iscsi_session_get_param()
3488 len = sysfs_emit(buf, "%s\n", session->portal_type); in iscsi_session_get_param()
3491 len = sysfs_emit(buf, "%u\n", session->chap_auth_en); in iscsi_session_get_param()
3494 len = sysfs_emit(buf, "%u\n", session->discovery_logout_en); in iscsi_session_get_param()
3497 len = sysfs_emit(buf, "%u\n", session->bidi_chap_en); in iscsi_session_get_param()
3500 len = sysfs_emit(buf, "%u\n", session->discovery_auth_optional); in iscsi_session_get_param()
3503 len = sysfs_emit(buf, "%d\n", session->time2wait); in iscsi_session_get_param()
3506 len = sysfs_emit(buf, "%d\n", session->time2retain); in iscsi_session_get_param()
3509 len = sysfs_emit(buf, "%u\n", session->tsid); in iscsi_session_get_param()
3513 session->isid[0], session->isid[1], in iscsi_session_get_param()
3514 session->isid[2], session->isid[3], in iscsi_session_get_param()
3515 session->isid[4], session->isid[5]); in iscsi_session_get_param()
3518 len = sysfs_emit(buf, "%u\n", session->discovery_parent_idx); in iscsi_session_get_param()
3521 if (session->discovery_parent_type) in iscsi_session_get_param()
3523 session->discovery_parent_type); in iscsi_session_get_param()