libiscsi.c (46a84c6516fa09bb8e4cc0c7998ccd4cb5e876a1) libiscsi.c (55e51eda4820ec5a1c1fc8693a51029f74eac2b9)
1/*
2 * iSCSI lib functions
3 *
4 * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
5 * Copyright (C) 2004 - 2006 Mike Christie
6 * Copyright (C) 2004 - 2005 Dmitry Yusupov
7 * Copyright (C) 2004 - 2005 Alex Aizman
8 * maintained by open-iscsi@googlegroups.com

--- 96 unchanged lines hidden (view full) ---

105 if (iscsi_sna_lt(max_cmdsn, exp_cmdsn - 1))
106 return;
107
108 if (exp_cmdsn != session->exp_cmdsn &&
109 !iscsi_sna_lt(exp_cmdsn, session->exp_cmdsn))
110 session->exp_cmdsn = exp_cmdsn;
111
112 if (max_cmdsn != session->max_cmdsn &&
1/*
2 * iSCSI lib functions
3 *
4 * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
5 * Copyright (C) 2004 - 2006 Mike Christie
6 * Copyright (C) 2004 - 2005 Dmitry Yusupov
7 * Copyright (C) 2004 - 2005 Alex Aizman
8 * maintained by open-iscsi@googlegroups.com

--- 96 unchanged lines hidden (view full) ---

105 if (iscsi_sna_lt(max_cmdsn, exp_cmdsn - 1))
106 return;
107
108 if (exp_cmdsn != session->exp_cmdsn &&
109 !iscsi_sna_lt(exp_cmdsn, session->exp_cmdsn))
110 session->exp_cmdsn = exp_cmdsn;
111
112 if (max_cmdsn != session->max_cmdsn &&
113 !iscsi_sna_lt(max_cmdsn, session->max_cmdsn))
113 !iscsi_sna_lt(max_cmdsn, session->max_cmdsn)) {
114 session->max_cmdsn = max_cmdsn;
114 session->max_cmdsn = max_cmdsn;
115 /*
116 * if the window closed with IO queued, then kick the
117 * xmit thread
118 */
119 if (!list_empty(&session->leadconn->cmdqueue) ||
120 !list_empty(&session->leadconn->mgmtqueue))
121 iscsi_conn_queue_work(session->leadconn);
122 }
115}
116
117void iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr)
118{
119 __iscsi_update_cmdsn(session, be32_to_cpu(hdr->exp_cmdsn),
120 be32_to_cpu(hdr->max_cmdsn));
121}
122EXPORT_SYMBOL_GPL(iscsi_update_cmdsn);

--- 259 unchanged lines hidden (view full) ---

382
383 task->imm_count = 0;
384 if (scsi_bidi_cmnd(sc)) {
385 hdr->flags |= ISCSI_FLAG_CMD_READ;
386 rc = iscsi_prep_bidi_ahs(task);
387 if (rc)
388 return rc;
389 }
123}
124
125void iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr)
126{
127 __iscsi_update_cmdsn(session, be32_to_cpu(hdr->exp_cmdsn),
128 be32_to_cpu(hdr->max_cmdsn));
129}
130EXPORT_SYMBOL_GPL(iscsi_update_cmdsn);

--- 259 unchanged lines hidden (view full) ---

390
391 task->imm_count = 0;
392 if (scsi_bidi_cmnd(sc)) {
393 hdr->flags |= ISCSI_FLAG_CMD_READ;
394 rc = iscsi_prep_bidi_ahs(task);
395 if (rc)
396 return rc;
397 }
398
399 if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
400 task->protected = true;
401
390 if (sc->sc_data_direction == DMA_TO_DEVICE) {
391 unsigned out_len = scsi_out(sc)->length;
392 struct iscsi_r2t_info *r2t = &task->unsol_r2t;
393
394 hdr->data_length = cpu_to_be32(out_len);
395 hdr->flags |= ISCSI_FLAG_CMD_WRITE;
396 /*
397 * Write counters:

--- 70 unchanged lines hidden (view full) ---

468 session->max_cmdsn - session->exp_cmdsn + 1);
469 return 0;
470}
471
472/**
473 * iscsi_free_task - free a task
474 * @task: iscsi cmd task
475 *
402 if (sc->sc_data_direction == DMA_TO_DEVICE) {
403 unsigned out_len = scsi_out(sc)->length;
404 struct iscsi_r2t_info *r2t = &task->unsol_r2t;
405
406 hdr->data_length = cpu_to_be32(out_len);
407 hdr->flags |= ISCSI_FLAG_CMD_WRITE;
408 /*
409 * Write counters:

--- 70 unchanged lines hidden (view full) ---

480 session->max_cmdsn - session->exp_cmdsn + 1);
481 return 0;
482}
483
484/**
485 * iscsi_free_task - free a task
486 * @task: iscsi cmd task
487 *
476 * Must be called with session back_lock.
488 * Must be called with session lock.
477 * This function returns the scsi command to scsi-ml or cleans
478 * up mgmt tasks then returns the task to the pool.
479 */
480static void iscsi_free_task(struct iscsi_task *task)
481{
482 struct iscsi_conn *conn = task->conn;
483 struct iscsi_session *session = conn->session;
484 struct scsi_cmnd *sc = task->sc;

--- 37 unchanged lines hidden (view full) ---

522 iscsi_free_task(task);
523}
524EXPORT_SYMBOL_GPL(__iscsi_put_task);
525
526void iscsi_put_task(struct iscsi_task *task)
527{
528 struct iscsi_session *session = task->conn->session;
529
489 * This function returns the scsi command to scsi-ml or cleans
490 * up mgmt tasks then returns the task to the pool.
491 */
492static void iscsi_free_task(struct iscsi_task *task)
493{
494 struct iscsi_conn *conn = task->conn;
495 struct iscsi_session *session = conn->session;
496 struct scsi_cmnd *sc = task->sc;

--- 37 unchanged lines hidden (view full) ---

534 iscsi_free_task(task);
535}
536EXPORT_SYMBOL_GPL(__iscsi_put_task);
537
538void iscsi_put_task(struct iscsi_task *task)
539{
540 struct iscsi_session *session = task->conn->session;
541
530 /* regular RX path uses back_lock */
531 spin_lock_bh(&session->back_lock);
542 spin_lock_bh(&session->lock);
532 __iscsi_put_task(task);
543 __iscsi_put_task(task);
533 spin_unlock_bh(&session->back_lock);
544 spin_unlock_bh(&session->lock);
534}
535EXPORT_SYMBOL_GPL(iscsi_put_task);
536
537/**
538 * iscsi_complete_task - finish a task
539 * @task: iscsi cmd task
540 * @state: state to complete task with
541 *
545}
546EXPORT_SYMBOL_GPL(iscsi_put_task);
547
548/**
549 * iscsi_complete_task - finish a task
550 * @task: iscsi cmd task
551 * @state: state to complete task with
552 *
542 * Must be called with session back_lock.
553 * Must be called with session lock.
543 */
544static void iscsi_complete_task(struct iscsi_task *task, int state)
545{
546 struct iscsi_conn *conn = task->conn;
547
548 ISCSI_DBG_SESSION(conn->session,
549 "complete task itt 0x%x state %d sc %p\n",
550 task->itt, task->state, task->sc);

--- 22 unchanged lines hidden (view full) ---

573 * iscsi_complete_scsi_task - finish scsi task normally
574 * @task: iscsi task for scsi cmd
575 * @exp_cmdsn: expected cmd sn in cpu format
576 * @max_cmdsn: max cmd sn in cpu format
577 *
578 * This is used when drivers do not need or cannot perform
579 * lower level pdu processing.
580 *
554 */
555static void iscsi_complete_task(struct iscsi_task *task, int state)
556{
557 struct iscsi_conn *conn = task->conn;
558
559 ISCSI_DBG_SESSION(conn->session,
560 "complete task itt 0x%x state %d sc %p\n",
561 task->itt, task->state, task->sc);

--- 22 unchanged lines hidden (view full) ---

584 * iscsi_complete_scsi_task - finish scsi task normally
585 * @task: iscsi task for scsi cmd
586 * @exp_cmdsn: expected cmd sn in cpu format
587 * @max_cmdsn: max cmd sn in cpu format
588 *
589 * This is used when drivers do not need or cannot perform
590 * lower level pdu processing.
591 *
581 * Called with session back_lock
592 * Called with session lock
582 */
583void iscsi_complete_scsi_task(struct iscsi_task *task,
584 uint32_t exp_cmdsn, uint32_t max_cmdsn)
585{
586 struct iscsi_conn *conn = task->conn;
587
588 ISCSI_DBG_SESSION(conn->session, "[itt 0x%x]\n", task->itt);
589
590 conn->last_recv = jiffies;
591 __iscsi_update_cmdsn(conn->session, exp_cmdsn, max_cmdsn);
592 iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
593}
594EXPORT_SYMBOL_GPL(iscsi_complete_scsi_task);
595
596
597/*
593 */
594void iscsi_complete_scsi_task(struct iscsi_task *task,
595 uint32_t exp_cmdsn, uint32_t max_cmdsn)
596{
597 struct iscsi_conn *conn = task->conn;
598
599 ISCSI_DBG_SESSION(conn->session, "[itt 0x%x]\n", task->itt);
600
601 conn->last_recv = jiffies;
602 __iscsi_update_cmdsn(conn->session, exp_cmdsn, max_cmdsn);
603 iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
604}
605EXPORT_SYMBOL_GPL(iscsi_complete_scsi_task);
606
607
608/*
598 * session back_lock must be held and if not called for a task that is
609 * session lock must be held and if not called for a task that is
599 * still pending or from the xmit thread, then xmit thread must
600 * be suspended.
601 */
602static void fail_scsi_task(struct iscsi_task *task, int err)
603{
604 struct iscsi_conn *conn = task->conn;
605 struct scsi_cmnd *sc;
606 int state;

--- 23 unchanged lines hidden (view full) ---

630 sc->result = err << 16;
631 if (!scsi_bidi_cmnd(sc))
632 scsi_set_resid(sc, scsi_bufflen(sc));
633 else {
634 scsi_out(sc)->resid = scsi_out(sc)->length;
635 scsi_in(sc)->resid = scsi_in(sc)->length;
636 }
637
610 * still pending or from the xmit thread, then xmit thread must
611 * be suspended.
612 */
613static void fail_scsi_task(struct iscsi_task *task, int err)
614{
615 struct iscsi_conn *conn = task->conn;
616 struct scsi_cmnd *sc;
617 int state;

--- 23 unchanged lines hidden (view full) ---

641 sc->result = err << 16;
642 if (!scsi_bidi_cmnd(sc))
643 scsi_set_resid(sc, scsi_bufflen(sc));
644 else {
645 scsi_out(sc)->resid = scsi_out(sc)->length;
646 scsi_in(sc)->resid = scsi_in(sc)->length;
647 }
648
638 /* regular RX path uses back_lock */
639 spin_lock_bh(&conn->session->back_lock);
640 iscsi_complete_task(task, state);
649 iscsi_complete_task(task, state);
641 spin_unlock_bh(&conn->session->back_lock);
642}
643
644static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
645 struct iscsi_task *task)
646{
647 struct iscsi_session *session = conn->session;
648 struct iscsi_hdr *hdr = task->hdr;
649 struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr;

--- 121 unchanged lines hidden (view full) ---

771 } else {
772 list_add_tail(&task->running, &conn->mgmtqueue);
773 iscsi_conn_queue_work(conn);
774 }
775
776 return task;
777
778free_task:
650}
651
652static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
653 struct iscsi_task *task)
654{
655 struct iscsi_session *session = conn->session;
656 struct iscsi_hdr *hdr = task->hdr;
657 struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr;

--- 121 unchanged lines hidden (view full) ---

779 } else {
780 list_add_tail(&task->running, &conn->mgmtqueue);
781 iscsi_conn_queue_work(conn);
782 }
783
784 return task;
785
786free_task:
779 /* regular RX path uses back_lock */
780 spin_lock_bh(&session->back_lock);
781 __iscsi_put_task(task);
787 __iscsi_put_task(task);
782 spin_unlock_bh(&session->back_lock);
783 return NULL;
784}
785
786int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
787 char *data, uint32_t data_size)
788{
789 struct iscsi_conn *conn = cls_conn->dd_data;
790 struct iscsi_session *session = conn->session;
791 int err = 0;
792
788 return NULL;
789}
790
791int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
792 char *data, uint32_t data_size)
793{
794 struct iscsi_conn *conn = cls_conn->dd_data;
795 struct iscsi_session *session = conn->session;
796 int err = 0;
797
793 spin_lock_bh(&session->frwd_lock);
798 spin_lock_bh(&session->lock);
794 if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
795 err = -EPERM;
799 if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
800 err = -EPERM;
796 spin_unlock_bh(&session->frwd_lock);
801 spin_unlock_bh(&session->lock);
797 return err;
798}
799EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);
800
801/**
802 * iscsi_cmd_rsp - SCSI Command Response processing
803 * @conn: iscsi connection
804 * @hdr: iscsi header

--- 12 unchanged lines hidden (view full) ---

817 struct iscsi_session *session = conn->session;
818 struct scsi_cmnd *sc = task->sc;
819
820 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
821 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
822
823 sc->result = (DID_OK << 16) | rhdr->cmd_status;
824
802 return err;
803}
804EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);
805
806/**
807 * iscsi_cmd_rsp - SCSI Command Response processing
808 * @conn: iscsi connection
809 * @hdr: iscsi header

--- 12 unchanged lines hidden (view full) ---

822 struct iscsi_session *session = conn->session;
823 struct scsi_cmnd *sc = task->sc;
824
825 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
826 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
827
828 sc->result = (DID_OK << 16) | rhdr->cmd_status;
829
830 if (task->protected) {
831 sector_t sector;
832 u8 ascq;
833
834 /**
835 * Transports that didn't implement check_protection
836 * callback but still published T10-PI support to scsi-mid
837 * deserve this BUG_ON.
838 **/
839 BUG_ON(!session->tt->check_protection);
840
841 ascq = session->tt->check_protection(task, &sector);
842 if (ascq) {
843 sc->result = DRIVER_SENSE << 24 |
844 SAM_STAT_CHECK_CONDITION;
845 scsi_build_sense_buffer(1, sc->sense_buffer,
846 ILLEGAL_REQUEST, 0x10, ascq);
847 sc->sense_buffer[7] = 0xc; /* Additional sense length */
848 sc->sense_buffer[8] = 0; /* Information desc type */
849 sc->sense_buffer[9] = 0xa; /* Additional desc length */
850 sc->sense_buffer[10] = 0x80; /* Validity bit */
851
852 put_unaligned_be64(sector, &sc->sense_buffer[12]);
853 goto out;
854 }
855 }
856
825 if (rhdr->response != ISCSI_STATUS_CMD_COMPLETED) {
826 sc->result = DID_ERROR << 16;
827 goto out;
828 }
829
830 if (rhdr->cmd_status == SAM_STAT_CHECK_CONDITION) {
831 uint16_t senselen;
832

--- 174 unchanged lines hidden (view full) ---

1007 memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr));
1008 opcode = rejected_pdu.opcode & ISCSI_OPCODE_MASK;
1009
1010 switch (reject->reason) {
1011 case ISCSI_REASON_DATA_DIGEST_ERROR:
1012 iscsi_conn_printk(KERN_ERR, conn,
1013 "pdu (op 0x%x itt 0x%x) rejected "
1014 "due to DataDigest error.\n",
857 if (rhdr->response != ISCSI_STATUS_CMD_COMPLETED) {
858 sc->result = DID_ERROR << 16;
859 goto out;
860 }
861
862 if (rhdr->cmd_status == SAM_STAT_CHECK_CONDITION) {
863 uint16_t senselen;
864

--- 174 unchanged lines hidden (view full) ---

1039 memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr));
1040 opcode = rejected_pdu.opcode & ISCSI_OPCODE_MASK;
1041
1042 switch (reject->reason) {
1043 case ISCSI_REASON_DATA_DIGEST_ERROR:
1044 iscsi_conn_printk(KERN_ERR, conn,
1045 "pdu (op 0x%x itt 0x%x) rejected "
1046 "due to DataDigest error.\n",
1015 opcode, rejected_pdu.itt);
1047 rejected_pdu.itt, opcode);
1016 break;
1017 case ISCSI_REASON_IMM_CMD_REJECT:
1018 iscsi_conn_printk(KERN_ERR, conn,
1019 "pdu (op 0x%x itt 0x%x) rejected. Too many "
1020 "immediate commands.\n",
1048 break;
1049 case ISCSI_REASON_IMM_CMD_REJECT:
1050 iscsi_conn_printk(KERN_ERR, conn,
1051 "pdu (op 0x%x itt 0x%x) rejected. Too many "
1052 "immediate commands.\n",
1021 opcode, rejected_pdu.itt);
1053 rejected_pdu.itt, opcode);
1022 /*
1023 * We only send one TMF at a time so if the target could not
1024 * handle it, then it should get fixed (RFC mandates that
1025 * a target can handle one immediate TMF per conn).
1026 *
1027 * For nops-outs, we could have sent more than one if
1028 * the target is sending us lots of nop-ins
1029 */
1030 if (opcode != ISCSI_OP_NOOP_OUT)
1031 return 0;
1032
1054 /*
1055 * We only send one TMF at a time so if the target could not
1056 * handle it, then it should get fixed (RFC mandates that
1057 * a target can handle one immediate TMF per conn).
1058 *
1059 * For nops-outs, we could have sent more than one if
1060 * the target is sending us lots of nop-ins
1061 */
1062 if (opcode != ISCSI_OP_NOOP_OUT)
1063 return 0;
1064
1033 if (rejected_pdu.itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
1065 if (rejected_pdu.itt == cpu_to_be32(ISCSI_RESERVED_TAG))
1034 /*
1035 * nop-out in response to target's nop-out rejected.
1036 * Just resend.
1037 */
1066 /*
1067 * nop-out in response to target's nop-out rejected.
1068 * Just resend.
1069 */
1038 /* In RX path we are under back lock */
1039 spin_unlock(&conn->session->back_lock);
1040 spin_lock(&conn->session->frwd_lock);
1041 iscsi_send_nopout(conn,
1042 (struct iscsi_nopin*)&rejected_pdu);
1070 iscsi_send_nopout(conn,
1071 (struct iscsi_nopin*)&rejected_pdu);
1043 spin_unlock(&conn->session->frwd_lock);
1044 spin_lock(&conn->session->back_lock);
1045 } else {
1072 else {
1046 struct iscsi_task *task;
1047 /*
1048 * Our nop as ping got dropped. We know the target
1049 * and transport are ok so just clean up
1050 */
1051 task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1052 if (!task) {
1053 iscsi_conn_printk(KERN_ERR, conn,

--- 4 unchanged lines hidden (view full) ---

1058 rc = iscsi_nop_out_rsp(task,
1059 (struct iscsi_nopin*)&rejected_pdu,
1060 NULL, 0);
1061 }
1062 break;
1063 default:
1064 iscsi_conn_printk(KERN_ERR, conn,
1065 "pdu (op 0x%x itt 0x%x) rejected. Reason "
1073 struct iscsi_task *task;
1074 /*
1075 * Our nop as ping got dropped. We know the target
1076 * and transport are ok so just clean up
1077 */
1078 task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1079 if (!task) {
1080 iscsi_conn_printk(KERN_ERR, conn,

--- 4 unchanged lines hidden (view full) ---

1085 rc = iscsi_nop_out_rsp(task,
1086 (struct iscsi_nopin*)&rejected_pdu,
1087 NULL, 0);
1088 }
1089 break;
1090 default:
1091 iscsi_conn_printk(KERN_ERR, conn,
1092 "pdu (op 0x%x itt 0x%x) rejected. Reason "
1066 "code 0x%x\n", rejected_pdu.opcode,
1067 rejected_pdu.itt, reject->reason);
1093 "code 0x%x\n", rejected_pdu.itt,
1094 rejected_pdu.opcode, reject->reason);
1068 break;
1069 }
1070 return rc;
1071}
1072
1073/**
1074 * iscsi_itt_to_task - look up task by itt
1075 * @conn: iscsi connection
1076 * @itt: itt
1077 *
1078 * This should be used for mgmt tasks like login and nops, or if
1079 * the LDD's itt space does not include the session age.
1080 *
1095 break;
1096 }
1097 return rc;
1098}
1099
1100/**
1101 * iscsi_itt_to_task - look up task by itt
1102 * @conn: iscsi connection
1103 * @itt: itt
1104 *
1105 * This should be used for mgmt tasks like login and nops, or if
1106 * the LDD's itt space does not include the session age.
1107 *
1081 * The session back_lock must be held.
1108 * The session lock must be held.
1082 */
1083struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
1084{
1085 struct iscsi_session *session = conn->session;
1086 int i;
1087
1088 if (itt == RESERVED_ITT)
1089 return NULL;

--- 12 unchanged lines hidden (view full) ---

1102/**
1103 * __iscsi_complete_pdu - complete pdu
1104 * @conn: iscsi conn
1105 * @hdr: iscsi header
1106 * @data: data buffer
1107 * @datalen: len of data buffer
1108 *
1109 * Completes pdu processing by freeing any resources allocated at
1109 */
1110struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
1111{
1112 struct iscsi_session *session = conn->session;
1113 int i;
1114
1115 if (itt == RESERVED_ITT)
1116 return NULL;

--- 12 unchanged lines hidden (view full) ---

1129/**
1130 * __iscsi_complete_pdu - complete pdu
1131 * @conn: iscsi conn
1132 * @hdr: iscsi header
1133 * @data: data buffer
1134 * @datalen: len of data buffer
1135 *
1136 * Completes pdu processing by freeing any resources allocated at
1110 * queuecommand or send generic. session back_lock must be held and verify
1137 * queuecommand or send generic. session lock must be held and verify
1111 * itt must have been called.
1112 */
1113int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1114 char *data, int datalen)
1115{
1116 struct iscsi_session *session = conn->session;
1117 int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0;
1118 struct iscsi_task *task;

--- 20 unchanged lines hidden (view full) ---

1139 if (datalen) {
1140 rc = ISCSI_ERR_PROTO;
1141 break;
1142 }
1143
1144 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))
1145 break;
1146
1138 * itt must have been called.
1139 */
1140int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1141 char *data, int datalen)
1142{
1143 struct iscsi_session *session = conn->session;
1144 int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0;
1145 struct iscsi_task *task;

--- 20 unchanged lines hidden (view full) ---

1166 if (datalen) {
1167 rc = ISCSI_ERR_PROTO;
1168 break;
1169 }
1170
1171 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))
1172 break;
1173
1147 /* In RX path we are under back lock */
1148 spin_unlock(&session->back_lock);
1149 spin_lock(&session->frwd_lock);
1150 iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr);
1174 iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr);
1151 spin_unlock(&session->frwd_lock);
1152 spin_lock(&session->back_lock);
1153 break;
1154 case ISCSI_OP_REJECT:
1155 rc = iscsi_handle_reject(conn, hdr, data, datalen);
1156 break;
1157 case ISCSI_OP_ASYNC_EVENT:
1158 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
1159 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
1160 rc = ISCSI_ERR_CONN_FAILED;

