Lines Matching +full:offset +full:- +full:x
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * (c) Copyright 2007-2013 Datera, Inc.
8 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
28 * checks against to determine a PDU's Offset+Length is within the current
34 struct iscsi_conn *conn = cmd->conn; in iscsit_set_dataout_sequence_values()
39 if (cmd->unsolicited_data) { in iscsit_set_dataout_sequence_values()
40 cmd->seq_start_offset = cmd->write_data_done; in iscsit_set_dataout_sequence_values()
41 cmd->seq_end_offset = min(cmd->se_cmd.data_length, in iscsit_set_dataout_sequence_values()
42 conn->sess->sess_ops->FirstBurstLength); in iscsit_set_dataout_sequence_values()
46 if (!conn->sess->sess_ops->DataSequenceInOrder) in iscsit_set_dataout_sequence_values()
49 if (!cmd->seq_start_offset && !cmd->seq_end_offset) { in iscsit_set_dataout_sequence_values()
50 cmd->seq_start_offset = cmd->write_data_done; in iscsit_set_dataout_sequence_values()
51 cmd->seq_end_offset = (cmd->se_cmd.data_length > in iscsit_set_dataout_sequence_values()
52 conn->sess->sess_ops->MaxBurstLength) ? in iscsit_set_dataout_sequence_values()
53 (cmd->write_data_done + in iscsit_set_dataout_sequence_values()
54 conn->sess->sess_ops->MaxBurstLength) : cmd->se_cmd.data_length; in iscsit_set_dataout_sequence_values()
56 cmd->seq_start_offset = cmd->seq_end_offset; in iscsit_set_dataout_sequence_values()
57 cmd->seq_end_offset = ((cmd->seq_end_offset + in iscsit_set_dataout_sequence_values()
58 conn->sess->sess_ops->MaxBurstLength) >= in iscsit_set_dataout_sequence_values()
59 cmd->se_cmd.data_length) ? cmd->se_cmd.data_length : in iscsit_set_dataout_sequence_values()
60 (cmd->seq_end_offset + in iscsit_set_dataout_sequence_values()
61 conn->sess->sess_ops->MaxBurstLength); in iscsit_set_dataout_sequence_values()
69 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_within_command_recovery_check()
71 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_within_command_recovery_check()
74 * We do the within-command recovery checks here as it is in iscsit_dataout_within_command_recovery_check()
76 * Basically, if we are in within-command recovery and in iscsit_dataout_within_command_recovery_check()
77 * the PDU does not contain the offset the sequence needs, in iscsit_dataout_within_command_recovery_check()
81 * DataPDUInOrder=No we only re-request the failed PDU in iscsit_dataout_within_command_recovery_check()
85 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_dataout_within_command_recovery_check()
86 if ((cmd->cmd_flags & ICF_WITHIN_COMMAND_RECOVERY) && in iscsit_dataout_within_command_recovery_check()
87 cmd->write_data_done != be32_to_cpu(hdr->offset)) in iscsit_dataout_within_command_recovery_check()
90 cmd->cmd_flags &= ~ICF_WITHIN_COMMAND_RECOVERY; in iscsit_dataout_within_command_recovery_check()
94 seq = iscsit_get_seq_holder(cmd, be32_to_cpu(hdr->offset), in iscsit_dataout_within_command_recovery_check()
101 cmd->seq_ptr = seq; in iscsit_dataout_within_command_recovery_check()
103 if (conn->sess->sess_ops->DataPDUInOrder) { in iscsit_dataout_within_command_recovery_check()
104 if (seq->status == in iscsit_dataout_within_command_recovery_check()
106 (seq->offset != be32_to_cpu(hdr->offset) || in iscsit_dataout_within_command_recovery_check()
107 seq->data_sn != be32_to_cpu(hdr->datasn))) in iscsit_dataout_within_command_recovery_check()
110 if (seq->status == in iscsit_dataout_within_command_recovery_check()
112 seq->data_sn != be32_to_cpu(hdr->datasn)) in iscsit_dataout_within_command_recovery_check()
116 if (seq->status == DATAOUT_SEQUENCE_COMPLETE) in iscsit_dataout_within_command_recovery_check()
119 if (seq->status != DATAOUT_SEQUENCE_COMPLETE) in iscsit_dataout_within_command_recovery_check()
120 seq->status = 0; in iscsit_dataout_within_command_recovery_check()
126 pr_err("Dumping DataOUT PDU Offset: %u Length: %d DataSN:" in iscsit_dataout_within_command_recovery_check()
127 " 0x%08x\n", hdr->offset, payload_length, hdr->datasn); in iscsit_dataout_within_command_recovery_check()
136 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_check_unsolicited_sequence()
138 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_check_unsolicited_sequence()
141 if ((be32_to_cpu(hdr->offset) < cmd->seq_start_offset) || in iscsit_dataout_check_unsolicited_sequence()
142 ((be32_to_cpu(hdr->offset) + payload_length) > cmd->seq_end_offset)) { in iscsit_dataout_check_unsolicited_sequence()
143 pr_err("Command ITT: 0x%08x with Offset: %u," in iscsit_dataout_check_unsolicited_sequence()
145 " DataSequenceInOrder=Yes.\n", cmd->init_task_tag, in iscsit_dataout_check_unsolicited_sequence()
146 be32_to_cpu(hdr->offset), payload_length, cmd->seq_start_offset, in iscsit_dataout_check_unsolicited_sequence()
147 cmd->seq_end_offset); in iscsit_dataout_check_unsolicited_sequence()
151 first_burst_len = (cmd->first_burst_len + payload_length); in iscsit_dataout_check_unsolicited_sequence()
153 if (first_burst_len > conn->sess->sess_ops->FirstBurstLength) { in iscsit_dataout_check_unsolicited_sequence()
156 first_burst_len, conn->sess->sess_ops->FirstBurstLength); in iscsit_dataout_check_unsolicited_sequence()
157 transport_send_check_condition_and_sense(&cmd->se_cmd, in iscsit_dataout_check_unsolicited_sequence()
166 if (hdr->flags & ISCSI_FLAG_CMD_FINAL) { in iscsit_dataout_check_unsolicited_sequence()
172 if (!conn->sess->sess_ops->DataPDUInOrder) in iscsit_dataout_check_unsolicited_sequence()
175 if ((first_burst_len != cmd->se_cmd.data_length) && in iscsit_dataout_check_unsolicited_sequence()
176 (first_burst_len != conn->sess->sess_ops->FirstBurstLength)) { in iscsit_dataout_check_unsolicited_sequence()
177 pr_err("Unsolicited non-immediate data" in iscsit_dataout_check_unsolicited_sequence()
180 conn->sess->sess_ops->FirstBurstLength, in iscsit_dataout_check_unsolicited_sequence()
181 cmd->se_cmd.data_length); in iscsit_dataout_check_unsolicited_sequence()
182 transport_send_check_condition_and_sense(&cmd->se_cmd, in iscsit_dataout_check_unsolicited_sequence()
187 if (first_burst_len == conn->sess->sess_ops->FirstBurstLength) { in iscsit_dataout_check_unsolicited_sequence()
188 pr_err("Command ITT: 0x%08x reached" in iscsit_dataout_check_unsolicited_sequence()
190 " error.\n", cmd->init_task_tag, in iscsit_dataout_check_unsolicited_sequence()
191 conn->sess->sess_ops->FirstBurstLength); in iscsit_dataout_check_unsolicited_sequence()
194 if (first_burst_len == cmd->se_cmd.data_length) { in iscsit_dataout_check_unsolicited_sequence()
195 pr_err("Command ITT: 0x%08x reached" in iscsit_dataout_check_unsolicited_sequence()
197 " error.\n", cmd->init_task_tag, cmd->se_cmd.data_length); in iscsit_dataout_check_unsolicited_sequence()
211 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_check_sequence()
214 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_check_sequence()
217 * For DataSequenceInOrder=Yes: Check that the offset and offset+length in iscsit_dataout_check_sequence()
221 * offset+length tuple. in iscsit_dataout_check_sequence()
223 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_dataout_check_sequence()
229 if ((be32_to_cpu(hdr->offset) < cmd->seq_start_offset) || in iscsit_dataout_check_sequence()
230 ((be32_to_cpu(hdr->offset) + payload_length) > cmd->seq_end_offset)) { in iscsit_dataout_check_sequence()
231 pr_err("Command ITT: 0x%08x with Offset: %u," in iscsit_dataout_check_sequence()
233 " DataSequenceInOrder=Yes.\n", cmd->init_task_tag, in iscsit_dataout_check_sequence()
234 be32_to_cpu(hdr->offset), payload_length, cmd->seq_start_offset, in iscsit_dataout_check_sequence()
235 cmd->seq_end_offset); in iscsit_dataout_check_sequence()
242 next_burst_len = (cmd->next_burst_len + payload_length); in iscsit_dataout_check_sequence()
244 seq = iscsit_get_seq_holder(cmd, be32_to_cpu(hdr->offset), in iscsit_dataout_check_sequence()
251 cmd->seq_ptr = seq; in iscsit_dataout_check_sequence()
253 if (seq->status == DATAOUT_SEQUENCE_COMPLETE) { in iscsit_dataout_check_sequence()
259 next_burst_len = (seq->next_burst_len + payload_length); in iscsit_dataout_check_sequence()
262 if (next_burst_len > conn->sess->sess_ops->MaxBurstLength) { in iscsit_dataout_check_sequence()
263 pr_err("Command ITT: 0x%08x, NextBurstLength: %u and" in iscsit_dataout_check_sequence()
265 " error.\n", cmd->init_task_tag, in iscsit_dataout_check_sequence()
266 (next_burst_len - payload_length), in iscsit_dataout_check_sequence()
267 payload_length, conn->sess->sess_ops->MaxBurstLength); in iscsit_dataout_check_sequence()
275 if (hdr->flags & ISCSI_FLAG_CMD_FINAL) { in iscsit_dataout_check_sequence()
281 if (!conn->sess->sess_ops->DataPDUInOrder) in iscsit_dataout_check_sequence()
284 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_dataout_check_sequence()
286 conn->sess->sess_ops->MaxBurstLength) && in iscsit_dataout_check_sequence()
287 ((cmd->write_data_done + payload_length) < in iscsit_dataout_check_sequence()
288 cmd->se_cmd.data_length)) { in iscsit_dataout_check_sequence()
289 pr_err("Command ITT: 0x%08x set ISCSI_FLAG_CMD_FINAL" in iscsit_dataout_check_sequence()
291 " error.\n", cmd->init_task_tag); in iscsit_dataout_check_sequence()
295 if (next_burst_len < seq->xfer_len) { in iscsit_dataout_check_sequence()
296 pr_err("Command ITT: 0x%08x set ISCSI_FLAG_CMD_FINAL" in iscsit_dataout_check_sequence()
298 " error.\n", cmd->init_task_tag); in iscsit_dataout_check_sequence()
303 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_dataout_check_sequence()
305 conn->sess->sess_ops->MaxBurstLength) { in iscsit_dataout_check_sequence()
306 pr_err("Command ITT: 0x%08x reached" in iscsit_dataout_check_sequence()
308 " not set, protocol error.", cmd->init_task_tag, in iscsit_dataout_check_sequence()
309 conn->sess->sess_ops->MaxBurstLength); in iscsit_dataout_check_sequence()
312 if ((cmd->write_data_done + payload_length) == in iscsit_dataout_check_sequence()
313 cmd->se_cmd.data_length) { in iscsit_dataout_check_sequence()
314 pr_err("Command ITT: 0x%08x reached" in iscsit_dataout_check_sequence()
317 cmd->init_task_tag); in iscsit_dataout_check_sequence()
321 if (next_burst_len == seq->xfer_len) { in iscsit_dataout_check_sequence()
322 pr_err("Command ITT: 0x%08x reached" in iscsit_dataout_check_sequence()
325 cmd->init_task_tag); in iscsit_dataout_check_sequence()
340 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_check_datasn()
342 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_check_datasn()
345 * Considering the target has no method of re-requesting DataOUT in iscsit_dataout_check_datasn()
352 if (conn->sess->sess_ops->DataSequenceInOrder) in iscsit_dataout_check_datasn()
353 data_sn = cmd->data_sn; in iscsit_dataout_check_datasn()
355 struct iscsi_seq *seq = cmd->seq_ptr; in iscsit_dataout_check_datasn()
356 data_sn = seq->data_sn; in iscsit_dataout_check_datasn()
359 if (be32_to_cpu(hdr->datasn) > data_sn) { in iscsit_dataout_check_datasn()
360 pr_err("Command ITT: 0x%08x, received DataSN: 0x%08x" in iscsit_dataout_check_datasn()
361 " higher than expected 0x%08x.\n", cmd->init_task_tag, in iscsit_dataout_check_datasn()
362 be32_to_cpu(hdr->datasn), data_sn); in iscsit_dataout_check_datasn()
364 } else if (be32_to_cpu(hdr->datasn) < data_sn) { in iscsit_dataout_check_datasn()
365 pr_err("Command ITT: 0x%08x, received DataSN: 0x%08x" in iscsit_dataout_check_datasn()
366 " lower than expected 0x%08x, discarding payload.\n", in iscsit_dataout_check_datasn()
367 cmd->init_task_tag, be32_to_cpu(hdr->datasn), data_sn); in iscsit_dataout_check_datasn()
374 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_dataout_check_datasn()
375 pr_err("Unable to perform within-command recovery" in iscsit_dataout_check_datasn()
391 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_pre_datapduinorder_yes()
393 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_pre_datapduinorder_yes()
396 * For DataSequenceInOrder=Yes: If the offset is greater than the global in iscsit_dataout_pre_datapduinorder_yes()
397 * DataPDUInOrder=Yes offset counter in struct iscsi_cmd a protcol error has in iscsit_dataout_pre_datapduinorder_yes()
400 * For DataSequenceInOrder=No: If the offset is greater than the per in iscsit_dataout_pre_datapduinorder_yes()
401 * sequence DataPDUInOrder=Yes offset counter in struct iscsi_seq a protocol in iscsit_dataout_pre_datapduinorder_yes()
404 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_dataout_pre_datapduinorder_yes()
405 if (be32_to_cpu(hdr->offset) != cmd->write_data_done) { in iscsit_dataout_pre_datapduinorder_yes()
406 pr_err("Command ITT: 0x%08x, received offset" in iscsit_dataout_pre_datapduinorder_yes()
407 " %u different than expected %u.\n", cmd->init_task_tag, in iscsit_dataout_pre_datapduinorder_yes()
408 be32_to_cpu(hdr->offset), cmd->write_data_done); in iscsit_dataout_pre_datapduinorder_yes()
413 struct iscsi_seq *seq = cmd->seq_ptr; in iscsit_dataout_pre_datapduinorder_yes()
415 if (be32_to_cpu(hdr->offset) > seq->offset) { in iscsit_dataout_pre_datapduinorder_yes()
416 pr_err("Command ITT: 0x%08x, received offset" in iscsit_dataout_pre_datapduinorder_yes()
417 " %u greater than expected %u.\n", cmd->init_task_tag, in iscsit_dataout_pre_datapduinorder_yes()
418 be32_to_cpu(hdr->offset), seq->offset); in iscsit_dataout_pre_datapduinorder_yes()
421 } else if (be32_to_cpu(hdr->offset) < seq->offset) { in iscsit_dataout_pre_datapduinorder_yes()
422 pr_err("Command ITT: 0x%08x, received offset" in iscsit_dataout_pre_datapduinorder_yes()
424 cmd->init_task_tag, be32_to_cpu(hdr->offset), in iscsit_dataout_pre_datapduinorder_yes()
425 seq->offset); in iscsit_dataout_pre_datapduinorder_yes()
434 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_dataout_pre_datapduinorder_yes()
435 pr_err("Unable to perform within-command recovery" in iscsit_dataout_pre_datapduinorder_yes()
444 be32_to_cpu(hdr->offset), payload_length) : in iscsit_dataout_pre_datapduinorder_yes()
454 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_pre_datapduinorder_no()
456 pdu = iscsit_get_pdu_holder(cmd, be32_to_cpu(hdr->offset), in iscsit_dataout_pre_datapduinorder_no()
461 cmd->pdu_ptr = pdu; in iscsit_dataout_pre_datapduinorder_no()
463 switch (pdu->status) { in iscsit_dataout_pre_datapduinorder_no()
469 pr_err("Command ITT: 0x%08x received already gotten" in iscsit_dataout_pre_datapduinorder_no()
470 " Offset: %u, Length: %u\n", cmd->init_task_tag, in iscsit_dataout_pre_datapduinorder_no()
471 be32_to_cpu(hdr->offset), payload_length); in iscsit_dataout_pre_datapduinorder_no()
472 return iscsit_dump_data_payload(cmd->conn, payload_length, 1); in iscsit_dataout_pre_datapduinorder_no()
480 static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 length) in iscsit_dataout_update_r2t() argument
484 if (cmd->unsolicited_data) in iscsit_dataout_update_r2t()
487 r2t = iscsit_get_r2t_for_eos(cmd, offset, length); in iscsit_dataout_update_r2t()
489 return -1; in iscsit_dataout_update_r2t()
491 spin_lock_bh(&cmd->r2t_lock); in iscsit_dataout_update_r2t()
492 r2t->seq_complete = 1; in iscsit_dataout_update_r2t()
493 cmd->outstanding_r2ts--; in iscsit_dataout_update_r2t()
494 spin_unlock_bh(&cmd->r2t_lock); in iscsit_dataout_update_r2t()
505 struct iscsi_pdu *pdu = cmd->pdu_ptr; in iscsit_dataout_update_datapduinorder_no()
507 pdu->data_sn = data_sn; in iscsit_dataout_update_datapduinorder_no()
509 switch (pdu->status) { in iscsit_dataout_update_datapduinorder_no()
511 pdu->status = ISCSI_PDU_RECEIVED_OK; in iscsit_dataout_update_datapduinorder_no()
514 pdu->status = ISCSI_PDU_RECEIVED_OK; in iscsit_dataout_update_datapduinorder_no()
517 pdu->status = ISCSI_PDU_RECEIVED_OK; in iscsit_dataout_update_datapduinorder_no()
537 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_post_crc_passed()
540 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_post_crc_passed()
542 if (cmd->unsolicited_data) { in iscsit_dataout_post_crc_passed()
543 if ((cmd->first_burst_len + payload_length) == in iscsit_dataout_post_crc_passed()
544 conn->sess->sess_ops->FirstBurstLength) { in iscsit_dataout_post_crc_passed()
545 if (iscsit_dataout_update_r2t(cmd, be32_to_cpu(hdr->offset), in iscsit_dataout_post_crc_passed()
551 if (!conn->sess->sess_ops->DataPDUInOrder) { in iscsit_dataout_post_crc_passed()
553 be32_to_cpu(hdr->datasn), in iscsit_dataout_post_crc_passed()
554 (hdr->flags & ISCSI_FLAG_CMD_FINAL)); in iscsit_dataout_post_crc_passed()
559 cmd->first_burst_len += payload_length; in iscsit_dataout_post_crc_passed()
561 if (conn->sess->sess_ops->DataSequenceInOrder) in iscsit_dataout_post_crc_passed()
562 cmd->data_sn++; in iscsit_dataout_post_crc_passed()
564 seq = cmd->seq_ptr; in iscsit_dataout_post_crc_passed()
565 seq->data_sn++; in iscsit_dataout_post_crc_passed()
566 seq->offset += payload_length; in iscsit_dataout_post_crc_passed()
571 seq->status = DATAOUT_SEQUENCE_COMPLETE; in iscsit_dataout_post_crc_passed()
572 cmd->first_burst_len = 0; in iscsit_dataout_post_crc_passed()
573 cmd->unsolicited_data = 0; in iscsit_dataout_post_crc_passed()
576 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_dataout_post_crc_passed()
577 if ((cmd->next_burst_len + payload_length) == in iscsit_dataout_post_crc_passed()
578 conn->sess->sess_ops->MaxBurstLength) { in iscsit_dataout_post_crc_passed()
580 be32_to_cpu(hdr->offset), in iscsit_dataout_post_crc_passed()
586 if (!conn->sess->sess_ops->DataPDUInOrder) { in iscsit_dataout_post_crc_passed()
588 cmd, be32_to_cpu(hdr->datasn), in iscsit_dataout_post_crc_passed()
589 (hdr->flags & ISCSI_FLAG_CMD_FINAL)); in iscsit_dataout_post_crc_passed()
594 cmd->next_burst_len += payload_length; in iscsit_dataout_post_crc_passed()
595 cmd->data_sn++; in iscsit_dataout_post_crc_passed()
598 cmd->next_burst_len = 0; in iscsit_dataout_post_crc_passed()
600 seq = cmd->seq_ptr; in iscsit_dataout_post_crc_passed()
602 if ((seq->next_burst_len + payload_length) == in iscsit_dataout_post_crc_passed()
603 seq->xfer_len) { in iscsit_dataout_post_crc_passed()
605 be32_to_cpu(hdr->offset), in iscsit_dataout_post_crc_passed()
611 if (!conn->sess->sess_ops->DataPDUInOrder) { in iscsit_dataout_post_crc_passed()
613 cmd, be32_to_cpu(hdr->datasn), in iscsit_dataout_post_crc_passed()
614 (hdr->flags & ISCSI_FLAG_CMD_FINAL)); in iscsit_dataout_post_crc_passed()
619 seq->data_sn++; in iscsit_dataout_post_crc_passed()
620 seq->offset += payload_length; in iscsit_dataout_post_crc_passed()
621 seq->next_burst_len += payload_length; in iscsit_dataout_post_crc_passed()
624 seq->next_burst_len = 0; in iscsit_dataout_post_crc_passed()
625 seq->status = DATAOUT_SEQUENCE_COMPLETE; in iscsit_dataout_post_crc_passed()
630 if (send_r2t && conn->sess->sess_ops->DataSequenceInOrder) in iscsit_dataout_post_crc_passed()
631 cmd->data_sn = 0; in iscsit_dataout_post_crc_passed()
633 cmd->write_data_done += payload_length; in iscsit_dataout_post_crc_passed()
635 if (cmd->write_data_done == cmd->se_cmd.data_length) in iscsit_dataout_post_crc_passed()
647 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_post_crc_failed()
650 u32 payload_length = ntoh24(hdr->dlength); in iscsit_dataout_post_crc_failed()
652 if (conn->sess->sess_ops->DataPDUInOrder) in iscsit_dataout_post_crc_failed()
657 pdu = cmd->pdu_ptr; in iscsit_dataout_post_crc_failed()
659 switch (pdu->status) { in iscsit_dataout_post_crc_failed()
661 pdu->status = ISCSI_PDU_CRC_FAILED; in iscsit_dataout_post_crc_failed()
666 pdu->status = ISCSI_PDU_CRC_FAILED; in iscsit_dataout_post_crc_failed()
673 return iscsit_recover_dataout_sequence(cmd, be32_to_cpu(hdr->offset), in iscsit_dataout_post_crc_failed()
686 struct iscsi_conn *conn = cmd->conn; in iscsit_check_pre_dataout()
698 if (cmd->unsolicited_data) { in iscsit_check_pre_dataout()
710 return (conn->sess->sess_ops->DataPDUInOrder) ? in iscsit_check_pre_dataout()
724 struct iscsi_conn *conn = cmd->conn; in iscsit_check_post_dataout()
726 cmd->dataout_timeout_retries = 0; in iscsit_check_post_dataout()
731 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_check_post_dataout()
747 struct iscsi_portal_group *tpg = sess->tpg; in iscsit_handle_time2retain_timeout()
748 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; in iscsit_handle_time2retain_timeout()
750 spin_lock_bh(&se_tpg->session_lock); in iscsit_handle_time2retain_timeout()
751 if (sess->time2retain_timer_flags & ISCSI_TF_STOP) { in iscsit_handle_time2retain_timeout()
752 spin_unlock_bh(&se_tpg->session_lock); in iscsit_handle_time2retain_timeout()
755 if (atomic_read(&sess->session_reinstatement)) { in iscsit_handle_time2retain_timeout()
758 spin_unlock_bh(&se_tpg->session_lock); in iscsit_handle_time2retain_timeout()
761 sess->time2retain_timer_flags |= ISCSI_TF_EXPIRED; in iscsit_handle_time2retain_timeout()
764 " iSCSI session.\n", sess->sid); in iscsit_handle_time2retain_timeout()
767 spin_unlock_bh(&se_tpg->session_lock); in iscsit_handle_time2retain_timeout()
778 spin_lock(&sess->tpg->tpg_state_lock); in iscsit_start_time2retain_handler()
779 tpg_active = (sess->tpg->tpg_state == TPG_STATE_ACTIVE); in iscsit_start_time2retain_handler()
780 spin_unlock(&sess->tpg->tpg_state_lock); in iscsit_start_time2retain_handler()
785 if (sess->time2retain_timer_flags & ISCSI_TF_RUNNING) in iscsit_start_time2retain_handler()
789 " SID: %u\n", sess->sess_ops->DefaultTime2Retain, sess->sid); in iscsit_start_time2retain_handler()
791 sess->time2retain_timer_flags &= ~ISCSI_TF_STOP; in iscsit_start_time2retain_handler()
792 sess->time2retain_timer_flags |= ISCSI_TF_RUNNING; in iscsit_start_time2retain_handler()
793 mod_timer(&sess->time2retain_timer, in iscsit_start_time2retain_handler()
794 jiffies + sess->sess_ops->DefaultTime2Retain * HZ); in iscsit_start_time2retain_handler()
799 struct iscsi_portal_group *tpg = sess->tpg; in iscsit_stop_time2retain_timer()
800 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; in iscsit_stop_time2retain_timer()
802 lockdep_assert_held(&se_tpg->session_lock); in iscsit_stop_time2retain_timer()
804 if (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED) in iscsit_stop_time2retain_timer()
805 return -1; in iscsit_stop_time2retain_timer()
807 if (!(sess->time2retain_timer_flags & ISCSI_TF_RUNNING)) in iscsit_stop_time2retain_timer()
810 sess->time2retain_timer_flags |= ISCSI_TF_STOP; in iscsit_stop_time2retain_timer()
811 spin_unlock(&se_tpg->session_lock); in iscsit_stop_time2retain_timer()
813 del_timer_sync(&sess->time2retain_timer); in iscsit_stop_time2retain_timer()
815 spin_lock(&se_tpg->session_lock); in iscsit_stop_time2retain_timer()
816 sess->time2retain_timer_flags &= ~ISCSI_TF_RUNNING; in iscsit_stop_time2retain_timer()
818 sess->sid); in iscsit_stop_time2retain_timer()
824 spin_lock_bh(&conn->state_lock); in iscsit_connection_reinstatement_rcfr()
825 if (atomic_read(&conn->connection_exit)) { in iscsit_connection_reinstatement_rcfr()
826 spin_unlock_bh(&conn->state_lock); in iscsit_connection_reinstatement_rcfr()
830 if (atomic_read(&conn->transport_failed)) { in iscsit_connection_reinstatement_rcfr()
831 spin_unlock_bh(&conn->state_lock); in iscsit_connection_reinstatement_rcfr()
834 spin_unlock_bh(&conn->state_lock); in iscsit_connection_reinstatement_rcfr()
836 if (conn->tx_thread && conn->tx_thread_active) in iscsit_connection_reinstatement_rcfr()
837 send_sig(SIGINT, conn->tx_thread, 1); in iscsit_connection_reinstatement_rcfr()
838 if (conn->rx_thread && conn->rx_thread_active) in iscsit_connection_reinstatement_rcfr()
839 send_sig(SIGINT, conn->rx_thread, 1); in iscsit_connection_reinstatement_rcfr()
842 wait_for_completion(&conn->conn_wait_rcfr_comp); in iscsit_connection_reinstatement_rcfr()
843 complete(&conn->conn_post_wait_comp); in iscsit_connection_reinstatement_rcfr()
848 spin_lock_bh(&conn->state_lock); in iscsit_cause_connection_reinstatement()
849 if (atomic_read(&conn->connection_exit)) { in iscsit_cause_connection_reinstatement()
850 spin_unlock_bh(&conn->state_lock); in iscsit_cause_connection_reinstatement()
854 if (atomic_read(&conn->transport_failed)) { in iscsit_cause_connection_reinstatement()
855 spin_unlock_bh(&conn->state_lock); in iscsit_cause_connection_reinstatement()
859 if (atomic_read(&conn->connection_reinstatement)) { in iscsit_cause_connection_reinstatement()
860 spin_unlock_bh(&conn->state_lock); in iscsit_cause_connection_reinstatement()
864 if (conn->tx_thread && conn->tx_thread_active) in iscsit_cause_connection_reinstatement()
865 send_sig(SIGINT, conn->tx_thread, 1); in iscsit_cause_connection_reinstatement()
866 if (conn->rx_thread && conn->rx_thread_active) in iscsit_cause_connection_reinstatement()
867 send_sig(SIGINT, conn->rx_thread, 1); in iscsit_cause_connection_reinstatement()
869 atomic_set(&conn->connection_reinstatement, 1); in iscsit_cause_connection_reinstatement()
871 spin_unlock_bh(&conn->state_lock); in iscsit_cause_connection_reinstatement()
875 atomic_set(&conn->sleep_on_conn_wait_comp, 1); in iscsit_cause_connection_reinstatement()
876 spin_unlock_bh(&conn->state_lock); in iscsit_cause_connection_reinstatement()
878 wait_for_completion(&conn->conn_wait_comp); in iscsit_cause_connection_reinstatement()
879 complete(&conn->conn_post_wait_comp); in iscsit_cause_connection_reinstatement()
886 " %u\n", sess->sid); in iscsit_fall_back_to_erl0()
888 atomic_set(&sess->session_fall_back_to_erl0, 1); in iscsit_fall_back_to_erl0()
893 struct iscsi_session *sess = conn->sess; in iscsit_handle_connection_cleanup()
895 if ((sess->sess_ops->ErrorRecoveryLevel == 2) && in iscsit_handle_connection_cleanup()
896 !atomic_read(&sess->session_reinstatement) && in iscsit_handle_connection_cleanup()
897 !atomic_read(&sess->session_fall_back_to_erl0)) in iscsit_handle_connection_cleanup()
901 " Connection ID: %hu from %s\n", conn->cid, in iscsit_handle_connection_cleanup()
902 sess->sess_ops->InitiatorName); in iscsit_handle_connection_cleanup()
911 spin_lock_bh(&conn->state_lock); in iscsit_take_action_for_connection_exit()
912 if (atomic_read(&conn->connection_exit)) { in iscsit_take_action_for_connection_exit()
913 spin_unlock_bh(&conn->state_lock); in iscsit_take_action_for_connection_exit()
916 atomic_set(&conn->connection_exit, 1); in iscsit_take_action_for_connection_exit()
918 if (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT) { in iscsit_take_action_for_connection_exit()
919 spin_unlock_bh(&conn->state_lock); in iscsit_take_action_for_connection_exit()
925 if (conn->conn_state == TARG_CONN_STATE_CLEANUP_WAIT) { in iscsit_take_action_for_connection_exit()
926 spin_unlock_bh(&conn->state_lock); in iscsit_take_action_for_connection_exit()
931 conn->conn_state = TARG_CONN_STATE_CLEANUP_WAIT; in iscsit_take_action_for_connection_exit()
932 spin_unlock_bh(&conn->state_lock); in iscsit_take_action_for_connection_exit()