mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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 <[email protected]> Reviewed-by: Mike Christie <[email protected]> Acked-by: Mike Christie <[email protected]> Cc: [email protected] # 3.15+ Signed-off-by: Nicholas Bellinger <[email protected]>
This commit is contained in:
parent
8846bab180
commit
d77e65350f
2 changed files with 19 additions and 33 deletions
|
|
@ -338,7 +338,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
|
|||
struct iscsi_session *session = conn->session;
|
||||
struct scsi_cmnd *sc = task->sc;
|
||||
struct iscsi_scsi_req *hdr;
|
||||
unsigned hdrlength, cmd_len;
|
||||
unsigned hdrlength, cmd_len, transfer_length;
|
||||
itt_t itt;
|
||||
int rc;
|
||||
|
||||
|
|
@ -391,11 +391,11 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
|
|||
if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
|
||||
task->protected = true;
|
||||
|
||||
transfer_length = scsi_transfer_length(sc);
|
||||
hdr->data_length = cpu_to_be32(transfer_length);
|
||||
if (sc->sc_data_direction == DMA_TO_DEVICE) {
|
||||
unsigned out_len = scsi_out(sc)->length;
|
||||
struct iscsi_r2t_info *r2t = &task->unsol_r2t;
|
||||
|
||||
hdr->data_length = cpu_to_be32(out_len);
|
||||
hdr->flags |= ISCSI_FLAG_CMD_WRITE;
|
||||
/*
|
||||
* Write counters:
|
||||
|
|
@ -414,18 +414,19 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
|
|||
memset(r2t, 0, sizeof(*r2t));
|
||||
|
||||
if (session->imm_data_en) {
|
||||
if (out_len >= session->first_burst)
|
||||
if (transfer_length >= session->first_burst)
|
||||
task->imm_count = min(session->first_burst,
|
||||
conn->max_xmit_dlength);
|
||||
else
|
||||
task->imm_count = min(out_len,
|
||||
conn->max_xmit_dlength);
|
||||
task->imm_count = min(transfer_length,
|
||||
conn->max_xmit_dlength);
|
||||
hton24(hdr->dlength, task->imm_count);
|
||||
} else
|
||||
zero_data(hdr->dlength);
|
||||
|
||||
if (!session->initial_r2t_en) {
|
||||
r2t->data_length = min(session->first_burst, out_len) -
|
||||
r2t->data_length = min(session->first_burst,
|
||||
transfer_length) -
|
||||
task->imm_count;
|
||||
r2t->data_offset = task->imm_count;
|
||||
r2t->ttt = cpu_to_be32(ISCSI_RESERVED_TAG);
|
||||
|
|
@ -438,7 +439,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
|
|||
} else {
|
||||
hdr->flags |= ISCSI_FLAG_CMD_FINAL;
|
||||
zero_data(hdr->dlength);
|
||||
hdr->data_length = cpu_to_be32(scsi_in(sc)->length);
|
||||
|
||||
if (sc->sc_data_direction == DMA_FROM_DEVICE)
|
||||
hdr->flags |= ISCSI_FLAG_CMD_READ;
|
||||
|
|
@ -466,7 +466,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
|
|||
scsi_bidi_cmnd(sc) ? "bidirectional" :
|
||||
sc->sc_data_direction == DMA_TO_DEVICE ?
|
||||
"write" : "read", conn->id, sc, sc->cmnd[0],
|
||||
task->itt, scsi_bufflen(sc),
|
||||
task->itt, transfer_length,
|
||||
scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0,
|
||||
session->cmdsn,
|
||||
session->max_cmdsn - session->exp_cmdsn + 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue