aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
authorSagi Grimberg <sagig@mellanox.com>2014-06-11 05:09:58 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2014-06-11 16:06:45 -0400
commitd77e65350f2d82dfa0557707d505711f5a43c8fd (patch)
tree04adddbd63d60ebdaae4ee5a7c320dd6b9412d76 /drivers/scsi/libiscsi.c
parent8846bab180fa2bcfe02d4ba5288fbaba12c8f4f3 (diff)
libiscsi, iser: Adjust data_length to include protection information
In case protection information exists over the wire iscsi header data length is required to include it. Use protection information aware scsi helpers to set the correct transfer length. In order to avoid breakage, remove iser transfer length checks for each task as they are not always true and somewhat redundant anyway. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Acked-by: Mike Christie <michaelc@cs.wisc.edu> Cc: stable@vger.kernel.org # 3.15+ Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 26dc005bb0f0..3f462349b16c 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -338,7 +338,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
338 struct iscsi_session *session = conn->session; 338 struct iscsi_session *session = conn->session;
339 struct scsi_cmnd *sc = task->sc; 339 struct scsi_cmnd *sc = task->sc;
340 struct iscsi_scsi_req *hdr; 340 struct iscsi_scsi_req *hdr;
341 unsigned hdrlength, cmd_len; 341 unsigned hdrlength, cmd_len, transfer_length;
342 itt_t itt; 342 itt_t itt;
343 int rc; 343 int rc;
344 344
@@ -391,11 +391,11 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
391 if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL) 391 if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
392 task->protected = true; 392 task->protected = true;
393 393
394 transfer_length = scsi_transfer_length(sc);
395 hdr->data_length = cpu_to_be32(transfer_length);
394 if (sc->sc_data_direction == DMA_TO_DEVICE) { 396 if (sc->sc_data_direction == DMA_TO_DEVICE) {
395 unsigned out_len = scsi_out(sc)->length;
396 struct iscsi_r2t_info *r2t = &task->unsol_r2t; 397 struct iscsi_r2t_info *r2t = &task->unsol_r2t;
397 398
398 hdr->data_length = cpu_to_be32(out_len);
399 hdr->flags |= ISCSI_FLAG_CMD_WRITE; 399 hdr->flags |= ISCSI_FLAG_CMD_WRITE;
400 /* 400 /*
401 * Write counters: 401 * Write counters:
@@ -414,18 +414,19 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
414 memset(r2t, 0, sizeof(*r2t)); 414 memset(r2t, 0, sizeof(*r2t));
415 415
416 if (session->imm_data_en) { 416 if (session->imm_data_en) {
417 if (out_len >= session->first_burst) 417 if (transfer_length >= session->first_burst)
418 task->imm_count = min(session->first_burst, 418 task->imm_count = min(session->first_burst,
419 conn->max_xmit_dlength); 419 conn->max_xmit_dlength);
420 else 420 else
421 task->imm_count = min(out_len, 421 task->imm_count = min(transfer_length,
422 conn->max_xmit_dlength); 422 conn->max_xmit_dlength);
423 hton24(hdr->dlength, task->imm_count); 423 hton24(hdr->dlength, task->imm_count);
424 } else 424 } else
425 zero_data(hdr->dlength); 425 zero_data(hdr->dlength);
426 426
427 if (!session->initial_r2t_en) { 427 if (!session->initial_r2t_en) {
428 r2t->data_length = min(session->first_burst, out_len) - 428 r2t->data_length = min(session->first_burst,
429 transfer_length) -
429 task->imm_count; 430 task->imm_count;
430 r2t->data_offset = task->imm_count; 431 r2t->data_offset = task->imm_count;
431 r2t->ttt = cpu_to_be32(ISCSI_RESERVED_TAG); 432 r2t->ttt = cpu_to_be32(ISCSI_RESERVED_TAG);
@@ -438,7 +439,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
438 } else { 439 } else {
439 hdr->flags |= ISCSI_FLAG_CMD_FINAL; 440 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
440 zero_data(hdr->dlength); 441 zero_data(hdr->dlength);
441 hdr->data_length = cpu_to_be32(scsi_in(sc)->length);
442 442
443 if (sc->sc_data_direction == DMA_FROM_DEVICE) 443 if (sc->sc_data_direction == DMA_FROM_DEVICE)
444 hdr->flags |= ISCSI_FLAG_CMD_READ; 444 hdr->flags |= ISCSI_FLAG_CMD_READ;
@@ -466,7 +466,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
466 scsi_bidi_cmnd(sc) ? "bidirectional" : 466 scsi_bidi_cmnd(sc) ? "bidirectional" :
467 sc->sc_data_direction == DMA_TO_DEVICE ? 467 sc->sc_data_direction == DMA_TO_DEVICE ?
468 "write" : "read", conn->id, sc, sc->cmnd[0], 468 "write" : "read", conn->id, sc, sc->cmnd[0],
469 task->itt, scsi_bufflen(sc), 469 task->itt, transfer_length,
470 scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0, 470 scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0,
471 session->cmdsn, 471 session->cmdsn,
472 session->max_cmdsn - session->exp_cmdsn + 1); 472 session->max_cmdsn - session->exp_cmdsn + 1);