diff options
-rw-r--r-- | drivers/infiniband/ulp/iser/iscsi_iser.c | 4 | ||||
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 21 | ||||
-rw-r--r-- | drivers/scsi/libiscsi.c | 9 | ||||
-rw-r--r-- | include/scsi/libiscsi.h | 21 |
4 files changed, 28 insertions, 27 deletions
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index e39d9a07bc5d..568f88bf7c91 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c | |||
@@ -140,10 +140,10 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) | |||
140 | iser_ctask->iser_conn = iser_conn; | 140 | iser_ctask->iser_conn = iser_conn; |
141 | 141 | ||
142 | if (sc->sc_data_direction == DMA_TO_DEVICE) { | 142 | if (sc->sc_data_direction == DMA_TO_DEVICE) { |
143 | BUG_ON(ctask->total_length == 0); | 143 | BUG_ON(sc->request_bufflen == 0); |
144 | 144 | ||
145 | debug_scsi("cmd [itt %x total %d imm %d unsol_data %d\n", | 145 | debug_scsi("cmd [itt %x total %d imm %d unsol_data %d\n", |
146 | ctask->itt, ctask->total_length, ctask->imm_count, | 146 | ctask->itt, sc->request_bufflen, ctask->imm_count, |
147 | ctask->unsol_count); | 147 | ctask->unsol_count); |
148 | } | 148 | } |
149 | 149 | ||
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 17fc79c408a2..b2827d112cb0 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -216,6 +216,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) | |||
216 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; | 216 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; |
217 | struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; | 217 | struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; |
218 | struct iscsi_session *session = conn->session; | 218 | struct iscsi_session *session = conn->session; |
219 | struct scsi_cmnd *sc = ctask->sc; | ||
219 | int datasn = be32_to_cpu(rhdr->datasn); | 220 | int datasn = be32_to_cpu(rhdr->datasn); |
220 | 221 | ||
221 | rc = iscsi_check_assign_cmdsn(session, (struct iscsi_nopin*)rhdr); | 222 | rc = iscsi_check_assign_cmdsn(session, (struct iscsi_nopin*)rhdr); |
@@ -238,12 +239,14 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) | |||
238 | tcp_ctask->exp_datasn++; | 239 | tcp_ctask->exp_datasn++; |
239 | 240 | ||
240 | tcp_ctask->data_offset = be32_to_cpu(rhdr->offset); | 241 | tcp_ctask->data_offset = be32_to_cpu(rhdr->offset); |
241 | if (tcp_ctask->data_offset + tcp_conn->in.datalen > ctask->total_length) | 242 | if (tcp_ctask->data_offset + tcp_conn->in.datalen > sc->request_bufflen) { |
243 | debug_tcp("%s: data_offset(%d) + data_len(%d) > total_length_in(%d)\n", | ||
244 | __FUNCTION__, tcp_ctask->data_offset, | ||
245 | tcp_conn->in.datalen, sc->request_bufflen); | ||
242 | return ISCSI_ERR_DATA_OFFSET; | 246 | return ISCSI_ERR_DATA_OFFSET; |
247 | } | ||
243 | 248 | ||
244 | if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) { | 249 | if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) { |
245 | struct scsi_cmnd *sc = ctask->sc; | ||
246 | |||
247 | conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; | 250 | conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; |
248 | if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) { | 251 | if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) { |
249 | int res_count = be32_to_cpu(rhdr->residual_count); | 252 | int res_count = be32_to_cpu(rhdr->residual_count); |
@@ -405,11 +408,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) | |||
405 | r2t->data_length, session->max_burst); | 408 | r2t->data_length, session->max_burst); |
406 | 409 | ||
407 | r2t->data_offset = be32_to_cpu(rhdr->data_offset); | 410 | r2t->data_offset = be32_to_cpu(rhdr->data_offset); |
408 | if (r2t->data_offset + r2t->data_length > ctask->total_length) { | 411 | if (r2t->data_offset + r2t->data_length > ctask->sc->request_bufflen) { |
409 | spin_unlock(&session->lock); | 412 | spin_unlock(&session->lock); |
410 | printk(KERN_ERR "iscsi_tcp: invalid R2T with data len %u at " | 413 | printk(KERN_ERR "iscsi_tcp: invalid R2T with data len %u at " |
411 | "offset %u and total length %d\n", r2t->data_length, | 414 | "offset %u and total length %d\n", r2t->data_length, |
412 | r2t->data_offset, ctask->total_length); | 415 | r2t->data_offset, ctask->sc->request_bufflen); |
413 | return ISCSI_ERR_DATALEN; | 416 | return ISCSI_ERR_DATALEN; |
414 | } | 417 | } |
415 | 418 | ||
@@ -604,7 +607,7 @@ iscsi_ctask_copy(struct iscsi_tcp_conn *tcp_conn, struct iscsi_cmd_task *ctask, | |||
604 | { | 607 | { |
605 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; | 608 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; |
606 | int buf_left = buf_size - (tcp_conn->data_copied + offset); | 609 | int buf_left = buf_size - (tcp_conn->data_copied + offset); |
607 | int size = min(tcp_conn->in.copy, buf_left); | 610 | unsigned size = min(tcp_conn->in.copy, buf_left); |
608 | int rc; | 611 | int rc; |
609 | 612 | ||
610 | size = min(size, ctask->data_count); | 613 | size = min(size, ctask->data_count); |
@@ -613,7 +616,7 @@ iscsi_ctask_copy(struct iscsi_tcp_conn *tcp_conn, struct iscsi_cmd_task *ctask, | |||
613 | size, tcp_conn->in.offset, tcp_conn->in.copied); | 616 | size, tcp_conn->in.offset, tcp_conn->in.copied); |
614 | 617 | ||
615 | BUG_ON(size <= 0); | 618 | BUG_ON(size <= 0); |
616 | BUG_ON(tcp_ctask->sent + size > ctask->total_length); | 619 | BUG_ON(tcp_ctask->sent + size > ctask->sc->request_bufflen); |
617 | 620 | ||
618 | rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset, | 621 | rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset, |
619 | (char*)buf + (offset + tcp_conn->data_copied), size); | 622 | (char*)buf + (offset + tcp_conn->data_copied), size); |
@@ -1292,7 +1295,7 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask) | |||
1292 | 1295 | ||
1293 | if (sc->sc_data_direction == DMA_TO_DEVICE) { | 1296 | if (sc->sc_data_direction == DMA_TO_DEVICE) { |
1294 | tcp_ctask->xmstate = XMSTATE_W_HDR; | 1297 | tcp_ctask->xmstate = XMSTATE_W_HDR; |
1295 | BUG_ON(ctask->total_length == 0); | 1298 | BUG_ON(sc->request_bufflen == 0); |
1296 | 1299 | ||
1297 | if (sc->use_sg) { | 1300 | if (sc->use_sg) { |
1298 | struct scatterlist *sg = sc->request_buffer; | 1301 | struct scatterlist *sg = sc->request_buffer; |
@@ -1309,7 +1312,7 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask) | |||
1309 | } | 1312 | } |
1310 | debug_scsi("cmd [itt 0x%x total %d imm_data %d " | 1313 | debug_scsi("cmd [itt 0x%x total %d imm_data %d " |
1311 | "unsol count %d, unsol offset %d]\n", | 1314 | "unsol count %d, unsol offset %d]\n", |
1312 | ctask->itt, ctask->total_length, ctask->imm_count, | 1315 | ctask->itt, sc->request_bufflen, ctask->imm_count, |
1313 | ctask->unsol_count, ctask->unsol_offset); | 1316 | ctask->unsol_count, ctask->unsol_offset); |
1314 | } else | 1317 | } else |
1315 | tcp_ctask->xmstate = XMSTATE_R_HDR; | 1318 | tcp_ctask->xmstate = XMSTATE_R_HDR; |
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index eb5113607958..0a9c64e9ce8b 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -147,19 +147,19 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | |||
147 | ctask->unsol_datasn = 0; | 147 | ctask->unsol_datasn = 0; |
148 | 148 | ||
149 | if (session->imm_data_en) { | 149 | if (session->imm_data_en) { |
150 | if (ctask->total_length >= session->first_burst) | 150 | if (sc->request_bufflen >= session->first_burst) |
151 | ctask->imm_count = min(session->first_burst, | 151 | ctask->imm_count = min(session->first_burst, |
152 | conn->max_xmit_dlength); | 152 | conn->max_xmit_dlength); |
153 | else | 153 | else |
154 | ctask->imm_count = min(ctask->total_length, | 154 | ctask->imm_count = min(sc->request_bufflen, |
155 | conn->max_xmit_dlength); | 155 | conn->max_xmit_dlength); |
156 | hton24(ctask->hdr->dlength, ctask->imm_count); | 156 | hton24(ctask->hdr->dlength, ctask->imm_count); |
157 | } else | 157 | } else |
158 | zero_data(ctask->hdr->dlength); | 158 | zero_data(ctask->hdr->dlength); |
159 | 159 | ||
160 | if (!session->initial_r2t_en) { | 160 | if (!session->initial_r2t_en) { |
161 | ctask->unsol_count = min(session->first_burst, | 161 | ctask->unsol_count = min((session->first_burst), |
162 | ctask->total_length) - ctask->imm_count; | 162 | (sc->request_bufflen)) - ctask->imm_count; |
163 | ctask->unsol_offset = ctask->imm_count; | 163 | ctask->unsol_offset = ctask->imm_count; |
164 | } | 164 | } |
165 | 165 | ||
@@ -815,7 +815,6 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | |||
815 | ctask->conn = conn; | 815 | ctask->conn = conn; |
816 | ctask->sc = sc; | 816 | ctask->sc = sc; |
817 | INIT_LIST_HEAD(&ctask->running); | 817 | INIT_LIST_HEAD(&ctask->running); |
818 | ctask->total_length = sc->request_bufflen; | ||
819 | iscsi_prep_scsi_cmd_pdu(ctask); | 818 | iscsi_prep_scsi_cmd_pdu(ctask); |
820 | 819 | ||
821 | session->tt->init_cmd_task(ctask); | 820 | session->tt->init_cmd_task(ctask); |
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 61e069206ac5..348265d4a27e 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h | |||
@@ -80,7 +80,7 @@ struct iscsi_mgmt_task { | |||
80 | */ | 80 | */ |
81 | struct iscsi_hdr *hdr; | 81 | struct iscsi_hdr *hdr; |
82 | char *data; /* mgmt payload */ | 82 | char *data; /* mgmt payload */ |
83 | int data_count; /* counts data to be sent */ | 83 | unsigned data_count; /* counts data to be sent */ |
84 | uint32_t itt; /* this ITT */ | 84 | uint32_t itt; /* this ITT */ |
85 | void *dd_data; /* driver/transport data */ | 85 | void *dd_data; /* driver/transport data */ |
86 | struct list_head running; | 86 | struct list_head running; |
@@ -101,13 +101,12 @@ struct iscsi_cmd_task { | |||
101 | int itt; /* this ITT */ | 101 | int itt; /* this ITT */ |
102 | 102 | ||
103 | uint32_t unsol_datasn; | 103 | uint32_t unsol_datasn; |
104 | int imm_count; /* imm-data (bytes) */ | 104 | unsigned imm_count; /* imm-data (bytes) */ |
105 | int unsol_count; /* unsolicited (bytes)*/ | 105 | unsigned unsol_count; /* unsolicited (bytes)*/ |
106 | /* offset in unsolicited stream (bytes); */ | 106 | /* offset in unsolicited stream (bytes); */ |
107 | int unsol_offset; | 107 | unsigned unsol_offset; |
108 | int data_count; /* remaining Data-Out */ | 108 | unsigned data_count; /* remaining Data-Out */ |
109 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ | 109 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ |
110 | int total_length; | ||
111 | struct iscsi_conn *conn; /* used connection */ | 110 | struct iscsi_conn *conn; /* used connection */ |
112 | struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */ | 111 | struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */ |
113 | 112 | ||
@@ -173,8 +172,8 @@ struct iscsi_conn { | |||
173 | int tmabort_state; /* see TMABORT_INITIAL, etc.*/ | 172 | int tmabort_state; /* see TMABORT_INITIAL, etc.*/ |
174 | 173 | ||
175 | /* negotiated params */ | 174 | /* negotiated params */ |
176 | int max_recv_dlength; /* initiator_max_recv_dsl*/ | 175 | unsigned max_recv_dlength; /* initiator_max_recv_dsl*/ |
177 | int max_xmit_dlength; /* target_max_recv_dsl */ | 176 | unsigned max_xmit_dlength; /* target_max_recv_dsl */ |
178 | int hdrdgst_en; | 177 | int hdrdgst_en; |
179 | int datadgst_en; | 178 | int datadgst_en; |
180 | int ifmarker_en; | 179 | int ifmarker_en; |
@@ -212,10 +211,10 @@ struct iscsi_session { | |||
212 | 211 | ||
213 | /* configuration */ | 212 | /* configuration */ |
214 | int initial_r2t_en; | 213 | int initial_r2t_en; |
215 | int max_r2t; | 214 | unsigned max_r2t; |
216 | int imm_data_en; | 215 | int imm_data_en; |
217 | int first_burst; | 216 | unsigned first_burst; |
218 | int max_burst; | 217 | unsigned max_burst; |
219 | int time2wait; | 218 | int time2wait; |
220 | int time2retain; | 219 | int time2retain; |
221 | int pdu_inorder_en; | 220 | int pdu_inorder_en; |