target: move ref_cmd from the generic se_tmr_req into iscsi code
authorChristoph Hellwig <hch@infradead.org>
Sun, 20 May 2012 18:35:02 +0000 (14:35 -0400)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 17 Jul 2012 00:29:11 +0000 (17:29 -0700)
Also remove the unused ref_task_lun field in struct se_tmr_req.

(nab: Add missing TASK_REASSIGN ref_lun vs. ref_cmd orig_fe_lun checks
      in iscsit_tmr_task_reassign)

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target_core.h
drivers/target/iscsi/iscsi_target_tmr.c
include/target/target_core_base.h

index 1c70144..63a8ed2 100644 (file)
@@ -481,6 +481,7 @@ struct iscsi_tmr_req {
        bool                    task_reassign:1;
        u32                     ref_cmd_sn;
        u32                     exp_data_sn;
+       struct iscsi_cmd        *ref_cmd;
        struct iscsi_conn_recovery *conn_recovery;
        struct se_tmr_req       *se_tmr_req;
 };
index f4e640b..1f75529 100644 (file)
@@ -19,6 +19,7 @@
  ******************************************************************************/
 
 #include <asm/unaligned.h>
+#include <scsi/scsi_device.h>
 #include <scsi/iscsi_proto.h>
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
@@ -61,7 +62,7 @@ u8 iscsit_tmr_abort_task(
        }
 
        se_tmr->ref_task_tag            = hdr->rtt;
-       se_tmr->ref_cmd                 = &ref_cmd->se_cmd;
+       tmr_req->ref_cmd                = ref_cmd;
        tmr_req->ref_cmd_sn             = hdr->refcmdsn;
        tmr_req->exp_data_sn            = hdr->exp_datasn;
 
@@ -121,7 +122,7 @@ u8 iscsit_tmr_task_reassign(
        struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
        struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
        struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
-       int ret;
+       int ret, ref_lun;
 
        pr_debug("Got TASK_REASSIGN TMR ITT: 0x%08x,"
                " RefTaskTag: 0x%08x, ExpDataSN: 0x%08x, CID: %hu\n",
@@ -155,9 +156,16 @@ u8 iscsit_tmr_task_reassign(
                return ISCSI_TMF_RSP_REJECTED;
        }
 
+       ref_lun = scsilun_to_int(&hdr->lun);
+       if (ref_lun != ref_cmd->se_cmd.orig_fe_lun) {
+               pr_err("Unable to perform connection recovery for"
+                       " differing ref_lun: %d ref_cmd orig_fe_lun: %u\n",
+                       ref_lun, ref_cmd->se_cmd.orig_fe_lun);
+               return ISCSI_TMF_RSP_REJECTED;
+       }
+
        se_tmr->ref_task_tag            = hdr->rtt;
-       se_tmr->ref_cmd                 = &ref_cmd->se_cmd;
-       se_tmr->ref_task_lun            = get_unaligned_le64(&hdr->lun);
+       tmr_req->ref_cmd                = ref_cmd;
        tmr_req->ref_cmd_sn             = hdr->refcmdsn;
        tmr_req->exp_data_sn            = hdr->exp_datasn;
        tmr_req->conn_recovery          = cr;
@@ -191,9 +199,7 @@ static int iscsit_task_reassign_complete_nop_out(
        struct iscsi_tmr_req *tmr_req,
        struct iscsi_conn *conn)
 {
-       struct se_tmr_req *se_tmr = tmr_req->se_tmr_req;
-       struct se_cmd *se_cmd = se_tmr->ref_cmd;
-       struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
+       struct iscsi_cmd *cmd = tmr_req->ref_cmd;
        struct iscsi_conn_recovery *cr;
 
        if (!cmd->cr) {
@@ -360,9 +366,7 @@ static int iscsit_task_reassign_complete_scsi_cmnd(
        struct iscsi_tmr_req *tmr_req,
        struct iscsi_conn *conn)
 {
-       struct se_tmr_req *se_tmr = tmr_req->se_tmr_req;
-       struct se_cmd *se_cmd = se_tmr->ref_cmd;
-       struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
+       struct iscsi_cmd *cmd = tmr_req->ref_cmd;
        struct iscsi_conn_recovery *cr;
 
        if (!cmd->cr) {
@@ -385,7 +389,7 @@ static int iscsit_task_reassign_complete_scsi_cmnd(
        list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list);
        spin_unlock_bh(&conn->cmd_lock);
 
-       if (se_cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) {
+       if (cmd->se_cmd.se_cmd_flags & SCF_SENT_CHECK_CONDITION) {
                cmd->i_state = ISTATE_SEND_STATUS;
                iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);
                return 0;
@@ -411,17 +415,14 @@ static int iscsit_task_reassign_complete(
        struct iscsi_tmr_req *tmr_req,
        struct iscsi_conn *conn)
 {
-       struct se_tmr_req *se_tmr = tmr_req->se_tmr_req;
-       struct se_cmd *se_cmd;
        struct iscsi_cmd *cmd;
        int ret = 0;
 
-       if (!se_tmr->ref_cmd) {
+       if (!tmr_req->ref_cmd) {
                pr_err("TMR Request is missing a RefCmd struct iscsi_cmd.\n");
                return -1;
        }
-       se_cmd = se_tmr->ref_cmd;
-       cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
+       cmd = tmr_req->ref_cmd;
 
        cmd->conn = conn;
 
@@ -547,9 +548,7 @@ int iscsit_task_reassign_prepare_write(
        struct iscsi_tmr_req *tmr_req,
        struct iscsi_conn *conn)
 {
-       struct se_tmr_req *se_tmr = tmr_req->se_tmr_req;
-       struct se_cmd *se_cmd = se_tmr->ref_cmd;
-       struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
+       struct iscsi_cmd *cmd = tmr_req->ref_cmd;
        struct iscsi_pdu *pdu = NULL;
        struct iscsi_r2t *r2t = NULL, *r2t_tmp;
        int first_incomplete_r2t = 1, i = 0;
@@ -782,14 +781,12 @@ int iscsit_check_task_reassign_expdatasn(
        struct iscsi_tmr_req *tmr_req,
        struct iscsi_conn *conn)
 {
-       struct se_tmr_req *se_tmr = tmr_req->se_tmr_req;
-       struct se_cmd *se_cmd = se_tmr->ref_cmd;
-       struct iscsi_cmd *ref_cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
+       struct iscsi_cmd *ref_cmd = tmr_req->ref_cmd;
 
        if (ref_cmd->iscsi_opcode != ISCSI_OP_SCSI_CMD)
                return 0;
 
-       if (se_cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION)
+       if (ref_cmd->se_cmd.se_cmd_flags & SCF_SENT_CHECK_CONDITION)
                return 0;
 
        if (ref_cmd->data_direction == DMA_NONE)
index 6e99dc5..15039dd 100644 (file)
@@ -483,11 +483,8 @@ struct se_tmr_req {
        int                     call_transport;
        /* Reference to ITT that Task Mgmt should be performed */
        u32                     ref_task_tag;
-       /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */
-       u64                     ref_task_lun;
        void                    *fabric_tmr_ptr;
        struct se_cmd           *task_cmd;
-       struct se_cmd           *ref_cmd;
        struct se_device        *tmr_dev;
        struct se_lun           *tmr_lun;
        struct list_head        tmr_list;