diff options
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r-- | drivers/scsi/libiscsi.c | 137 |
1 files changed, 74 insertions, 63 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 553168ae44f1..59f8445eab0d 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -160,7 +160,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | |||
160 | hdr->opcode = ISCSI_OP_SCSI_CMD; | 160 | hdr->opcode = ISCSI_OP_SCSI_CMD; |
161 | hdr->flags = ISCSI_ATTR_SIMPLE; | 161 | hdr->flags = ISCSI_ATTR_SIMPLE; |
162 | int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); | 162 | int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); |
163 | hdr->itt = build_itt(ctask->itt, conn->id, session->age); | 163 | hdr->itt = build_itt(ctask->itt, session->age); |
164 | hdr->data_length = cpu_to_be32(scsi_bufflen(sc)); | 164 | hdr->data_length = cpu_to_be32(scsi_bufflen(sc)); |
165 | hdr->cmdsn = cpu_to_be32(session->cmdsn); | 165 | hdr->cmdsn = cpu_to_be32(session->cmdsn); |
166 | session->cmdsn++; | 166 | session->cmdsn++; |
@@ -416,8 +416,9 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
416 | 416 | ||
417 | if (datalen < 2) { | 417 | if (datalen < 2) { |
418 | invalid_datalen: | 418 | invalid_datalen: |
419 | printk(KERN_ERR "iscsi: Got CHECK_CONDITION but " | 419 | iscsi_conn_printk(KERN_ERR, conn, |
420 | "invalid data buffer size of %d\n", datalen); | 420 | "Got CHECK_CONDITION but invalid data " |
421 | "buffer size of %d\n", datalen); | ||
421 | sc->result = DID_BAD_TARGET << 16; | 422 | sc->result = DID_BAD_TARGET << 16; |
422 | goto out; | 423 | goto out; |
423 | } | 424 | } |
@@ -494,7 +495,7 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) | |||
494 | 495 | ||
495 | mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0); | 496 | mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0); |
496 | if (!mtask) { | 497 | if (!mtask) { |
497 | printk(KERN_ERR "Could not send nopout\n"); | 498 | iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n"); |
498 | return; | 499 | return; |
499 | } | 500 | } |
500 | 501 | ||
@@ -522,9 +523,10 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
522 | if (ntoh24(reject->dlength) >= sizeof(struct iscsi_hdr)) { | 523 | if (ntoh24(reject->dlength) >= sizeof(struct iscsi_hdr)) { |
523 | memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr)); | 524 | memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr)); |
524 | itt = get_itt(rejected_pdu.itt); | 525 | itt = get_itt(rejected_pdu.itt); |
525 | printk(KERN_ERR "itt 0x%x had pdu (op 0x%x) rejected " | 526 | iscsi_conn_printk(KERN_ERR, conn, |
526 | "due to DataDigest error.\n", itt, | 527 | "itt 0x%x had pdu (op 0x%x) rejected " |
527 | rejected_pdu.opcode); | 528 | "due to DataDigest error.\n", itt, |
529 | rejected_pdu.opcode); | ||
528 | } | 530 | } |
529 | } | 531 | } |
530 | return 0; | 532 | return 0; |
@@ -541,8 +543,8 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
541 | * queuecommand or send generic. session lock must be held and verify | 543 | * queuecommand or send generic. session lock must be held and verify |
542 | * itt must have been called. | 544 | * itt must have been called. |
543 | */ | 545 | */ |
544 | int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | 546 | static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, |
545 | char *data, int datalen) | 547 | char *data, int datalen) |
546 | { | 548 | { |
547 | struct iscsi_session *session = conn->session; | 549 | struct iscsi_session *session = conn->session; |
548 | int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0; | 550 | int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0; |
@@ -672,7 +674,6 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
672 | 674 | ||
673 | return rc; | 675 | return rc; |
674 | } | 676 | } |
675 | EXPORT_SYMBOL_GPL(__iscsi_complete_pdu); | ||
676 | 677 | ||
677 | int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | 678 | int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, |
678 | char *data, int datalen) | 679 | char *data, int datalen) |
@@ -697,18 +698,13 @@ int iscsi_verify_itt(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
697 | if (hdr->itt != RESERVED_ITT) { | 698 | if (hdr->itt != RESERVED_ITT) { |
698 | if (((__force u32)hdr->itt & ISCSI_AGE_MASK) != | 699 | if (((__force u32)hdr->itt & ISCSI_AGE_MASK) != |
699 | (session->age << ISCSI_AGE_SHIFT)) { | 700 | (session->age << ISCSI_AGE_SHIFT)) { |
700 | printk(KERN_ERR "iscsi: received itt %x expected " | 701 | iscsi_conn_printk(KERN_ERR, conn, |
701 | "session age (%x)\n", (__force u32)hdr->itt, | 702 | "received itt %x expected session " |
702 | session->age & ISCSI_AGE_MASK); | 703 | "age (%x)\n", (__force u32)hdr->itt, |
704 | session->age & ISCSI_AGE_MASK); | ||
703 | return ISCSI_ERR_BAD_ITT; | 705 | return ISCSI_ERR_BAD_ITT; |
704 | } | 706 | } |
705 | 707 | ||
706 | if (((__force u32)hdr->itt & ISCSI_CID_MASK) != | ||
707 | (conn->id << ISCSI_CID_SHIFT)) { | ||
708 | printk(KERN_ERR "iscsi: received itt %x, expected " | ||
709 | "CID (%x)\n", (__force u32)hdr->itt, conn->id); | ||
710 | return ISCSI_ERR_BAD_ITT; | ||
711 | } | ||
712 | itt = get_itt(hdr->itt); | 708 | itt = get_itt(hdr->itt); |
713 | } else | 709 | } else |
714 | itt = ~0U; | 710 | itt = ~0U; |
@@ -717,16 +713,17 @@ int iscsi_verify_itt(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
717 | ctask = session->cmds[itt]; | 713 | ctask = session->cmds[itt]; |
718 | 714 | ||
719 | if (!ctask->sc) { | 715 | if (!ctask->sc) { |
720 | printk(KERN_INFO "iscsi: dropping ctask with " | 716 | iscsi_conn_printk(KERN_INFO, conn, "dropping ctask " |
721 | "itt 0x%x\n", ctask->itt); | 717 | "with itt 0x%x\n", ctask->itt); |
722 | /* force drop */ | 718 | /* force drop */ |
723 | return ISCSI_ERR_NO_SCSI_CMD; | 719 | return ISCSI_ERR_NO_SCSI_CMD; |
724 | } | 720 | } |
725 | 721 | ||
726 | if (ctask->sc->SCp.phase != session->age) { | 722 | if (ctask->sc->SCp.phase != session->age) { |
727 | printk(KERN_ERR "iscsi: ctask's session age %d, " | 723 | iscsi_conn_printk(KERN_ERR, conn, |
728 | "expected %d\n", ctask->sc->SCp.phase, | 724 | "iscsi: ctask's session age %d, " |
729 | session->age); | 725 | "expected %d\n", ctask->sc->SCp.phase, |
726 | session->age); | ||
730 | return ISCSI_ERR_SESSION_FAILED; | 727 | return ISCSI_ERR_SESSION_FAILED; |
731 | } | 728 | } |
732 | } | 729 | } |
@@ -771,7 +768,7 @@ static void iscsi_prep_mtask(struct iscsi_conn *conn, | |||
771 | */ | 768 | */ |
772 | nop->cmdsn = cpu_to_be32(session->cmdsn); | 769 | nop->cmdsn = cpu_to_be32(session->cmdsn); |
773 | if (hdr->itt != RESERVED_ITT) { | 770 | if (hdr->itt != RESERVED_ITT) { |
774 | hdr->itt = build_itt(mtask->itt, conn->id, session->age); | 771 | hdr->itt = build_itt(mtask->itt, session->age); |
775 | /* | 772 | /* |
776 | * TODO: We always use immediate, so we never hit this. | 773 | * TODO: We always use immediate, so we never hit this. |
777 | * If we start to send tmfs or nops as non-immediate then | 774 | * If we start to send tmfs or nops as non-immediate then |
@@ -997,6 +994,7 @@ enum { | |||
997 | FAILURE_SESSION_IN_RECOVERY, | 994 | FAILURE_SESSION_IN_RECOVERY, |
998 | FAILURE_SESSION_RECOVERY_TIMEOUT, | 995 | FAILURE_SESSION_RECOVERY_TIMEOUT, |
999 | FAILURE_SESSION_LOGGING_OUT, | 996 | FAILURE_SESSION_LOGGING_OUT, |
997 | FAILURE_SESSION_NOT_READY, | ||
1000 | }; | 998 | }; |
1001 | 999 | ||
1002 | int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | 1000 | int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) |
@@ -1017,6 +1015,12 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | |||
1017 | session = iscsi_hostdata(host->hostdata); | 1015 | session = iscsi_hostdata(host->hostdata); |
1018 | spin_lock(&session->lock); | 1016 | spin_lock(&session->lock); |
1019 | 1017 | ||
1018 | reason = iscsi_session_chkready(session_to_cls(session)); | ||
1019 | if (reason) { | ||
1020 | sc->result = reason; | ||
1021 | goto fault; | ||
1022 | } | ||
1023 | |||
1020 | /* | 1024 | /* |
1021 | * ISCSI_STATE_FAILED is a temp. state. The recovery | 1025 | * ISCSI_STATE_FAILED is a temp. state. The recovery |
1022 | * code will decide what is best to do with command queued | 1026 | * code will decide what is best to do with command queued |
@@ -1033,18 +1037,23 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | |||
1033 | switch (session->state) { | 1037 | switch (session->state) { |
1034 | case ISCSI_STATE_IN_RECOVERY: | 1038 | case ISCSI_STATE_IN_RECOVERY: |
1035 | reason = FAILURE_SESSION_IN_RECOVERY; | 1039 | reason = FAILURE_SESSION_IN_RECOVERY; |
1036 | goto reject; | 1040 | sc->result = DID_IMM_RETRY << 16; |
1041 | break; | ||
1037 | case ISCSI_STATE_LOGGING_OUT: | 1042 | case ISCSI_STATE_LOGGING_OUT: |
1038 | reason = FAILURE_SESSION_LOGGING_OUT; | 1043 | reason = FAILURE_SESSION_LOGGING_OUT; |
1039 | goto reject; | 1044 | sc->result = DID_IMM_RETRY << 16; |
1045 | break; | ||
1040 | case ISCSI_STATE_RECOVERY_FAILED: | 1046 | case ISCSI_STATE_RECOVERY_FAILED: |
1041 | reason = FAILURE_SESSION_RECOVERY_TIMEOUT; | 1047 | reason = FAILURE_SESSION_RECOVERY_TIMEOUT; |
1048 | sc->result = DID_NO_CONNECT << 16; | ||
1042 | break; | 1049 | break; |
1043 | case ISCSI_STATE_TERMINATE: | 1050 | case ISCSI_STATE_TERMINATE: |
1044 | reason = FAILURE_SESSION_TERMINATE; | 1051 | reason = FAILURE_SESSION_TERMINATE; |
1052 | sc->result = DID_NO_CONNECT << 16; | ||
1045 | break; | 1053 | break; |
1046 | default: | 1054 | default: |
1047 | reason = FAILURE_SESSION_FREED; | 1055 | reason = FAILURE_SESSION_FREED; |
1056 | sc->result = DID_NO_CONNECT << 16; | ||
1048 | } | 1057 | } |
1049 | goto fault; | 1058 | goto fault; |
1050 | } | 1059 | } |
@@ -1052,6 +1061,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | |||
1052 | conn = session->leadconn; | 1061 | conn = session->leadconn; |
1053 | if (!conn) { | 1062 | if (!conn) { |
1054 | reason = FAILURE_SESSION_FREED; | 1063 | reason = FAILURE_SESSION_FREED; |
1064 | sc->result = DID_NO_CONNECT << 16; | ||
1055 | goto fault; | 1065 | goto fault; |
1056 | } | 1066 | } |
1057 | 1067 | ||
@@ -1091,9 +1101,7 @@ reject: | |||
1091 | 1101 | ||
1092 | fault: | 1102 | fault: |
1093 | spin_unlock(&session->lock); | 1103 | spin_unlock(&session->lock); |
1094 | printk(KERN_ERR "iscsi: cmd 0x%x is not queued (%d)\n", | 1104 | debug_scsi("iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason); |
1095 | sc->cmnd[0], reason); | ||
1096 | sc->result = (DID_NO_CONNECT << 16); | ||
1097 | scsi_set_resid(sc, scsi_bufflen(sc)); | 1105 | scsi_set_resid(sc, scsi_bufflen(sc)); |
1098 | sc->scsi_done(sc); | 1106 | sc->scsi_done(sc); |
1099 | spin_lock(host->host_lock); | 1107 | spin_lock(host->host_lock); |
@@ -1160,7 +1168,8 @@ failed: | |||
1160 | mutex_lock(&session->eh_mutex); | 1168 | mutex_lock(&session->eh_mutex); |
1161 | spin_lock_bh(&session->lock); | 1169 | spin_lock_bh(&session->lock); |
1162 | if (session->state == ISCSI_STATE_LOGGED_IN) | 1170 | if (session->state == ISCSI_STATE_LOGGED_IN) |
1163 | printk(KERN_INFO "iscsi: host reset succeeded\n"); | 1171 | iscsi_session_printk(KERN_INFO, session, |
1172 | "host reset succeeded\n"); | ||
1164 | else | 1173 | else |
1165 | goto failed; | 1174 | goto failed; |
1166 | spin_unlock_bh(&session->lock); | 1175 | spin_unlock_bh(&session->lock); |
@@ -1239,7 +1248,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, | |||
1239 | * Fail commands. session lock held and recv side suspended and xmit | 1248 | * Fail commands. session lock held and recv side suspended and xmit |
1240 | * thread flushed | 1249 | * thread flushed |
1241 | */ | 1250 | */ |
1242 | static void fail_all_commands(struct iscsi_conn *conn, unsigned lun) | 1251 | static void fail_all_commands(struct iscsi_conn *conn, unsigned lun, |
1252 | int error) | ||
1243 | { | 1253 | { |
1244 | struct iscsi_cmd_task *ctask, *tmp; | 1254 | struct iscsi_cmd_task *ctask, *tmp; |
1245 | 1255 | ||
@@ -1251,7 +1261,7 @@ static void fail_all_commands(struct iscsi_conn *conn, unsigned lun) | |||
1251 | if (lun == ctask->sc->device->lun || lun == -1) { | 1261 | if (lun == ctask->sc->device->lun || lun == -1) { |
1252 | debug_scsi("failing pending sc %p itt 0x%x\n", | 1262 | debug_scsi("failing pending sc %p itt 0x%x\n", |
1253 | ctask->sc, ctask->itt); | 1263 | ctask->sc, ctask->itt); |
1254 | fail_command(conn, ctask, DID_BUS_BUSY << 16); | 1264 | fail_command(conn, ctask, error << 16); |
1255 | } | 1265 | } |
1256 | } | 1266 | } |
1257 | 1267 | ||
@@ -1259,7 +1269,7 @@ static void fail_all_commands(struct iscsi_conn *conn, unsigned lun) | |||
1259 | if (lun == ctask->sc->device->lun || lun == -1) { | 1269 | if (lun == ctask->sc->device->lun || lun == -1) { |
1260 | debug_scsi("failing requeued sc %p itt 0x%x\n", | 1270 | debug_scsi("failing requeued sc %p itt 0x%x\n", |
1261 | ctask->sc, ctask->itt); | 1271 | ctask->sc, ctask->itt); |
1262 | fail_command(conn, ctask, DID_BUS_BUSY << 16); | 1272 | fail_command(conn, ctask, error << 16); |
1263 | } | 1273 | } |
1264 | } | 1274 | } |
1265 | 1275 | ||
@@ -1357,10 +1367,10 @@ static void iscsi_check_transport_timeouts(unsigned long data) | |||
1357 | last_recv = conn->last_recv; | 1367 | last_recv = conn->last_recv; |
1358 | if (time_before_eq(last_recv + timeout + (conn->ping_timeout * HZ), | 1368 | if (time_before_eq(last_recv + timeout + (conn->ping_timeout * HZ), |
1359 | jiffies)) { | 1369 | jiffies)) { |
1360 | printk(KERN_ERR "ping timeout of %d secs expired, " | 1370 | iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " |
1361 | "last rx %lu, last ping %lu, now %lu\n", | 1371 | "expired, last rx %lu, last ping %lu, " |
1362 | conn->ping_timeout, last_recv, | 1372 | "now %lu\n", conn->ping_timeout, last_recv, |
1363 | conn->last_ping, jiffies); | 1373 | conn->last_ping, jiffies); |
1364 | spin_unlock(&session->lock); | 1374 | spin_unlock(&session->lock); |
1365 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 1375 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); |
1366 | return; | 1376 | return; |
@@ -1373,14 +1383,11 @@ static void iscsi_check_transport_timeouts(unsigned long data) | |||
1373 | iscsi_send_nopout(conn, NULL); | 1383 | iscsi_send_nopout(conn, NULL); |
1374 | } | 1384 | } |
1375 | next_timeout = last_recv + timeout + (conn->ping_timeout * HZ); | 1385 | next_timeout = last_recv + timeout + (conn->ping_timeout * HZ); |
1376 | } else { | 1386 | } else |
1377 | next_timeout = last_recv + timeout; | 1387 | next_timeout = last_recv + timeout; |
1378 | } | ||
1379 | 1388 | ||
1380 | if (next_timeout) { | 1389 | debug_scsi("Setting next tmo %lu\n", next_timeout); |
1381 | debug_scsi("Setting next tmo %lu\n", next_timeout); | 1390 | mod_timer(&conn->transport_timer, next_timeout); |
1382 | mod_timer(&conn->transport_timer, next_timeout); | ||
1383 | } | ||
1384 | done: | 1391 | done: |
1385 | spin_unlock(&session->lock); | 1392 | spin_unlock(&session->lock); |
1386 | } | 1393 | } |
@@ -1573,7 +1580,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
1573 | /* need to grab the recv lock then session lock */ | 1580 | /* need to grab the recv lock then session lock */ |
1574 | write_lock_bh(conn->recv_lock); | 1581 | write_lock_bh(conn->recv_lock); |
1575 | spin_lock(&session->lock); | 1582 | spin_lock(&session->lock); |
1576 | fail_all_commands(conn, sc->device->lun); | 1583 | fail_all_commands(conn, sc->device->lun, DID_ERROR); |
1577 | conn->tmf_state = TMF_INITIAL; | 1584 | conn->tmf_state = TMF_INITIAL; |
1578 | spin_unlock(&session->lock); | 1585 | spin_unlock(&session->lock); |
1579 | write_unlock_bh(conn->recv_lock); | 1586 | write_unlock_bh(conn->recv_lock); |
@@ -1944,9 +1951,10 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) | |||
1944 | } | 1951 | } |
1945 | spin_unlock_irqrestore(session->host->host_lock, flags); | 1952 | spin_unlock_irqrestore(session->host->host_lock, flags); |
1946 | msleep_interruptible(500); | 1953 | msleep_interruptible(500); |
1947 | printk(KERN_INFO "iscsi: scsi conn_destroy(): host_busy %d " | 1954 | iscsi_conn_printk(KERN_INFO, conn, "iscsi conn_destroy(): " |
1948 | "host_failed %d\n", session->host->host_busy, | 1955 | "host_busy %d host_failed %d\n", |
1949 | session->host->host_failed); | 1956 | session->host->host_busy, |
1957 | session->host->host_failed); | ||
1950 | /* | 1958 | /* |
1951 | * force eh_abort() to unblock | 1959 | * force eh_abort() to unblock |
1952 | */ | 1960 | */ |
@@ -1975,27 +1983,28 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) | |||
1975 | struct iscsi_session *session = conn->session; | 1983 | struct iscsi_session *session = conn->session; |
1976 | 1984 | ||
1977 | if (!session) { | 1985 | if (!session) { |
1978 | printk(KERN_ERR "iscsi: can't start unbound connection\n"); | 1986 | iscsi_conn_printk(KERN_ERR, conn, |
1987 | "can't start unbound connection\n"); | ||
1979 | return -EPERM; | 1988 | return -EPERM; |
1980 | } | 1989 | } |
1981 | 1990 | ||
1982 | if ((session->imm_data_en || !session->initial_r2t_en) && | 1991 | if ((session->imm_data_en || !session->initial_r2t_en) && |
1983 | session->first_burst > session->max_burst) { | 1992 | session->first_burst > session->max_burst) { |
1984 | printk("iscsi: invalid burst lengths: " | 1993 | iscsi_conn_printk(KERN_INFO, conn, "invalid burst lengths: " |
1985 | "first_burst %d max_burst %d\n", | 1994 | "first_burst %d max_burst %d\n", |
1986 | session->first_burst, session->max_burst); | 1995 | session->first_burst, session->max_burst); |
1987 | return -EINVAL; | 1996 | return -EINVAL; |
1988 | } | 1997 | } |
1989 | 1998 | ||
1990 | if (conn->ping_timeout && !conn->recv_timeout) { | 1999 | if (conn->ping_timeout && !conn->recv_timeout) { |
1991 | printk(KERN_ERR "iscsi: invalid recv timeout of zero " | 2000 | iscsi_conn_printk(KERN_ERR, conn, "invalid recv timeout of " |
1992 | "Using 5 seconds\n."); | 2001 | "zero. Using 5 seconds\n."); |
1993 | conn->recv_timeout = 5; | 2002 | conn->recv_timeout = 5; |
1994 | } | 2003 | } |
1995 | 2004 | ||
1996 | if (conn->recv_timeout && !conn->ping_timeout) { | 2005 | if (conn->recv_timeout && !conn->ping_timeout) { |
1997 | printk(KERN_ERR "iscsi: invalid ping timeout of zero " | 2006 | iscsi_conn_printk(KERN_ERR, conn, "invalid ping timeout of " |
1998 | "Using 5 seconds.\n"); | 2007 | "zero. Using 5 seconds.\n"); |
1999 | conn->ping_timeout = 5; | 2008 | conn->ping_timeout = 5; |
2000 | } | 2009 | } |
2001 | 2010 | ||
@@ -2019,11 +2028,9 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) | |||
2019 | conn->stop_stage = 0; | 2028 | conn->stop_stage = 0; |
2020 | conn->tmf_state = TMF_INITIAL; | 2029 | conn->tmf_state = TMF_INITIAL; |
2021 | session->age++; | 2030 | session->age++; |
2022 | spin_unlock_bh(&session->lock); | 2031 | if (session->age == 16) |
2023 | 2032 | session->age = 0; | |
2024 | iscsi_unblock_session(session_to_cls(session)); | 2033 | break; |
2025 | wake_up(&conn->ehwait); | ||
2026 | return 0; | ||
2027 | case STOP_CONN_TERM: | 2034 | case STOP_CONN_TERM: |
2028 | conn->stop_stage = 0; | 2035 | conn->stop_stage = 0; |
2029 | break; | 2036 | break; |
@@ -2032,6 +2039,8 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) | |||
2032 | } | 2039 | } |
2033 | spin_unlock_bh(&session->lock); | 2040 | spin_unlock_bh(&session->lock); |
2034 | 2041 | ||
2042 | iscsi_unblock_session(session_to_cls(session)); | ||
2043 | wake_up(&conn->ehwait); | ||
2035 | return 0; | 2044 | return 0; |
2036 | } | 2045 | } |
2037 | EXPORT_SYMBOL_GPL(iscsi_conn_start); | 2046 | EXPORT_SYMBOL_GPL(iscsi_conn_start); |
@@ -2123,7 +2132,8 @@ static void iscsi_start_session_recovery(struct iscsi_session *session, | |||
2123 | * flush queues. | 2132 | * flush queues. |
2124 | */ | 2133 | */ |
2125 | spin_lock_bh(&session->lock); | 2134 | spin_lock_bh(&session->lock); |
2126 | fail_all_commands(conn, -1); | 2135 | fail_all_commands(conn, -1, |
2136 | STOP_CONN_RECOVER ? DID_BUS_BUSY : DID_ERROR); | ||
2127 | flush_control_queues(session, conn); | 2137 | flush_control_queues(session, conn); |
2128 | spin_unlock_bh(&session->lock); | 2138 | spin_unlock_bh(&session->lock); |
2129 | mutex_unlock(&session->eh_mutex); | 2139 | mutex_unlock(&session->eh_mutex); |
@@ -2140,7 +2150,8 @@ void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) | |||
2140 | iscsi_start_session_recovery(session, conn, flag); | 2150 | iscsi_start_session_recovery(session, conn, flag); |
2141 | break; | 2151 | break; |
2142 | default: | 2152 | default: |
2143 | printk(KERN_ERR "iscsi: invalid stop flag %d\n", flag); | 2153 | iscsi_conn_printk(KERN_ERR, conn, |
2154 | "invalid stop flag %d\n", flag); | ||
2144 | } | 2155 | } |
2145 | } | 2156 | } |
2146 | EXPORT_SYMBOL_GPL(iscsi_conn_stop); | 2157 | EXPORT_SYMBOL_GPL(iscsi_conn_stop); |