Skip to content

Commit 4d65491

Browse files
Varun PrakashNicholas Bellinger
authored andcommitted
target/iscsi: Fix unsolicited data seq_end_offset calculation
In case of unsolicited data for the first sequence seq_end_offset must be set to minimum of total data length and FirstBurstLength, so do not add cmd->write_data_done to the min of total data length and FirstBurstLength. This patch avoids that with ImmediateData=Yes, InitialR2T=No, MaxXmitDataSegmentLength < FirstBurstLength that a WRITE command with IO size above FirstBurstLength triggers sequence error messages, for example Set following parameters on target (linux-4.8.12) ImmediateData = Yes InitialR2T = No MaxXmitDataSegmentLength = 8k FirstBurstLength = 64k Log in from Open iSCSI initiator and execute dd if=/dev/zero of=/dev/sdb bs=128k count=1 oflag=direct Error messages on target Command ITT: 0x00000035 with Offset: 65536, Length: 8192 outside of Sequence 73728:131072 while DataSequenceInOrder=Yes. Command ITT: 0x00000035, received DataSN: 0x00000001 higher than expected 0x00000000. Unable to perform within-command recovery while ERL=0. Signed-off-by: Varun Prakash <[email protected]> [ bvanassche: Use min() instead of open-coding it / edited patch description ] Signed-off-by: Bart Van Assche <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 79e57cf commit 4d65491

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/target/iscsi/iscsi_target_erl0.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ void iscsit_set_dataout_sequence_values(
4444
*/
4545
if (cmd->unsolicited_data) {
4646
cmd->seq_start_offset = cmd->write_data_done;
47-
cmd->seq_end_offset = (cmd->write_data_done +
48-
((cmd->se_cmd.data_length >
49-
conn->sess->sess_ops->FirstBurstLength) ?
50-
conn->sess->sess_ops->FirstBurstLength : cmd->se_cmd.data_length));
47+
cmd->seq_end_offset = min(cmd->se_cmd.data_length,
48+
conn->sess->sess_ops->FirstBurstLength);
5149
return;
5250
}
5351

0 commit comments

Comments
 (0)