--- 90 unchanged lines hidden (view full) ---

1251}
1252EXPORT_SYMBOL_GPL(__iscsi_complete_pdu);
1253
1254int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1255 char *data, int datalen)
1256{
1257 int rc;
1258
1175 break;
1176 case ISCSI_OP_REJECT:
1177 rc = iscsi_handle_reject(conn, hdr, data, datalen);
1178 break;
1179 case ISCSI_OP_ASYNC_EVENT:
1180 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
1181 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
1182 rc = ISCSI_ERR_CONN_FAILED;

--- 90 unchanged lines hidden (view full) ---

1273}
1274EXPORT_SYMBOL_GPL(__iscsi_complete_pdu);
1275
1276int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1277 char *data, int datalen)
1278{
1279 int rc;
1280
1259 spin_lock(&conn->session->back_lock);
1281 spin_lock(&conn->session->lock);
1260 rc = __iscsi_complete_pdu(conn, hdr, data, datalen);
1282 rc = __iscsi_complete_pdu(conn, hdr, data, datalen);
1261 spin_unlock(&conn->session->back_lock);
1283 spin_unlock(&conn->session->lock);
1262 return rc;
1263}
1264EXPORT_SYMBOL_GPL(iscsi_complete_pdu);
1265
1266int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
1267{
1268 struct iscsi_session *session = conn->session;
1269 int age = 0, i = 0;

--- 27 unchanged lines hidden (view full) ---

1297
1298/**
1299 * iscsi_itt_to_ctask - look up ctask by itt
1300 * @conn: iscsi connection
1301 * @itt: itt
1302 *
1303 * This should be used for cmd tasks.
1304 *
1284 return rc;
1285}
1286EXPORT_SYMBOL_GPL(iscsi_complete_pdu);
1287
1288int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
1289{
1290 struct iscsi_session *session = conn->session;
1291 int age = 0, i = 0;

--- 27 unchanged lines hidden (view full) ---

1319
1320/**
1321 * iscsi_itt_to_ctask - look up ctask by itt
1322 * @conn: iscsi connection
1323 * @itt: itt
1324 *
1325 * This should be used for cmd tasks.
1326 *
1305 * The session back_lock must be held.
1327 * The session lock must be held.
1306 */
1307struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt)
1308{
1309 struct iscsi_task *task;
1310
1311 if (iscsi_verify_itt(conn, itt))
1312 return NULL;
1313

--- 13 unchanged lines hidden (view full) ---

1327EXPORT_SYMBOL_GPL(iscsi_itt_to_ctask);
1328
1329void iscsi_session_failure(struct iscsi_session *session,
1330 enum iscsi_err err)
1331{
1332 struct iscsi_conn *conn;
1333 struct device *dev;
1334
1328 */
1329struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt)
1330{
1331 struct iscsi_task *task;
1332
1333 if (iscsi_verify_itt(conn, itt))
1334 return NULL;
1335

--- 13 unchanged lines hidden (view full) ---

1349EXPORT_SYMBOL_GPL(iscsi_itt_to_ctask);
1350
1351void iscsi_session_failure(struct iscsi_session *session,
1352 enum iscsi_err err)
1353{
1354 struct iscsi_conn *conn;
1355 struct device *dev;
1356
1335 spin_lock_bh(&session->frwd_lock);
1357 spin_lock_bh(&session->lock);
1336 conn = session->leadconn;
1337 if (session->state == ISCSI_STATE_TERMINATE || !conn) {
1358 conn = session->leadconn;
1359 if (session->state == ISCSI_STATE_TERMINATE || !conn) {
1338 spin_unlock_bh(&session->frwd_lock);
1360 spin_unlock_bh(&session->lock);
1339 return;
1340 }
1341
1342 dev = get_device(&conn->cls_conn->dev);
1361 return;
1362 }
1363
1364 dev = get_device(&conn->cls_conn->dev);
1343 spin_unlock_bh(&session->frwd_lock);
1365 spin_unlock_bh(&session->lock);
1344 if (!dev)
1345 return;
1346 /*
1347 * if the host is being removed bypass the connection
1348 * recovery initialization because we are going to kill
1349 * the session.
1350 */
1351 if (err == ISCSI_ERR_INVALID_HOST)
1352 iscsi_conn_error_event(conn->cls_conn, err);
1353 else
1354 iscsi_conn_failure(conn, err);
1355 put_device(dev);
1356}
1357EXPORT_SYMBOL_GPL(iscsi_session_failure);
1358
1359void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
1360{
1361 struct iscsi_session *session = conn->session;
1362
1366 if (!dev)
1367 return;
1368 /*
1369 * if the host is being removed bypass the connection
1370 * recovery initialization because we are going to kill
1371 * the session.
1372 */
1373 if (err == ISCSI_ERR_INVALID_HOST)
1374 iscsi_conn_error_event(conn->cls_conn, err);
1375 else
1376 iscsi_conn_failure(conn, err);
1377 put_device(dev);
1378}
1379EXPORT_SYMBOL_GPL(iscsi_session_failure);
1380
1381void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
1382{
1383 struct iscsi_session *session = conn->session;
1384
1363 spin_lock_bh(&session->frwd_lock);
1385 spin_lock_bh(&session->lock);
1364 if (session->state == ISCSI_STATE_FAILED) {
1386 if (session->state == ISCSI_STATE_FAILED) {
1365 spin_unlock_bh(&session->frwd_lock);
1387 spin_unlock_bh(&session->lock);
1366 return;
1367 }
1368
1369 if (conn->stop_stage == 0)
1370 session->state = ISCSI_STATE_FAILED;
1388 return;
1389 }
1390
1391 if (conn->stop_stage == 0)
1392 session->state = ISCSI_STATE_FAILED;
1371 spin_unlock_bh(&session->frwd_lock);
1393 spin_unlock_bh(&session->lock);
1372
1373 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1374 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
1375 iscsi_conn_error_event(conn->cls_conn, err);
1376}
1377EXPORT_SYMBOL_GPL(iscsi_conn_failure);
1378
1379static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn)

--- 17 unchanged lines hidden (view full) ---

1397{
1398 struct iscsi_task *task = conn->task;
1399 int rc;
1400
1401 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx))
1402 return -ENODATA;
1403
1404 __iscsi_get_task(task);
1394
1395 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1396 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
1397 iscsi_conn_error_event(conn->cls_conn, err);
1398}
1399EXPORT_SYMBOL_GPL(iscsi_conn_failure);
1400
1401static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn)

--- 17 unchanged lines hidden (view full) ---

