For correct TMF handling we should keep track of outstanding
TTTs; some targets will drop the connections if outstanding
TTTs are not honoured.

Signed-off-by: Hannes Reinecke <h...@suse.de>
---
 drivers/scsi/libiscsi.c     |    8 ++++++++
 drivers/scsi/libiscsi_tcp.c |    2 +-
 include/scsi/libiscsi.h     |    1 +
 3 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 77b167a..c4d2c76 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -177,6 +177,7 @@ void iscsi_prep_data_out_pdu(struct iscsi_task *task, 
struct iscsi_r2t_info *r2t
                hton24(hdr->dlength, left);
                r2t->data_count = left;
                hdr->flags = ISCSI_FLAG_CMD_FINAL;
+               task->ttt = RESERVED_ITT;
        }
        conn->dataout_pdus_cnt++;
 }
@@ -444,6 +445,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
                return -EIO;
 
        task->state = ISCSI_TASK_RUNNING;
+       task->ttt = RESERVED_ITT;
        hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
        session->cmdsn++;
 
@@ -478,6 +480,7 @@ static void iscsi_free_task(struct iscsi_task *task)
                          task->itt, task->state, task->sc);
 
        session->tt->cleanup_task(task);
+       task->ttt = RESERVED_ITT;
        task->state = ISCSI_TASK_FREE;
        task->sc = NULL;
        /*
@@ -590,6 +593,11 @@ static void fail_scsi_task(struct iscsi_task *task, int 
err)
        else
                state = ISCSI_TASK_ABRT_TMF;
 
+       if (task->ttt != RESERVED_ITT)
+               ISCSI_DBG_EH(conn->session,
+                            "task itt 0x%x ttt 0x%x sc %p still active\n",
+                            task->itt, task->ttt, task->sc);
+
        sc->result = err << 16;
        if (!scsi_bidi_cmnd(sc))
                scsi_set_resid(sc, scsi_bufflen(sc));
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 2e0746d..0f33f11 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -575,7 +575,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, 
struct iscsi_task *task)
                return ISCSI_ERR_DATALEN;
        }
 
-       r2t->ttt = rhdr->ttt; /* no flip */
+       r2t->ttt = task->ttt = rhdr->ttt; /* no flip */
        r2t->datasn = 0;
        r2t->sent = 0;
 
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 61afeb5..3a20dea 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -116,6 +116,7 @@ struct iscsi_task {
        uint8_t                 lun[8];
 
        int                     itt;            /* this ITT */
+       int                     ttt;
 
        unsigned                imm_count;      /* imm-data (bytes)   */
        /* offset in unsolicited stream (bytes); */
-- 
1.6.0.2


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Reply via email to