Skip to content

Commit

Permalink
iscsi-target: Fix processing of OOO commands
Browse files Browse the repository at this point in the history
Fix two issues in OOO commands processing done at iscsit_attach_ooo_cmdsn.

Handle command serial numbers wrap around by using iscsi_sna_lt and not regular comparisson.

The routine iterates until it finds an entry whose serial number is greater than the serial number of
the new one, thus the new entry should be inserted before that entry and not after.

Signed-off-by: Shlomo Pongratz <shlomop@mellanox.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Shlomo Pongratz authored and Nicholas Bellinger committed May 7, 2013
1 parent 80690fd commit 3eccfdb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/target/iscsi/iscsi_target_erl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ static int iscsit_attach_ooo_cmdsn(
/*
* CmdSN is greater than the tail of the list.
*/
if (ooo_tail->cmdsn < ooo_cmdsn->cmdsn)
if (iscsi_sna_lt(ooo_tail->cmdsn, ooo_cmdsn->cmdsn))
list_add_tail(&ooo_cmdsn->ooo_list,
&sess->sess_ooo_cmdsn_list);
else {
Expand All @@ -833,11 +833,12 @@ static int iscsit_attach_ooo_cmdsn(
*/
list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list,
ooo_list) {
if (ooo_tmp->cmdsn < ooo_cmdsn->cmdsn)
if (iscsi_sna_lt(ooo_tmp->cmdsn, ooo_cmdsn->cmdsn))
continue;

/* Insert before this entry */
list_add(&ooo_cmdsn->ooo_list,
&ooo_tmp->ooo_list);
ooo_tmp->ooo_list.prev);
break;
}
}
Expand Down

0 comments on commit 3eccfdb

Please sign in to comment.