diff mbox

iscsi-target: fix seq_end_offset calculation

Message ID 82f2f427-e53b-4f2b-1f2b-5e85f265f86d@sandisk.com (mailing list archive)
State Accepted
Headers show

Commit Message

Bart Van Assche Jan. 23, 2017, 7:14 p.m. UTC
On 01/23/2017 03:23 AM, Varun Prakash wrote:
> This patch does not look correct to me because with this patch
> seq_end_offset can get a value which is greater than IO size.

Agreed. I will queue your patch. But I would appreciate if you could
also review the patch below.



From: Bart Van Assche <bart.vanassche@sandisk.com>
Subject: [PATCH] target/iscsi: Fix solicited data sequence offset calculations

From the iSCSI RFC (https://tools.ietf.org/html/rfc7143):
* MaxBurstLength is the maximum SCSI data payload in bytes in a
  Data-In or a solicited Data-Out iSCSI sequence. A sequence
  consists of one or more consecutive Data-In or Data-Out PDUs
  that end with a Data-In or Data-Out PDU with the F bit set to 1.
* FirstBurstLength is the maximum amount in bytes of unsolicited
  data an iSCSI initiator may send to the target during the
  execution of a single SCSI command.  This covers the immediate
  data (if any) and the sequence of unsolicited Data-Out PDUs
  (if any) that follow the command.

Hence change the solicited data offset calculations as follows:
* For the second and later Data-Out PDUs, set seq_start_offset
  to write_data_done instead of seq_end_offset of the previous
  Data-Out PDU.
* For all Data-Out PDUs, limit seq_end_offset to MaxBurstLength
  as required by the iSCSI RFC.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
 drivers/target/iscsi/iscsi_target_erl0.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)


Bart Van Assche Jan. 24, 2017, 7:21 p.m. UTC | #1
On Mon, 2017-01-23 at 11:14 -0800, Bart Van Assche wrote:
> From: Bart Van Assche <bart.vanassche@sandisk.com>
> Subject: [PATCH] target/iscsi: Fix solicited data sequence offset calculations

Please ignore this patch - I have dropped it.

To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox


diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c
index a8bcbc43b047..f5fbcba8cbbe 100644
--- a/drivers/target/iscsi/iscsi_target_erl0.c
+++ b/drivers/target/iscsi/iscsi_target_erl0.c
@@ -52,20 +52,9 @@  void iscsit_set_dataout_sequence_values(
 	if (!conn->sess->sess_ops->DataSequenceInOrder)
-	if (!cmd->seq_start_offset && !cmd->seq_end_offset) {
-		cmd->seq_start_offset = cmd->write_data_done;
-		cmd->seq_end_offset = (cmd->se_cmd.data_length >
-			conn->sess->sess_ops->MaxBurstLength) ?
-			(cmd->write_data_done +
-			conn->sess->sess_ops->MaxBurstLength) : cmd->se_cmd.data_length;
-	} else {
-		cmd->seq_start_offset = cmd->seq_end_offset;
-		cmd->seq_end_offset = ((cmd->seq_end_offset +
-			conn->sess->sess_ops->MaxBurstLength) >=
-			cmd->se_cmd.data_length) ? cmd->se_cmd.data_length :
-			(cmd->seq_end_offset +
-			 conn->sess->sess_ops->MaxBurstLength);
-	}
+	cmd->seq_start_offset = cmd->write_data_done;
+	cmd->seq_end_offset = min(cmd->se_cmd.data_length,
+				  conn->sess->sess_ops->MaxBurstLength);
 static int iscsit_dataout_within_command_recovery_check(