aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorSteve Hodgson <steve@purestorage.com>2012-11-05 21:02:41 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2012-11-07 23:12:07 -0500
commit64c13330a38935120501b19c97a3e6095747c7a1 (patch)
tree830b0a2bee8e3c8ba7318a978d07916e90fad34e /drivers/target
parent998866b0740f128fd2c107c167c8385406dadae0 (diff)
iscsi-target: Fix bug in handling of ExpStatSN ACK during u32 wrap-around
This patch fixes a bug in the hanlding of initiator provided ExpStatSN and individual iscsi_cmd->stat_sn comparision during iscsi_conn->stat_sn wrap-around within iscsit_ack_from_expstatsn() code. This bug would manifest itself as iscsi_cmd descriptors not being Acked by a lower ExpStatSn, causing them to be leaked until an iSCSI connection or session reinstatement event occurs to release all commands. Also fix up two other uses of incorrect CmdSN SNA comparison to use wrapper usage from include/scsi/iscsi_proto.h. Signed-off-by: Steve Hodgson <steve@purestorage.com> Signed-off-by: Roland Dreier <roland@purestorage.com> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/iscsi/iscsi_target.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_erl2.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_tmr.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 093fb6010272..4ad14ac9a12c 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -735,7 +735,7 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn)
735 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { 735 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
736 spin_lock(&cmd->istate_lock); 736 spin_lock(&cmd->istate_lock);
737 if ((cmd->i_state == ISTATE_SENT_STATUS) && 737 if ((cmd->i_state == ISTATE_SENT_STATUS) &&
738 (cmd->stat_sn < exp_statsn)) { 738 iscsi_sna_lt(cmd->stat_sn, exp_statsn)) {
739 cmd->i_state = ISTATE_REMOVE; 739 cmd->i_state = ISTATE_REMOVE;
740 spin_unlock(&cmd->istate_lock); 740 spin_unlock(&cmd->istate_lock);
741 iscsit_add_cmd_to_immediate_queue(cmd, conn, 741 iscsit_add_cmd_to_immediate_queue(cmd, conn,
diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c
index 17d8c20094fd..9ac4c151eae4 100644
--- a/drivers/target/iscsi/iscsi_target_erl2.c
+++ b/drivers/target/iscsi/iscsi_target_erl2.c
@@ -372,7 +372,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
372 * made generic here. 372 * made generic here.
373 */ 373 */
374 if (!(cmd->cmd_flags & ICF_OOO_CMDSN) && !cmd->immediate_cmd && 374 if (!(cmd->cmd_flags & ICF_OOO_CMDSN) && !cmd->immediate_cmd &&
375 (cmd->cmd_sn >= conn->sess->exp_cmd_sn)) { 375 iscsi_sna_gte(cmd->stat_sn, conn->sess->exp_cmd_sn)) {
376 list_del(&cmd->i_conn_node); 376 list_del(&cmd->i_conn_node);
377 spin_unlock_bh(&conn->cmd_lock); 377 spin_unlock_bh(&conn->cmd_lock);
378 iscsit_free_cmd(cmd); 378 iscsit_free_cmd(cmd);
diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c
index 4a99820d063b..9d4417aae921 100644
--- a/drivers/target/iscsi/iscsi_target_tmr.c
+++ b/drivers/target/iscsi/iscsi_target_tmr.c
@@ -50,8 +50,8 @@ u8 iscsit_tmr_abort_task(
50 if (!ref_cmd) { 50 if (!ref_cmd) {
51 pr_err("Unable to locate RefTaskTag: 0x%08x on CID:" 51 pr_err("Unable to locate RefTaskTag: 0x%08x on CID:"
52 " %hu.\n", hdr->rtt, conn->cid); 52 " %hu.\n", hdr->rtt, conn->cid);
53 return (be32_to_cpu(hdr->refcmdsn) >= conn->sess->exp_cmd_sn && 53 return (iscsi_sna_gte(be32_to_cpu(hdr->refcmdsn), conn->sess->exp_cmd_sn) &&
54 be32_to_cpu(hdr->refcmdsn) <= conn->sess->max_cmd_sn) ? 54 iscsi_sna_lte(be32_to_cpu(hdr->refcmdsn), conn->sess->max_cmd_sn)) ?
55 ISCSI_TMF_RSP_COMPLETE : ISCSI_TMF_RSP_NO_TASK; 55 ISCSI_TMF_RSP_COMPLETE : ISCSI_TMF_RSP_NO_TASK;
56 } 56 }
57 if (ref_cmd->cmd_sn != be32_to_cpu(hdr->refcmdsn)) { 57 if (ref_cmd->cmd_sn != be32_to_cpu(hdr->refcmdsn)) {