1419{
1420 struct iscsi_task *task = conn->task;
1421 int rc;
1422
1423 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx))
1424 return -ENODATA;
1425
1426 __iscsi_get_task(task);
1405 spin_unlock_bh(&conn->session->frwd_lock);
1427 spin_unlock_bh(&conn->session->lock);
1406 rc = conn->session->tt->xmit_task(task);
1428 rc = conn->session->tt->xmit_task(task);
1407 spin_lock_bh(&conn->session->frwd_lock);
1429 spin_lock_bh(&conn->session->lock);
1408 if (!rc) {
1409 /* done with this task */
1410 task->last_xfer = jiffies;
1411 conn->task = NULL;
1412 }
1430 if (!rc) {
1431 /* done with this task */
1432 task->last_xfer = jiffies;
1433 conn->task = NULL;
1434 }
1413 /* regular RX path uses back_lock */
1414 spin_lock_bh(&conn->session->back_lock);
1415 __iscsi_put_task(task);
1435 __iscsi_put_task(task);
1416 spin_unlock_bh(&conn->session->back_lock);
1417 return rc;
1418}
1419
1420/**
1421 * iscsi_requeue_task - requeue task to run from session workqueue
1422 * @task: task to requeue
1423 *
1424 * LLDs that need to run a task from the session workqueue should call
1436 return rc;
1437}
1438
1439/**
1440 * iscsi_requeue_task - requeue task to run from session workqueue
1441 * @task: task to requeue
1442 *
1443 * LLDs that need to run a task from the session workqueue should call
1425 * this. The session frwd_lock must be held. This should only be called
1444 * this. The session lock must be held. This should only be called
1426 * by software drivers.
1427 */
1428void iscsi_requeue_task(struct iscsi_task *task)
1429{
1430 struct iscsi_conn *conn = task->conn;
1431
1432 /*
1433 * this may be on the requeue list already if the xmit_task callout

--- 14 unchanged lines hidden (view full) ---

1448 * re-schedule it again later or recover. '0' return code means
1449 * successful xmit.
1450 **/
1451static int iscsi_data_xmit(struct iscsi_conn *conn)
1452{
1453 struct iscsi_task *task;
1454 int rc = 0;
1455
1445 * by software drivers.
1446 */
1447void iscsi_requeue_task(struct iscsi_task *task)
1448{
1449 struct iscsi_conn *conn = task->conn;
1450
1451 /*
1452 * this may be on the requeue list already if the xmit_task callout

--- 14 unchanged lines hidden (view full) ---

1467 * re-schedule it again later or recover. '0' return code means
1468 * successful xmit.
1469 **/
1470static int iscsi_data_xmit(struct iscsi_conn *conn)
1471{
1472 struct iscsi_task *task;
1473 int rc = 0;
1474
1456 spin_lock_bh(&conn->session->frwd_lock);
1475 spin_lock_bh(&conn->session->lock);
1457 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
1458 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n");
1476 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
1477 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n");
1459 spin_unlock_bh(&conn->session->frwd_lock);
1478 spin_unlock_bh(&conn->session->lock);
1460 return -ENODATA;
1461 }
1462
1463 if (conn->task) {
1464 rc = iscsi_xmit_task(conn);
1465 if (rc)
1466 goto done;
1467 }

--- 4 unchanged lines hidden (view full) ---

1472 * overflow us with nop-ins
1473 */
1474check_mgmt:
1475 while (!list_empty(&conn->mgmtqueue)) {
1476 conn->task = list_entry(conn->mgmtqueue.next,
1477 struct iscsi_task, running);
1478 list_del_init(&conn->task->running);
1479 if (iscsi_prep_mgmt_task(conn, conn->task)) {
1479 return -ENODATA;
1480 }
1481
1482 if (conn->task) {
1483 rc = iscsi_xmit_task(conn);
1484 if (rc)
1485 goto done;
1486 }

--- 4 unchanged lines hidden (view full) ---

1491 * overflow us with nop-ins
1492 */
1493check_mgmt:
1494 while (!list_empty(&conn->mgmtqueue)) {
1495 conn->task = list_entry(conn->mgmtqueue.next,
1496 struct iscsi_task, running);
1497 list_del_init(&conn->task->running);
1498 if (iscsi_prep_mgmt_task(conn, conn->task)) {
1480 /* regular RX path uses back_lock */
1481 spin_lock_bh(&conn->session->back_lock);
1482 __iscsi_put_task(conn->task);
1499 __iscsi_put_task(conn->task);
1483 spin_unlock_bh(&conn->session->back_lock);
1484 conn->task = NULL;
1485 continue;
1486 }
1487 rc = iscsi_xmit_task(conn);
1488 if (rc)
1489 goto done;
1490 }
1491

--- 45 unchanged lines hidden (view full) ---

1537 list_del_init(&conn->task->running);
1538 conn->task->state = ISCSI_TASK_RUNNING;
1539 rc = iscsi_xmit_task(conn);
1540 if (rc)
1541 goto done;
1542 if (!list_empty(&conn->mgmtqueue))
1543 goto check_mgmt;
1544 }
1500 conn->task = NULL;
1501 continue;
1502 }
1503 rc = iscsi_xmit_task(conn);
1504 if (rc)
1505 goto done;
1506 }
1507

--- 45 unchanged lines hidden (view full) ---

1553 list_del_init(&conn->task->running);
1554 conn->task->state = ISCSI_TASK_RUNNING;
1555 rc = iscsi_xmit_task(conn);
1556 if (rc)
1557 goto done;
1558 if (!list_empty(&conn->mgmtqueue))
1559 goto check_mgmt;
1560 }
1545 spin_unlock_bh(&conn->session->frwd_lock);
1561 spin_unlock_bh(&conn->session->lock);
1546 return -ENODATA;
1547
1548done:
1562 return -ENODATA;
1563
1564done:
1549 spin_unlock_bh(&conn->session->frwd_lock);
1565 spin_unlock_bh(&conn->session->lock);
1550 return rc;
1551}
1552
1553static void iscsi_xmitworker(struct work_struct *work)
1554{
1555 struct iscsi_conn *conn =
1556 container_of(work, struct iscsi_conn, xmitwork);
1557 int rc;

--- 19 unchanged lines hidden (view full) ---

1577
1578 atomic_set(&task->refcount, 1);
1579 task->state = ISCSI_TASK_PENDING;
1580 task->conn = conn;
1581 task->sc = sc;
1582 task->have_checked_conn = false;
1583 task->last_timeout = jiffies;
1584 task->last_xfer = jiffies;
1566 return rc;
1567}
1568
1569static void iscsi_xmitworker(struct work_struct *work)
1570{
1571 struct iscsi_conn *conn =
1572 container_of(work, struct iscsi_conn, xmitwork);
1573 int rc;

--- 19 unchanged lines hidden (view full) ---

1593
1594 atomic_set(&task->refcount, 1);
1595 task->state = ISCSI_TASK_PENDING;
1596 task->conn = conn;
1597 task->sc = sc;
1598 task->have_checked_conn = false;
1599 task->last_timeout = jiffies;
1600 task->last_xfer = jiffies;
1601 task->protected = false;
1585 INIT_LIST_HEAD(&task->running);
1586 return task;
1587}
1588
1589enum {
1590 FAILURE_BAD_HOST = 1,
1591 FAILURE_SESSION_FAILED,
1592 FAILURE_SESSION_FREED,

--- 17 unchanged lines hidden (view full) ---

1610
1611 sc->result = 0;
1612 sc->SCp.ptr = NULL;
1613
1614 ihost = shost_priv(host);
1615
1616 cls_session = starget_to_session(scsi_target(sc->device));
1617 session = cls_session->dd_data;
1602 INIT_LIST_HEAD(&task->running);
1603 return task;
1604}
1605
1606enum {
1607 FAILURE_BAD_HOST = 1,
1608 FAILURE_SESSION_FAILED,
1609 FAILURE_SESSION_FREED,

--- 17 unchanged lines hidden (view full) ---

1627
1628 sc->result = 0;
1629 sc->SCp.ptr = NULL;
1630
1631 ihost = shost_priv(host);
1632
1633 cls_session = starget_to_session(scsi_target(sc->device));
1634 session = cls_session->dd_data;
1618 spin_lock_bh(&session->frwd_lock);
1635 spin_lock_bh(&session->lock);
1619
1620 reason = iscsi_session_chkready(cls_session);
1621 if (reason) {
1622 sc->result = reason;
1623 goto fault;
1624 }
1625
1626 if (session->state != ISCSI_STATE_LOGGED_IN) {

--- 69 unchanged lines hidden (view full) ---

1696 goto prepd_reject;
1697 }
1698 } else {
1699 list_add_tail(&task->running, &conn->cmdqueue);
1700 iscsi_conn_queue_work(conn);
1701 }
1702
1703 session->queued_cmdsn++;
1636
1637 reason = iscsi_session_chkready(cls_session);
1638 if (reason) {
1639 sc->result = reason;
1640 goto fault;
1641 }
1642
1643 if (session->state != ISCSI_STATE_LOGGED_IN) {

--- 69 unchanged lines hidden (view full) ---

1713 goto prepd_reject;
1714 }
1715 } else {
1716 list_add_tail(&task->running, &conn->cmdqueue);
1717 iscsi_conn_queue_work(conn);
1718 }
1719
1720 session->queued_cmdsn++;
1704 spin_unlock_bh(&session->frwd_lock);
1721 spin_unlock_bh(&session->lock);
1705 return 0;
1706
1707prepd_reject:
1708 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ);
1709reject:
1722 return 0;
1723
1724prepd_reject:
1725 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ);
1726reject:
1710 spin_unlock_bh(&session->frwd_lock);
1727 spin_unlock_bh(&session->lock);
1711 ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n",
1712 sc->cmnd[0], reason);
1713 return SCSI_MLQUEUE_TARGET_BUSY;
1714
1715prepd_fault:
1716 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ);
1717fault:
1728 ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n",
1729 sc->cmnd[0], reason);
1730 return SCSI_MLQUEUE_TARGET_BUSY;
1731
1732prepd_fault:
1733 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ);
1734fault:
1718 spin_unlock_bh(&session->frwd_lock);
1735 spin_unlock_bh(&session->lock);
1719 ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n",
1720 sc->cmnd[0], reason);
1721 if (!scsi_bidi_cmnd(sc))
1722 scsi_set_resid(sc, scsi_bufflen(sc));
1723 else {
1724 scsi_out(sc)->resid = scsi_out(sc)->length;
1725 scsi_in(sc)->resid = scsi_in(sc)->length;
1726 }

--- 31 unchanged lines hidden (view full) ---

1758}
1759EXPORT_SYMBOL_GPL(iscsi_target_alloc);
1760
1761static void iscsi_tmf_timedout(unsigned long data)
1762{
1763 struct iscsi_conn *conn = (struct iscsi_conn *)data;
1764 struct iscsi_session *session = conn->session;
1765
1736 ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n",
1737 sc->cmnd[0], reason);
1738 if (!scsi_bidi_cmnd(sc))
1739 scsi_set_resid(sc, scsi_bufflen(sc));
1740 else {
1741 scsi_out(sc)->resid = scsi_out(sc)->length;
1742 scsi_in(sc)->resid = scsi_in(sc)->length;
1743 }

--- 31 unchanged lines hidden (view full) ---

