Re: [PATCH] iscsi-target: fix seq_end_offset calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Thanks,

Bart.

From: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
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@xxxxxxxxxxx>
---
 drivers/target/iscsi/iscsi_target_erl0.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

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)
 		return;
 
-	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(
-- 
2.11.0

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



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux