diff options
Diffstat (limited to 'drivers/scsi/iscsi_tcp.c')
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 2a2f0094570f..ed6c54cae7b1 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -523,22 +523,20 @@ iscsi_tcp_cleanup_task(struct iscsi_conn *conn, struct iscsi_task *task) | |||
523 | } | 523 | } |
524 | 524 | ||
525 | /** | 525 | /** |
526 | * iscsi_data_rsp - SCSI Data-In Response processing | 526 | * iscsi_data_in - SCSI Data-In Response processing |
527 | * @conn: iscsi connection | 527 | * @conn: iscsi connection |
528 | * @task: scsi command task | 528 | * @task: scsi command task |
529 | **/ | 529 | **/ |
530 | static int | 530 | static int |
531 | iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) | 531 | iscsi_data_in(struct iscsi_conn *conn, struct iscsi_task *task) |
532 | { | 532 | { |
533 | struct iscsi_tcp_conn *tcp_conn = conn->dd_data; | 533 | struct iscsi_tcp_conn *tcp_conn = conn->dd_data; |
534 | struct iscsi_tcp_task *tcp_task = task->dd_data; | 534 | struct iscsi_tcp_task *tcp_task = task->dd_data; |
535 | struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; | 535 | struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; |
536 | struct iscsi_session *session = conn->session; | ||
537 | struct scsi_cmnd *sc = task->sc; | ||
538 | int datasn = be32_to_cpu(rhdr->datasn); | 536 | int datasn = be32_to_cpu(rhdr->datasn); |
539 | unsigned total_in_length = scsi_in(sc)->length; | 537 | unsigned total_in_length = scsi_in(task->sc)->length; |
540 | 538 | ||
541 | iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); | 539 | iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr); |
542 | if (tcp_conn->in.datalen == 0) | 540 | if (tcp_conn->in.datalen == 0) |
543 | return 0; | 541 | return 0; |
544 | 542 | ||
@@ -558,23 +556,6 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) | |||
558 | return ISCSI_ERR_DATA_OFFSET; | 556 | return ISCSI_ERR_DATA_OFFSET; |
559 | } | 557 | } |
560 | 558 | ||
561 | if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) { | ||
562 | sc->result = (DID_OK << 16) | rhdr->cmd_status; | ||
563 | conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; | ||
564 | if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW | | ||
565 | ISCSI_FLAG_DATA_OVERFLOW)) { | ||
566 | int res_count = be32_to_cpu(rhdr->residual_count); | ||
567 | |||
568 | if (res_count > 0 && | ||
569 | (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || | ||
570 | res_count <= total_in_length)) | ||
571 | scsi_in(sc)->resid = res_count; | ||
572 | else | ||
573 | sc->result = (DID_BAD_TARGET << 16) | | ||
574 | rhdr->cmd_status; | ||
575 | } | ||
576 | } | ||
577 | |||
578 | conn->datain_pdus_cnt++; | 559 | conn->datain_pdus_cnt++; |
579 | return 0; | 560 | return 0; |
580 | } | 561 | } |
@@ -774,7 +755,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) | |||
774 | if (!task) | 755 | if (!task) |
775 | rc = ISCSI_ERR_BAD_ITT; | 756 | rc = ISCSI_ERR_BAD_ITT; |
776 | else | 757 | else |
777 | rc = iscsi_data_rsp(conn, task); | 758 | rc = iscsi_data_in(conn, task); |
778 | if (rc) { | 759 | if (rc) { |
779 | spin_unlock(&conn->session->lock); | 760 | spin_unlock(&conn->session->lock); |
780 | break; | 761 | break; |
@@ -998,7 +979,7 @@ iscsi_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, | |||
998 | 979 | ||
999 | error: | 980 | error: |
1000 | debug_tcp("Error receiving PDU, errno=%d\n", rc); | 981 | debug_tcp("Error receiving PDU, errno=%d\n", rc); |
1001 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 982 | iscsi_conn_failure(conn, rc); |
1002 | return 0; | 983 | return 0; |
1003 | } | 984 | } |
1004 | 985 | ||
@@ -1117,8 +1098,10 @@ iscsi_xmit(struct iscsi_conn *conn) | |||
1117 | 1098 | ||
1118 | while (1) { | 1099 | while (1) { |
1119 | rc = iscsi_tcp_xmit_segment(tcp_conn, segment); | 1100 | rc = iscsi_tcp_xmit_segment(tcp_conn, segment); |
1120 | if (rc < 0) | 1101 | if (rc < 0) { |
1102 | rc = ISCSI_ERR_XMIT_FAILED; | ||
1121 | goto error; | 1103 | goto error; |
1104 | } | ||
1122 | if (rc == 0) | 1105 | if (rc == 0) |
1123 | break; | 1106 | break; |
1124 | 1107 | ||
@@ -1127,7 +1110,7 @@ iscsi_xmit(struct iscsi_conn *conn) | |||
1127 | if (segment->total_copied >= segment->total_size) { | 1110 | if (segment->total_copied >= segment->total_size) { |
1128 | if (segment->done != NULL) { | 1111 | if (segment->done != NULL) { |
1129 | rc = segment->done(tcp_conn, segment); | 1112 | rc = segment->done(tcp_conn, segment); |
1130 | if (rc < 0) | 1113 | if (rc != 0) |
1131 | goto error; | 1114 | goto error; |
1132 | } | 1115 | } |
1133 | } | 1116 | } |
@@ -1142,8 +1125,8 @@ error: | |||
1142 | /* Transmit error. We could initiate error recovery | 1125 | /* Transmit error. We could initiate error recovery |
1143 | * here. */ | 1126 | * here. */ |
1144 | debug_tcp("Error sending PDU, errno=%d\n", rc); | 1127 | debug_tcp("Error sending PDU, errno=%d\n", rc); |
1145 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 1128 | iscsi_conn_failure(conn, rc); |
1146 | return rc; | 1129 | return -EIO; |
1147 | } | 1130 | } |
1148 | 1131 | ||
1149 | /** | 1132 | /** |
@@ -1904,6 +1887,7 @@ static void iscsi_tcp_session_destroy(struct iscsi_cls_session *cls_session) | |||
1904 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); | 1887 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); |
1905 | 1888 | ||
1906 | iscsi_r2tpool_free(cls_session->dd_data); | 1889 | iscsi_r2tpool_free(cls_session->dd_data); |
1890 | iscsi_session_teardown(cls_session); | ||
1907 | 1891 | ||
1908 | iscsi_host_remove(shost); | 1892 | iscsi_host_remove(shost); |
1909 | iscsi_host_free(shost); | 1893 | iscsi_host_free(shost); |
@@ -1927,7 +1911,7 @@ static struct scsi_host_template iscsi_sht = { | |||
1927 | .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, | 1911 | .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, |
1928 | .eh_abort_handler = iscsi_eh_abort, | 1912 | .eh_abort_handler = iscsi_eh_abort, |
1929 | .eh_device_reset_handler= iscsi_eh_device_reset, | 1913 | .eh_device_reset_handler= iscsi_eh_device_reset, |
1930 | .eh_host_reset_handler = iscsi_eh_host_reset, | 1914 | .eh_target_reset_handler= iscsi_eh_target_reset, |
1931 | .use_clustering = DISABLE_CLUSTERING, | 1915 | .use_clustering = DISABLE_CLUSTERING, |
1932 | .slave_configure = iscsi_tcp_slave_configure, | 1916 | .slave_configure = iscsi_tcp_slave_configure, |
1933 | .proc_name = "iscsi_tcp", | 1917 | .proc_name = "iscsi_tcp", |