1775}
1776EXPORT_SYMBOL_GPL(iscsi_target_alloc);
1777
1778static void iscsi_tmf_timedout(unsigned long data)
1779{
1780 struct iscsi_conn *conn = (struct iscsi_conn *)data;
1781 struct iscsi_session *session = conn->session;
1782
1766 spin_lock(&session->frwd_lock);
1783 spin_lock(&session->lock);
1767 if (conn->tmf_state == TMF_QUEUED) {
1768 conn->tmf_state = TMF_TIMEDOUT;
1769 ISCSI_DBG_EH(session, "tmf timedout\n");
1770 /* unblock eh_abort() */
1771 wake_up(&conn->ehwait);
1772 }
1784 if (conn->tmf_state == TMF_QUEUED) {
1785 conn->tmf_state = TMF_TIMEDOUT;
1786 ISCSI_DBG_EH(session, "tmf timedout\n");
1787 /* unblock eh_abort() */
1788 wake_up(&conn->ehwait);
1789 }
1773 spin_unlock(&session->frwd_lock);
1790 spin_unlock(&session->lock);
1774}
1775
1776static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
1777 struct iscsi_tm *hdr, int age,
1778 int timeout)
1779{
1780 struct iscsi_session *session = conn->session;
1781 struct iscsi_task *task;
1782
1783 task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
1784 NULL, 0);
1785 if (!task) {
1791}
1792
1793static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
1794 struct iscsi_tm *hdr, int age,
1795 int timeout)
1796{
1797 struct iscsi_session *session = conn->session;
1798 struct iscsi_task *task;
1799
1800 task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
1801 NULL, 0);
1802 if (!task) {
1786 spin_unlock_bh(&session->frwd_lock);
1803 spin_unlock_bh(&session->lock);
1787 iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n");
1788 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1804 iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n");
1805 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1789 spin_lock_bh(&session->frwd_lock);
1806 spin_lock_bh(&session->lock);
1790 return -EPERM;
1791 }
1792 conn->tmfcmd_pdus_cnt++;
1793 conn->tmf_timer.expires = timeout * HZ + jiffies;
1794 conn->tmf_timer.function = iscsi_tmf_timedout;
1795 conn->tmf_timer.data = (unsigned long)conn;
1796 add_timer(&conn->tmf_timer);
1797 ISCSI_DBG_EH(session, "tmf set timeout\n");
1798
1807 return -EPERM;
1808 }
1809 conn->tmfcmd_pdus_cnt++;
1810 conn->tmf_timer.expires = timeout * HZ + jiffies;
1811 conn->tmf_timer.function = iscsi_tmf_timedout;
1812 conn->tmf_timer.data = (unsigned long)conn;
1813 add_timer(&conn->tmf_timer);
1814 ISCSI_DBG_EH(session, "tmf set timeout\n");
1815
1799 spin_unlock_bh(&session->frwd_lock);
1816 spin_unlock_bh(&session->lock);
1800 mutex_unlock(&session->eh_mutex);
1801
1802 /*
1803 * block eh thread until:
1804 *
1805 * 1) tmf response
1806 * 2) tmf timeout
1807 * 3) session is terminated or restarted or userspace has
1808 * given up on recovery
1809 */
1810 wait_event_interruptible(conn->ehwait, age != session->age ||
1811 session->state != ISCSI_STATE_LOGGED_IN ||
1812 conn->tmf_state != TMF_QUEUED);
1813 if (signal_pending(current))
1814 flush_signals(current);
1815 del_timer_sync(&conn->tmf_timer);
1816
1817 mutex_lock(&session->eh_mutex);
1817 mutex_unlock(&session->eh_mutex);
1818
1819 /*
1820 * block eh thread until:
1821 *
1822 * 1) tmf response
1823 * 2) tmf timeout
1824 * 3) session is terminated or restarted or userspace has
1825 * given up on recovery
1826 */
1827 wait_event_interruptible(conn->ehwait, age != session->age ||
1828 session->state != ISCSI_STATE_LOGGED_IN ||
1829 conn->tmf_state != TMF_QUEUED);
1830 if (signal_pending(current))
1831 flush_signals(current);
1832 del_timer_sync(&conn->tmf_timer);
1833
1834 mutex_lock(&session->eh_mutex);
1818 spin_lock_bh(&session->frwd_lock);
1835 spin_lock_bh(&session->lock);
1819 /* if the session drops it will clean up the task */
1820 if (age != session->age ||
1821 session->state != ISCSI_STATE_LOGGED_IN)
1822 return -ENOTCONN;
1823 return 0;
1824}
1825
1826/*

--- 20 unchanged lines hidden (view full) ---

1847 fail_scsi_task(task, error);
1848 }
1849}
1850
1851/**
1852 * iscsi_suspend_queue - suspend iscsi_queuecommand
1853 * @conn: iscsi conn to stop queueing IO on
1854 *
1836 /* if the session drops it will clean up the task */
1837 if (age != session->age ||
1838 session->state != ISCSI_STATE_LOGGED_IN)
1839 return -ENOTCONN;
1840 return 0;
1841}
1842
1843/*

--- 20 unchanged lines hidden (view full) ---

1864 fail_scsi_task(task, error);
1865 }
1866}
1867
1868/**
1869 * iscsi_suspend_queue - suspend iscsi_queuecommand
1870 * @conn: iscsi conn to stop queueing IO on
1871 *
1855 * This grabs the session frwd_lock to make sure no one is in
1872 * This grabs the session lock to make sure no one is in
1856 * xmit_task/queuecommand, and then sets suspend to prevent
1857 * new commands from being queued. This only needs to be called
1858 * by offload drivers that need to sync a path like ep disconnect
1859 * with the iscsi_queuecommand/xmit_task. To start IO again libiscsi
1860 * will call iscsi_start_tx and iscsi_unblock_session when in FFP.
1861 */
1862void iscsi_suspend_queue(struct iscsi_conn *conn)
1863{
1873 * xmit_task/queuecommand, and then sets suspend to prevent
1874 * new commands from being queued. This only needs to be called
1875 * by offload drivers that need to sync a path like ep disconnect
1876 * with the iscsi_queuecommand/xmit_task. To start IO again libiscsi
1877 * will call iscsi_start_tx and iscsi_unblock_session when in FFP.
1878 */
1879void iscsi_suspend_queue(struct iscsi_conn *conn)
1880{
1864 spin_lock_bh(&conn->session->frwd_lock);
1881 spin_lock_bh(&conn->session->lock);
1865 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1882 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1866 spin_unlock_bh(&conn->session->frwd_lock);
1883 spin_unlock_bh(&conn->session->lock);
1867}
1868EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
1869
1870/**
1871 * iscsi_suspend_tx - suspend iscsi_data_xmit
1872 * @conn: iscsi conn tp stop processing IO on.
1873 *
1874 * This function sets the suspend bit to prevent iscsi_data_xmit

--- 42 unchanged lines hidden (view full) ---

1917 struct iscsi_conn *conn;
1918 int i;
1919
1920 cls_session = starget_to_session(scsi_target(sc->device));
1921 session = cls_session->dd_data;
1922
1923 ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc);
1924
1884}
1885EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
1886
1887/**
1888 * iscsi_suspend_tx - suspend iscsi_data_xmit
1889 * @conn: iscsi conn tp stop processing IO on.
1890 *
1891 * This function sets the suspend bit to prevent iscsi_data_xmit

--- 42 unchanged lines hidden (view full) ---

1934 struct iscsi_conn *conn;
1935 int i;
1936
1937 cls_session = starget_to_session(scsi_target(sc->device));
1938 session = cls_session->dd_data;
1939
1940 ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc);
1941
1925 spin_lock(&session->frwd_lock);
1942 spin_lock(&session->lock);
1926 task = (struct iscsi_task *)sc->SCp.ptr;
1927 if (!task) {
1928 /*
1929 * Raced with completion. Blk layer has taken ownership
1930 * so let timeout code complete it now.
1931 */
1932 rc = BLK_EH_HANDLED;
1933 goto done;

--- 97 unchanged lines hidden (view full) ---

2031 /* Make sure there is a transport check done */
2032 iscsi_send_nopout(conn, NULL);
2033 task->have_checked_conn = true;
2034 rc = BLK_EH_RESET_TIMER;
2035
2036done:
2037 if (task)
2038 task->last_timeout = jiffies;
1943 task = (struct iscsi_task *)sc->SCp.ptr;
1944 if (!task) {
1945 /*
1946 * Raced with completion. Blk layer has taken ownership
1947 * so let timeout code complete it now.
1948 */
1949 rc = BLK_EH_HANDLED;
1950 goto done;

--- 97 unchanged lines hidden (view full) ---

2048 /* Make sure there is a transport check done */
2049 iscsi_send_nopout(conn, NULL);
2050 task->have_checked_conn = true;
2051 rc = BLK_EH_RESET_TIMER;
2052
2053done:
2054 if (task)
2055 task->last_timeout = jiffies;
2039 spin_unlock(&session->frwd_lock);
2056 spin_unlock(&session->lock);
2040 ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
2041 "timer reset" : "nh");
2042 return rc;
2043}
2044
2045static void iscsi_check_transport_timeouts(unsigned long data)
2046{
2047 struct iscsi_conn *conn = (struct iscsi_conn *)data;
2048 struct iscsi_session *session = conn->session;
2049 unsigned long recv_timeout, next_timeout = 0, last_recv;
2050
2057 ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
2058 "timer reset" : "nh");
2059 return rc;
2060}
2061
2062static void iscsi_check_transport_timeouts(unsigned long data)
2063{
2064 struct iscsi_conn *conn = (struct iscsi_conn *)data;
2065 struct iscsi_session *session = conn->session;
2066 unsigned long recv_timeout, next_timeout = 0, last_recv;
2067
2051 spin_lock(&session->frwd_lock);
2068 spin_lock(&session->lock);
2052 if (session->state != ISCSI_STATE_LOGGED_IN)
2053 goto done;
2054
2055 recv_timeout = conn->recv_timeout;
2056 if (!recv_timeout)
2057 goto done;
2058
2059 recv_timeout *= HZ;
2060 last_recv = conn->last_recv;
2061
2062 if (iscsi_has_ping_timed_out(conn)) {
2063 iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
2064 "expired, recv timeout %d, last rx %lu, "
2065 "last ping %lu, now %lu\n",
2066 conn->ping_timeout, conn->recv_timeout,
2067 last_recv, conn->last_ping, jiffies);
2069 if (session->state != ISCSI_STATE_LOGGED_IN)
2070 goto done;
2071
2072 recv_timeout = conn->recv_timeout;
2073 if (!recv_timeout)
2074 goto done;
2075
2076 recv_timeout *= HZ;
2077 last_recv = conn->last_recv;
2078
2079 if (iscsi_has_ping_timed_out(conn)) {
2080 iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
2081 "expired, recv timeout %d, last rx %lu, "
2082 "last ping %lu, now %lu\n",
2083 conn->ping_timeout, conn->recv_timeout,
2084 last_recv, conn->last_ping, jiffies);
2068 spin_unlock(&session->frwd_lock);
2085 spin_unlock(&session->lock);
2069 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
2070 return;
2071 }
2072
2073 if (time_before_eq(last_recv + recv_timeout, jiffies)) {
2074 /* send a ping to try to provoke some traffic */
2075 ISCSI_DBG_CONN(conn, "Sending nopout as ping\n");
2076 iscsi_send_nopout(conn, NULL);
2077 next_timeout = conn->last_ping + (conn->ping_timeout * HZ);
2078 } else
2079 next_timeout = last_recv + recv_timeout;
2080
2081 ISCSI_DBG_CONN(conn, "Setting next tmo %lu\n", next_timeout);
2082 mod_timer(&conn->transport_timer, next_timeout);
2083done:
2086 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
2087 return;
2088 }
2089
2090 if (time_before_eq(last_recv + recv_timeout, jiffies)) {
2091 /* send a ping to try to provoke some traffic */
2092 ISCSI_DBG_CONN(conn, "Sending nopout as ping\n");
2093 iscsi_send_nopout(conn, NULL);
2094 next_timeout = conn->last_ping + (conn->ping_timeout * HZ);
2095 } else
2096 next_timeout = last_recv + recv_timeout;
2097
2098 ISCSI_DBG_CONN(conn, "Setting next tmo %lu\n", next_timeout);
2099 mod_timer(&conn->transport_timer, next_timeout);
2100done:
2084 spin_unlock(&session->frwd_lock);
2101 spin_unlock(&session->lock);
2085}
2086
2087static void iscsi_prep_abort_task_pdu(struct iscsi_task *task,
2088 struct iscsi_tm *hdr)
2089{
2090 memset(hdr, 0, sizeof(*hdr));
2091 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
2092 hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK;

--- 13 unchanged lines hidden (view full) ---

2106 int rc, age;
2107
2108 cls_session = starget_to_session(scsi_target(sc->device));
2109 session = cls_session->dd_data;
2110
2111 ISCSI_DBG_EH(session, "aborting sc %p\n", sc);
2112
2113 mutex_lock(&session->eh_mutex);
2102}
2103
2104static void iscsi_prep_abort_task_pdu(struct iscsi_task *task,
2105 struct iscsi_tm *hdr)
2106{
2107 memset(hdr, 0, sizeof(*hdr));
2108 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
2109 hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK;

--- 13 unchanged lines hidden (view full) ---

2123 int rc, age;
2124
2125 cls_session = starget_to_session(scsi_target(sc->device));
2126 session = cls_session->dd_data;
2127
2128 ISCSI_DBG_EH(session, "aborting sc %p\n", sc);
2129
2130 mutex_lock(&session->eh_mutex);
2114 spin_lock_bh(&session->frwd_lock);
2131 spin_lock_bh(&session->lock);
2115 /*
2116 * if session was ISCSI_STATE_IN_RECOVERY then we may not have
2117 * got the command.
2118 */
2119 if (!sc->SCp.ptr) {
2120 ISCSI_DBG_EH(session, "sc never reached iscsi layer or "
2121 "it completed.\n");
2132 /*
2133 * if session was ISCSI_STATE_IN_RECOVERY then we may not have
2134 * got the command.
2135 */
2136 if (!sc->SCp.ptr) {
2137 ISCSI_DBG_EH(session, "sc never reached iscsi layer or "
2138 "it completed.\n");
2122 spin_unlock_bh(&session->frwd_lock);
2139 spin_unlock_bh(&session->lock);
2123 mutex_unlock(&session->eh_mutex);
2124 return SUCCESS;
2125 }
2126
2127 /*
2128 * If we are not logged in or we have started a new session
2129 * then let the host reset code handle this
2130 */
2131 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN ||
2132 sc->SCp.phase != session->age) {
2140 mutex_unlock(&session->eh_mutex);
2141 return SUCCESS;
2142 }
2143
2144 /*
2145 * If we are not logged in or we have started a new session
2146 * then let the host reset code handle this
2147 */
2148 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN ||
2149 sc->SCp.phase != session->age) {
2133 spin_unlock_bh(&session->frwd_lock);
2150 spin_unlock_bh(&session->lock);
2134 mutex_unlock(&session->eh_mutex);
2135 ISCSI_DBG_EH(session, "failing abort due to dropped "
2136 "session.\n");
2137 return FAILED;
2138 }
2139
2140 conn = session->leadconn;
2141 conn->eh_abort_cnt++;

--- 24 unchanged lines hidden (view full) ---

2166
2167 if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout)) {
2168 rc = FAILED;
2169 goto failed;
2170 }
2171
2172 switch (conn->tmf_state) {
2173 case TMF_SUCCESS:
2151 mutex_unlock(&session->eh_mutex);
2152 ISCSI_DBG_EH(session, "failing abort due to dropped "
2153 "session.\n");
2154 return FAILED;
2155 }
2156
2157 conn = session->leadconn;
2158 conn->eh_abort_cnt++;

--- 24 unchanged lines hidden (view full) ---

2183
2184 if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout)) {
2185 rc = FAILED;
2186 goto failed;
2187 }
2188
2189 switch (conn->tmf_state) {
2190 case TMF_SUCCESS:
2174 spin_unlock_bh(&session->frwd_lock);
2191 spin_unlock_bh(&session->lock);
2175 /*
2176 * stop tx side incase the target had sent a abort rsp but
2177 * the initiator was still writing out data.
2178 */
2179 iscsi_suspend_tx(conn);
2180 /*
2181 * we do not stop the recv side because targets have been
2182 * good and have never sent us a successful tmf response
2183 * then sent more data for the cmd.
2184 */
2192 /*
2193 * stop tx side incase the target had sent a abort rsp but
2194 * the initiator was still writing out data.
2195 */
2196 iscsi_suspend_tx(conn);
2197 /*
2198 * we do not stop the recv side because targets have been
2199 * good and have never sent us a successful tmf response
2200 * then sent more data for the cmd.
2201 */
2185 spin_lock_bh(&session->frwd_lock);
2202 spin_lock_bh(&session->lock);
2186 fail_scsi_task(task, DID_ABORT);
2187 conn->tmf_state = TMF_INITIAL;
2188 memset(hdr, 0, sizeof(*hdr));
2203 fail_scsi_task(task, DID_ABORT);
2204 conn->tmf_state = TMF_INITIAL;
2205 memset(hdr, 0, sizeof(*hdr));
2189 spin_unlock_bh(&session->frwd_lock);
2206 spin_unlock_bh(&session->lock);
2190 iscsi_start_tx(conn);
2191 goto success_unlocked;
2192 case TMF_TIMEDOUT:
2207 iscsi_start_tx(conn);
2208 goto success_unlocked;
2209 case TMF_TIMEDOUT:
2193 spin_unlock_bh(&session->frwd_lock);
2210 spin_unlock_bh(&session->lock);
2194 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2195 goto failed_unlocked;
2196 case TMF_NOT_FOUND:
2197 if (!sc->SCp.ptr) {
2198 conn->tmf_state = TMF_INITIAL;
2199 memset(hdr, 0, sizeof(*hdr));
2200 /* task completed before tmf abort response */
2201 ISCSI_DBG_EH(session, "sc completed while abort in "
2202 "progress\n");
2203 goto success;
2204 }
2205 /* fall through */
2206 default:
2207 conn->tmf_state = TMF_INITIAL;
2208 goto failed;
2209 }
2210
2211success:
2211 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2212 goto failed_unlocked;
2213 case TMF_NOT_FOUND:
2214 if (!sc->SCp.ptr) {
2215 conn->tmf_state = TMF_INITIAL;
2216 memset(hdr, 0, sizeof(*hdr));
2217 /* task completed before tmf abort response */
2218 ISCSI_DBG_EH(session, "sc completed while abort in "
2219 "progress\n");
2220 goto success;
2221 }
2222 /* fall through */
2223 default:
2224 conn->tmf_state = TMF_INITIAL;
2225 goto failed;
2226 }
2227
2228success:
2212 spin_unlock_bh(&session->frwd_lock);
2229 spin_unlock_bh(&session->lock);
2213success_unlocked:
2214 ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n",
2215 sc, task->itt);
2216 mutex_unlock(&session->eh_mutex);
2217 return SUCCESS;
2218
2219failed:
2230success_unlocked:
2231 ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n",
2232 sc, task->itt);
2233 mutex_unlock(&session->eh_mutex);
2234 return SUCCESS;
2235
2236failed:
2220 spin_unlock_bh(&session->frwd_lock);
2237 spin_unlock_bh(&session->lock);
2221failed_unlocked:
2222 ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc,
2223 task ? task->itt : 0);
2224 mutex_unlock(&session->eh_mutex);
2225 return FAILED;
2226}
2227EXPORT_SYMBOL_GPL(iscsi_eh_abort);
2228

--- 16 unchanged lines hidden (view full) ---

2245 int rc = FAILED;
2246
2247 cls_session = starget_to_session(scsi_target(sc->device));
2248 session = cls_session->dd_data;
2249
2250 ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
2251
2252 mutex_lock(&session->eh_mutex);
2238failed_unlocked:
2239 ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc,
2240 task ? task->itt : 0);
2241 mutex_unlock(&session->eh_mutex);
2242 return FAILED;
2243}
2244EXPORT_SYMBOL_GPL(iscsi_eh_abort);
2245

--- 16 unchanged lines hidden (view full) ---

2262 int rc = FAILED;
2263
2264 cls_session = starget_to_session(scsi_target(sc->device));
2265 session = cls_session->dd_data;
2266
2267 ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
2268
2269 mutex_lock(&session->eh_mutex);
2253 spin_lock_bh(&session->frwd_lock);
2270 spin_lock_bh(&session->lock);
2254 /*
2255 * Just check if we are not logged in. We cannot check for
2256 * the phase because the reset could come from a ioctl.
2257 */
2258 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
2259 goto unlock;
2260 conn = session->leadconn;
2261

--- 10 unchanged lines hidden (view full) ---

2272 rc = FAILED;
2273 goto unlock;
2274 }
2275
2276 switch (conn->tmf_state) {
2277 case TMF_SUCCESS:
2278 break;
2279 case TMF_TIMEDOUT:
2271 /*
2272 * Just check if we are not logged in. We cannot check for
2273 * the phase because the reset could come from a ioctl.
2274 */
2275 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
2276 goto unlock;
2277 conn = session->leadconn;
2278

--- 10 unchanged lines hidden (view full) ---

2289 rc = FAILED;
2290 goto unlock;
2291 }
2292
2293 switch (conn->tmf_state) {
2294 case TMF_SUCCESS:
2295 break;
2296 case TMF_TIMEDOUT:
2280 spin_unlock_bh(&session->frwd_lock);
2297 spin_unlock_bh(&session->lock);
2281 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2282 goto done;
2283 default:
2284 conn->tmf_state = TMF_INITIAL;
2285 goto unlock;
2286 }
2287
2288 rc = SUCCESS;
2298 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2299 goto done;
2300 default:
2301 conn->tmf_state = TMF_INITIAL;
2302 goto unlock;
2303 }
2304
2305 rc = SUCCESS;
2289 spin_unlock_bh(&session->frwd_lock);
2306 spin_unlock_bh(&session->lock);
2290
2291 iscsi_suspend_tx(conn);
2292
2307
2308 iscsi_suspend_tx(conn);
2309
2293 spin_lock_bh(&session->frwd_lock);
2310 spin_lock_bh(&session->lock);
2294 memset(hdr, 0, sizeof(*hdr));
2295 fail_scsi_tasks(conn, sc->device->lun, DID_ERROR);
2296 conn->tmf_state = TMF_INITIAL;
2311 memset(hdr, 0, sizeof(*hdr));
2312 fail_scsi_tasks(conn, sc->device->lun, DID_ERROR);
2313 conn->tmf_state = TMF_INITIAL;
2297 spin_unlock_bh(&session->frwd_lock);
2314 spin_unlock_bh(&session->lock);
2298
2299 iscsi_start_tx(conn);
2300 goto done;
2301
2302unlock:
2315
2316 iscsi_start_tx(conn);
2317 goto done;
2318
2319unlock:
2303 spin_unlock_bh(&session->frwd_lock);
2320 spin_unlock_bh(&session->lock);
2304done:
2305 ISCSI_DBG_EH(session, "dev reset result = %s\n",
2306 rc == SUCCESS ? "SUCCESS" : "FAILED");
2307 mutex_unlock(&session->eh_mutex);
2308 return rc;
2309}
2310EXPORT_SYMBOL_GPL(iscsi_eh_device_reset);
2311
2312void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
2313{
2314 struct iscsi_session *session = cls_session->dd_data;
2315
2321done:
2322 ISCSI_DBG_EH(session, "dev reset result = %s\n",
2323 rc == SUCCESS ? "SUCCESS" : "FAILED");
2324 mutex_unlock(&session->eh_mutex);
2325 return rc;
2326}
2327EXPORT_SYMBOL_GPL(iscsi_eh_device_reset);
2328
2329void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
2330{
2331 struct iscsi_session *session = cls_session->dd_data;
2332
2316 spin_lock_bh(&session->frwd_lock);
2333 spin_lock_bh(&session->lock);
2317 if (session->state != ISCSI_STATE_LOGGED_IN) {
2318 session->state = ISCSI_STATE_RECOVERY_FAILED;
2319 if (session->leadconn)
2320 wake_up(&session->leadconn->ehwait);
2321 }
2334 if (session->state != ISCSI_STATE_LOGGED_IN) {
2335 session->state = ISCSI_STATE_RECOVERY_FAILED;
2336 if (session->leadconn)
2337 wake_up(&session->leadconn->ehwait);
2338 }
2322 spin_unlock_bh(&session->frwd_lock);
2339 spin_unlock_bh(&session->lock);
2323}
2324EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout);
2325
2326/**
2327 * iscsi_eh_session_reset - drop session and attempt relogin
2328 * @sc: scsi command
2329 *
2330 * This function will wait for a relogin, session termination from

--- 5 unchanged lines hidden (view full) ---

2336 struct iscsi_session *session;
2337 struct iscsi_conn *conn;
2338
2339 cls_session = starget_to_session(scsi_target(sc->device));
2340 session = cls_session->dd_data;
2341 conn = session->leadconn;
2342
2343 mutex_lock(&session->eh_mutex);
2340}
2341EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout);
2342
2343/**
2344 * iscsi_eh_session_reset - drop session and attempt relogin
2345 * @sc: scsi command
2346 *
2347 * This function will wait for a relogin, session termination from

--- 5 unchanged lines hidden (view full) ---

2353 struct iscsi_session *session;
2354 struct iscsi_conn *conn;
2355
2356 cls_session = starget_to_session(scsi_target(sc->device));
2357 session = cls_session->dd_data;
2358 conn = session->leadconn;
2359
2360 mutex_lock(&session->eh_mutex);
2344 spin_lock_bh(&session->frwd_lock);
2361 spin_lock_bh(&session->lock);
2345 if (session->state == ISCSI_STATE_TERMINATE) {
2346failed:
2347 ISCSI_DBG_EH(session,
2348 "failing session reset: Could not log back into "
2349 "%s, %s [age %d]\n", session->targetname,
2350 conn->persistent_address, session->age);
2362 if (session->state == ISCSI_STATE_TERMINATE) {
2363failed:
2364 ISCSI_DBG_EH(session,
2365 "failing session reset: Could not log back into "
2366 "%s, %s [age %d]\n", session->targetname,
2367 conn->persistent_address, session->age);
2351 spin_unlock_bh(&session->frwd_lock);
2368 spin_unlock_bh(&session->lock);
2352 mutex_unlock(&session->eh_mutex);
2353 return FAILED;
2354 }
2355
2369 mutex_unlock(&session->eh_mutex);
2370 return FAILED;
2371 }
2372
2356 spin_unlock_bh(&session->frwd_lock);
2373 spin_unlock_bh(&session->lock);
2357 mutex_unlock(&session->eh_mutex);
2358 /*
2359 * we drop the lock here but the leadconn cannot be destoyed while
2360 * we are in the scsi eh
2361 */
2362 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2363
2364 ISCSI_DBG_EH(session, "wait for relogin\n");
2365 wait_event_interruptible(conn->ehwait,
2366 session->state == ISCSI_STATE_TERMINATE ||
2367 session->state == ISCSI_STATE_LOGGED_IN ||
2368 session->state == ISCSI_STATE_RECOVERY_FAILED);
2369 if (signal_pending(current))
2370 flush_signals(current);
2371
2372 mutex_lock(&session->eh_mutex);
2374 mutex_unlock(&session->eh_mutex);
2375 /*
2376 * we drop the lock here but the leadconn cannot be destoyed while
2377 * we are in the scsi eh
2378 */
2379 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2380
2381 ISCSI_DBG_EH(session, "wait for relogin\n");
2382 wait_event_interruptible(conn->ehwait,
2383 session->state == ISCSI_STATE_TERMINATE ||
2384 session->state == ISCSI_STATE_LOGGED_IN ||
2385 session->state == ISCSI_STATE_RECOVERY_FAILED);
2386 if (signal_pending(current))
2387 flush_signals(current);
2388
2389 mutex_lock(&session->eh_mutex);
2373 spin_lock_bh(&session->frwd_lock);
2390 spin_lock_bh(&session->lock);
2374 if (session->state == ISCSI_STATE_LOGGED_IN) {
2375 ISCSI_DBG_EH(session,
2376 "session reset succeeded for %s,%s\n",
2377 session->targetname, conn->persistent_address);
2378 } else
2379 goto failed;
2391 if (session->state == ISCSI_STATE_LOGGED_IN) {
2392 ISCSI_DBG_EH(session,
2393 "session reset succeeded for %s,%s\n",
2394 session->targetname, conn->persistent_address);
2395 } else
2396 goto failed;
2380 spin_unlock_bh(&session->frwd_lock);
2397 spin_unlock_bh(&session->lock);
2381 mutex_unlock(&session->eh_mutex);
2382 return SUCCESS;
2383}
2384EXPORT_SYMBOL_GPL(iscsi_eh_session_reset);
2385
2386static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
2387{
2388 memset(hdr, 0, sizeof(*hdr));

--- 19 unchanged lines hidden (view full) ---

2408
2409 cls_session = starget_to_session(scsi_target(sc->device));
2410 session = cls_session->dd_data;
2411
2412 ISCSI_DBG_EH(session, "tgt Reset [sc %p tgt %s]\n", sc,
2413 session->targetname);
2414
2415 mutex_lock(&session->eh_mutex);
2398 mutex_unlock(&session->eh_mutex);
2399 return SUCCESS;
2400}
2401EXPORT_SYMBOL_GPL(iscsi_eh_session_reset);
2402
2403static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
2404{
2405 memset(hdr, 0, sizeof(*hdr));

--- 19 unchanged lines hidden (view full) ---

2425
2426 cls_session = starget_to_session(scsi_target(sc->device));
2427 session = cls_session->dd_data;
2428
2429 ISCSI_DBG_EH(session, "tgt Reset [sc %p tgt %s]\n", sc,
2430 session->targetname);
2431
2432 mutex_lock(&session->eh_mutex);
2416 spin_lock_bh(&session->frwd_lock);
2433 spin_lock_bh(&session->lock);
2417 /*
2418 * Just check if we are not logged in. We cannot check for
2419 * the phase because the reset could come from a ioctl.
2420 */
2421 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
2422 goto unlock;
2423 conn = session->leadconn;
2424

--- 10 unchanged lines hidden (view full) ---

2435 rc = FAILED;
2436 goto unlock;
2437 }
2438
2439 switch (conn->tmf_state) {
2440 case TMF_SUCCESS:
2441 break;
2442 case TMF_TIMEDOUT:
2434 /*
2435 * Just check if we are not logged in. We cannot check for
2436 * the phase because the reset could come from a ioctl.
2437 */
2438 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
2439 goto unlock;
2440 conn = session->leadconn;
2441

--- 10 unchanged lines hidden (view full) ---

2452 rc = FAILED;
2453 goto unlock;
2454 }
2455
2456 switch (conn->tmf_state) {
2457 case TMF_SUCCESS:
2458 break;
2459 case TMF_TIMEDOUT:
2443 spin_unlock_bh(&session->frwd_lock);
2460 spin_unlock_bh(&session->lock);
2444 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2445 goto done;
2446 default:
2447 conn->tmf_state = TMF_INITIAL;
2448 goto unlock;
2449 }
2450
2451 rc = SUCCESS;
2461 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2462 goto done;
2463 default:
2464 conn->tmf_state = TMF_INITIAL;
2465 goto unlock;
2466 }
2467
2468 rc = SUCCESS;
2452 spin_unlock_bh(&session->frwd_lock);
2469 spin_unlock_bh(&session->lock);
2453
2454 iscsi_suspend_tx(conn);
2455
2470
2471 iscsi_suspend_tx(conn);
2472
2456 spin_lock_bh(&session->frwd_lock);
2473 spin_lock_bh(&session->lock);
2457 memset(hdr, 0, sizeof(*hdr));
2458 fail_scsi_tasks(conn, -1, DID_ERROR);
2459 conn->tmf_state = TMF_INITIAL;
2474 memset(hdr, 0, sizeof(*hdr));
2475 fail_scsi_tasks(conn, -1, DID_ERROR);
2476 conn->tmf_state = TMF_INITIAL;
2460 spin_unlock_bh(&session->frwd_lock);
2477 spin_unlock_bh(&session->lock);
2461
2462 iscsi_start_tx(conn);
2463 goto done;
2464
2465unlock:
2478
2479 iscsi_start_tx(conn);
2480 goto done;
2481
2482unlock:
2466 spin_unlock_bh(&session->frwd_lock);
2483 spin_unlock_bh(&session->lock);
2467done:
2468 ISCSI_DBG_EH(session, "tgt %s reset result = %s\n", session->targetname,
2469 rc == SUCCESS ? "SUCCESS" : "FAILED");
2470 mutex_unlock(&session->eh_mutex);
2471 return rc;
2472}
2473EXPORT_SYMBOL_GPL(iscsi_eh_target_reset);
2474

--- 281 unchanged lines hidden (view full) ---

2756 session->scsi_cmds_max = scsi_cmds;
2757 session->cmds_max = total_cmds;
2758 session->queued_cmdsn = session->cmdsn = initial_cmdsn;
2759 session->exp_cmdsn = initial_cmdsn + 1;
2760 session->max_cmdsn = initial_cmdsn + 1;
2761 session->max_r2t = 1;
2762 session->tt = iscsit;
2763 session->dd_data = cls_session->dd_data + sizeof(*session);
2484done:
2485 ISCSI_DBG_EH(session, "tgt %s reset result = %s\n", session->targetname,
2486 rc == SUCCESS ? "SUCCESS" : "FAILED");
2487 mutex_unlock(&session->eh_mutex);
2488 return rc;
2489}
2490EXPORT_SYMBOL_GPL(iscsi_eh_target_reset);
2491

--- 281 unchanged lines hidden (view full) ---

2773 session->scsi_cmds_max = scsi_cmds;
2774 session->cmds_max = total_cmds;
2775 session->queued_cmdsn = session->cmdsn = initial_cmdsn;
2776 session->exp_cmdsn = initial_cmdsn + 1;
2777 session->max_cmdsn = initial_cmdsn + 1;
2778 session->max_r2t = 1;
2779 session->tt = iscsit;
2780 session->dd_data = cls_session->dd_data + sizeof(*session);
2764
2765 mutex_init(&session->eh_mutex);
2781 mutex_init(&session->eh_mutex);
2766 spin_lock_init(&session->frwd_lock);
2767 spin_lock_init(&session->back_lock);
2782 spin_lock_init(&session->lock);
2768
2769 /* initialize SCSI PDU commands pool */
2770 if (iscsi_pool_init(&session->cmdpool, session->cmds_max,
2771 (void***)&session->cmds,
2772 cmd_task_size + sizeof(struct iscsi_task)))
2773 goto cmdpool_alloc_fail;
2774
2775 /* pre-format cmds pool with ITT */

--- 97 unchanged lines hidden (view full) ---

2873 conn->transport_timer.function = iscsi_check_transport_timeouts;
2874
2875 INIT_LIST_HEAD(&conn->mgmtqueue);
2876 INIT_LIST_HEAD(&conn->cmdqueue);
2877 INIT_LIST_HEAD(&conn->requeue);
2878 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
2879
2880 /* allocate login_task used for the login/text sequences */
2783
2784 /* initialize SCSI PDU commands pool */
2785 if (iscsi_pool_init(&session->cmdpool, session->cmds_max,
2786 (void***)&session->cmds,
2787 cmd_task_size + sizeof(struct iscsi_task)))
2788 goto cmdpool_alloc_fail;
2789
2790 /* pre-format cmds pool with ITT */

--- 97 unchanged lines hidden (view full) ---

2888 conn->transport_timer.function = iscsi_check_transport_timeouts;
2889
2890 INIT_LIST_HEAD(&conn->mgmtqueue);
2891 INIT_LIST_HEAD(&conn->cmdqueue);
2892 INIT_LIST_HEAD(&conn->requeue);
2893 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
2894
2895 /* allocate login_task used for the login/text sequences */
2881 spin_lock_bh(&session->frwd_lock);
2896 spin_lock_bh(&session->lock);
2882 if (!kfifo_out(&session->cmdpool.queue,
2883 (void*)&conn->login_task,
2884 sizeof(void*))) {
2897 if (!kfifo_out(&session->cmdpool.queue,
2898 (void*)&conn->login_task,
2899 sizeof(void*))) {
2885 spin_unlock_bh(&session->frwd_lock);
2900 spin_unlock_bh(&session->lock);
2886 goto login_task_alloc_fail;
2887 }
2901 goto login_task_alloc_fail;
2902 }
2888 spin_unlock_bh(&session->frwd_lock);
2903 spin_unlock_bh(&session->lock);
2889
2890 data = (char *) __get_free_pages(GFP_KERNEL,
2891 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
2892 if (!data)
2893 goto login_task_data_alloc_fail;
2894 conn->login_task->data = conn->data = data;
2895
2896 init_timer(&conn->tmf_timer);

--- 20 unchanged lines hidden (view full) ---

2917void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2918{
2919 struct iscsi_conn *conn = cls_conn->dd_data;
2920 struct iscsi_session *session = conn->session;
2921 unsigned long flags;
2922
2923 del_timer_sync(&conn->transport_timer);
2924
2904
2905 data = (char *) __get_free_pages(GFP_KERNEL,
2906 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
2907 if (!data)
2908 goto login_task_data_alloc_fail;
2909 conn->login_task->data = conn->data = data;
2910
2911 init_timer(&conn->tmf_timer);

--- 20 unchanged lines hidden (view full) ---

2932void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2933{
2934 struct iscsi_conn *conn = cls_conn->dd_data;
2935 struct iscsi_session *session = conn->session;
2936 unsigned long flags;
2937
2938 del_timer_sync(&conn->transport_timer);
2939
2925 spin_lock_bh(&session->frwd_lock);
2940 spin_lock_bh(&session->lock);
2926 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
2927 if (session->leadconn == conn) {
2928 /*
2929 * leading connection? then give up on recovery.
2930 */
2931 session->state = ISCSI_STATE_TERMINATE;
2932 wake_up(&conn->ehwait);
2933 }
2941 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
2942 if (session->leadconn == conn) {
2943 /*
2944 * leading connection? then give up on recovery.
2945 */
2946 session->state = ISCSI_STATE_TERMINATE;
2947 wake_up(&conn->ehwait);
2948 }
2934 spin_unlock_bh(&session->frwd_lock);
2949 spin_unlock_bh(&session->lock);
2935
2936 /*
2937 * Block until all in-progress commands for this connection
2938 * time out or fail.
2939 */
2940 for (;;) {
2941 spin_lock_irqsave(session->host->host_lock, flags);
2942 if (!session->host->host_busy) { /* OK for ERL == 0 */

--- 10 unchanged lines hidden (view full) ---

2953 * force eh_abort() to unblock
2954 */
2955 wake_up(&conn->ehwait);
2956 }
2957
2958 /* flush queued up work because we free the connection below */
2959 iscsi_suspend_tx(conn);
2960
2950
2951 /*
2952 * Block until all in-progress commands for this connection
2953 * time out or fail.
2954 */
2955 for (;;) {
2956 spin_lock_irqsave(session->host->host_lock, flags);
2957 if (!session->host->host_busy) { /* OK for ERL == 0 */

--- 10 unchanged lines hidden (view full) ---

2968 * force eh_abort() to unblock
2969 */
2970 wake_up(&conn->ehwait);
2971 }
2972
2973 /* flush queued up work because we free the connection below */
2974 iscsi_suspend_tx(conn);
2975
2961 spin_lock_bh(&session->frwd_lock);
2976 spin_lock_bh(&session->lock);
2962 free_pages((unsigned long) conn->data,
2963 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
2964 kfree(conn->persistent_address);
2965 kfree(conn->local_ipaddr);
2977 free_pages((unsigned long) conn->data,
2978 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
2979 kfree(conn->persistent_address);
2980 kfree(conn->local_ipaddr);
2966 /* regular RX path uses back_lock */
2967 spin_lock_bh(&session->back_lock);
2968 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
2969 sizeof(void*));
2981 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
2982 sizeof(void*));
2970 spin_unlock_bh(&session->back_lock);
2971 if (session->leadconn == conn)
2972 session->leadconn = NULL;
2983 if (session->leadconn == conn)
2984 session->leadconn = NULL;
2973 spin_unlock_bh(&session->frwd_lock);
2985 spin_unlock_bh(&session->lock);
2974
2975 iscsi_destroy_conn(cls_conn);
2976}
2977EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
2978
2979int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
2980{
2981 struct iscsi_conn *conn = cls_conn->dd_data;

--- 20 unchanged lines hidden (view full) ---

3002 }
3003
3004 if (conn->recv_timeout && !conn->ping_timeout) {
3005 iscsi_conn_printk(KERN_ERR, conn, "invalid ping timeout of "
3006 "zero. Using 5 seconds.\n");
3007 conn->ping_timeout = 5;
3008 }
3009
2986
2987 iscsi_destroy_conn(cls_conn);
2988}
2989EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
2990
2991int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
2992{
2993 struct iscsi_conn *conn = cls_conn->dd_data;

--- 20 unchanged lines hidden (view full) ---

3014 }
3015
3016 if (conn->recv_timeout && !conn->ping_timeout) {
3017 iscsi_conn_printk(KERN_ERR, conn, "invalid ping timeout of "
3018 "zero. Using 5 seconds.\n");
3019 conn->ping_timeout = 5;
3020 }
3021
3010 spin_lock_bh(&session->frwd_lock);
3022 spin_lock_bh(&session->lock);
3011 conn->c_stage = ISCSI_CONN_STARTED;
3012 session->state = ISCSI_STATE_LOGGED_IN;
3013 session->queued_cmdsn = session->cmdsn;
3014
3015 conn->last_recv = jiffies;
3016 conn->last_ping = jiffies;
3017 if (conn->recv_timeout && conn->ping_timeout)
3018 mod_timer(&conn->transport_timer,

--- 12 unchanged lines hidden (view full) ---

3031 session->age = 0;
3032 break;
3033 case STOP_CONN_TERM:
3034 conn->stop_stage = 0;
3035 break;
3036 default:
3037 break;
3038 }
3023 conn->c_stage = ISCSI_CONN_STARTED;
3024 session->state = ISCSI_STATE_LOGGED_IN;
3025 session->queued_cmdsn = session->cmdsn;
3026
3027 conn->last_recv = jiffies;
3028 conn->last_ping = jiffies;
3029 if (conn->recv_timeout && conn->ping_timeout)
3030 mod_timer(&conn->transport_timer,

--- 12 unchanged lines hidden (view full) ---

3043 session->age = 0;
3044 break;
3045 case STOP_CONN_TERM:
3046 conn->stop_stage = 0;
3047 break;
3048 default:
3049 break;
3050 }
3039 spin_unlock_bh(&session->frwd_lock);
3051 spin_unlock_bh(&session->lock);
3040
3041 iscsi_unblock_session(session->cls_session);
3042 wake_up(&conn->ehwait);
3043 return 0;
3044}
3045EXPORT_SYMBOL_GPL(iscsi_conn_start);
3046
3047static void

--- 22 unchanged lines hidden (view full) ---

3070}
3071
3072static void iscsi_start_session_recovery(struct iscsi_session *session,
3073 struct iscsi_conn *conn, int flag)
3074{
3075 int old_stop_stage;
3076
3077 mutex_lock(&session->eh_mutex);
3052
3053 iscsi_unblock_session(session->cls_session);
3054 wake_up(&conn->ehwait);
3055 return 0;
3056}
3057EXPORT_SYMBOL_GPL(iscsi_conn_start);
3058
3059static void

--- 22 unchanged lines hidden (view full) ---

3082}
3083
3084static void iscsi_start_session_recovery(struct iscsi_session *session,
3085 struct iscsi_conn *conn, int flag)
3086{
3087 int old_stop_stage;
3088
3089 mutex_lock(&session->eh_mutex);
3078 spin_lock_bh(&session->frwd_lock);
3090 spin_lock_bh(&session->lock);
3079 if (conn->stop_stage == STOP_CONN_TERM) {
3091 if (conn->stop_stage == STOP_CONN_TERM) {
3080 spin_unlock_bh(&session->frwd_lock);
3092 spin_unlock_bh(&session->lock);
3081 mutex_unlock(&session->eh_mutex);
3082 return;
3083 }
3084
3085 /*
3086 * When this is called for the in_login state, we only want to clean
3087 * up the login task and connection. We do not need to block and set
3088 * the recovery state again
3089 */
3090 if (flag == STOP_CONN_TERM)
3091 session->state = ISCSI_STATE_TERMINATE;
3092 else if (conn->stop_stage != STOP_CONN_RECOVER)
3093 session->state = ISCSI_STATE_IN_RECOVERY;
3094
3095 old_stop_stage = conn->stop_stage;
3096 conn->stop_stage = flag;
3093 mutex_unlock(&session->eh_mutex);
3094 return;
3095 }
3096
3097 /*
3098 * When this is called for the in_login state, we only want to clean
3099 * up the login task and connection. We do not need to block and set
3100 * the recovery state again
3101 */
3102 if (flag == STOP_CONN_TERM)
3103 session->state = ISCSI_STATE_TERMINATE;
3104 else if (conn->stop_stage != STOP_CONN_RECOVER)
3105 session->state = ISCSI_STATE_IN_RECOVERY;
3106
3107 old_stop_stage = conn->stop_stage;
3108 conn->stop_stage = flag;
3097 spin_unlock_bh(&session->frwd_lock);
3109 spin_unlock_bh(&session->lock);
3098
3099 del_timer_sync(&conn->transport_timer);
3100 iscsi_suspend_tx(conn);
3101
3110
3111 del_timer_sync(&conn->transport_timer);
3112 iscsi_suspend_tx(conn);
3113
3102 spin_lock_bh(&session->frwd_lock);
3114 spin_lock_bh(&session->lock);
3103 conn->c_stage = ISCSI_CONN_STOPPED;
3115 conn->c_stage = ISCSI_CONN_STOPPED;
3104 spin_unlock_bh(&session->frwd_lock);
3116 spin_unlock_bh(&session->lock);
3105
3106 /*
3107 * for connection level recovery we should not calculate
3108 * header digest. conn->hdr_size used for optimization
3109 * in hdr_extract() and will be re-negotiated at
3110 * set_param() time.
3111 */
3112 if (flag == STOP_CONN_RECOVER) {

--- 4 unchanged lines hidden (view full) ---

3117 ISCSI_DBG_SESSION(session, "blocking session\n");
3118 iscsi_block_session(session->cls_session);
3119 }
3120 }
3121
3122 /*
3123 * flush queues.
3124 */
3117
3118 /*
3119 * for connection level recovery we should not calculate
3120 * header digest. conn->hdr_size used for optimization
3121 * in hdr_extract() and will be re-negotiated at
3122 * set_param() time.
3123 */
3124 if (flag == STOP_CONN_RECOVER) {

--- 4 unchanged lines hidden (view full) ---

3129 ISCSI_DBG_SESSION(session, "blocking session\n");
3130 iscsi_block_session(session->cls_session);
3131 }
3132 }
3133
3134 /*
3135 * flush queues.
3136 */
3125 spin_lock_bh(&session->frwd_lock);
3137 spin_lock_bh(&session->lock);
3126 fail_scsi_tasks(conn, -1, DID_TRANSPORT_DISRUPTED);
3127 fail_mgmt_tasks(session, conn);
3128 memset(&conn->tmhdr, 0, sizeof(conn->tmhdr));
3138 fail_scsi_tasks(conn, -1, DID_TRANSPORT_DISRUPTED);
3139 fail_mgmt_tasks(session, conn);
3140 memset(&conn->tmhdr, 0, sizeof(conn->tmhdr));
3129 spin_unlock_bh(&session->frwd_lock);
3141 spin_unlock_bh(&session->lock);
3130 mutex_unlock(&session->eh_mutex);
3131}
3132
3133void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
3134{
3135 struct iscsi_conn *conn = cls_conn->dd_data;
3136 struct iscsi_session *session = conn->session;
3137

--- 10 unchanged lines hidden (view full) ---

3148EXPORT_SYMBOL_GPL(iscsi_conn_stop);
3149
3150int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
3151 struct iscsi_cls_conn *cls_conn, int is_leading)
3152{
3153 struct iscsi_session *session = cls_session->dd_data;
3154 struct iscsi_conn *conn = cls_conn->dd_data;
3155
3142 mutex_unlock(&session->eh_mutex);
3143}
3144
3145void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
3146{
3147 struct iscsi_conn *conn = cls_conn->dd_data;
3148 struct iscsi_session *session = conn->session;
3149

--- 10 unchanged lines hidden (view full) ---

3160EXPORT_SYMBOL_GPL(iscsi_conn_stop);
3161
3162int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
3163 struct iscsi_cls_conn *cls_conn, int is_leading)
3164{
3165 struct iscsi_session *session = cls_session->dd_data;
3166 struct iscsi_conn *conn = cls_conn->dd_data;
3167
3156 spin_lock_bh(&session->frwd_lock);
3168 spin_lock_bh(&session->lock);
3157 if (is_leading)
3158 session->leadconn = conn;
3169 if (is_leading)
3170 session->leadconn = conn;
3159 spin_unlock_bh(&session->frwd_lock);
3171 spin_unlock_bh(&session->lock);
3160
3161 /*
3162 * Unblock xmitworker(), Login Phase will pass through.
3163 */
3164 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
3165 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
3166 return 0;
3167}

--- 458 unchanged lines hidden ---
3172
3173 /*
3174 * Unblock xmitworker(), Login Phase will pass through.
3175 */
3176 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
3177 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
3178 return 0;
3179}

--- 458 unchanged lines hidden ---