[SCSI] qla4xxx: Clear DDB index map upon connection close failure
authorNilesh Javali <nilesh.javali@qlogic.com>
Mon, 16 Dec 2013 11:49:40 +0000 (06:49 -0500)
committerJames Bottomley <JBottomley@Parallels.com>
Sat, 15 Mar 2014 17:19:13 +0000 (10:19 -0700)
Issue:
qla4xxx Unable to clear DDB indices when logout fails due to
failure of connection close mbox command.

Root cause:
If login to session fail, iscsiadm make call to destroy_session.
qla4xxx driver does not free ddb index map before free_ddb()

Fix:
Clear DDB Index map before free_ddb in "destroy_session"
in case of connection close mailbox command failure with 4005h.

Signed-off-by: Nilesh Javali <nilesh.javali@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/qla4xxx/ql4_def.h
drivers/scsi/qla4xxx/ql4_fw.h
drivers/scsi/qla4xxx/ql4_mbx.c
drivers/scsi/qla4xxx/ql4_os.c

index 4e1113370faf0af8050b383514ddb2a438add9c5..33eae2e12dbaabf635a8ce6e74642e18a0bf083f 100644 (file)
@@ -297,6 +297,8 @@ struct ddb_entry {
 
        /* Driver Re-login  */
        unsigned long flags;              /* DDB Flags */
+#define DDB_CONN_CLOSE_FAILURE         0 /* 0x00000001 */
+
        uint16_t default_relogin_timeout; /*  Max time to wait for
                                           *  relogin to complete */
        atomic_t retry_relogin_timer;     /* Min Time between relogins
index e3242df75b98543bd391a8e8bb56bb46678f2655..a94593ab0067213bb4ac7e4f7936e028665cdc2f 100644 (file)
@@ -390,6 +390,7 @@ struct qla_flt_region {
 #define MBOX_CMD_CLEAR_DATABASE_ENTRY          0x0031
 #define MBOX_CMD_CONN_OPEN                     0x0074
 #define MBOX_CMD_CONN_CLOSE_SESS_LOGOUT                0x0056
+#define DDB_NOT_LOGGED_IN                      0x09
 #define LOGOUT_OPTION_CLOSE_SESSION            0x0002
 #define LOGOUT_OPTION_RELOGIN                  0x0004
 #define LOGOUT_OPTION_FREE_DDB                 0x0008
index 9ae8ca3b69f937ddfaf4527d97f6625c6ad2a4b6..f0dc6b321c8d508326cdcd40723663440e4df461 100644 (file)
@@ -1002,6 +1002,10 @@ int qla4xxx_session_logout_ddb(struct scsi_qla_host *ha,
                                  "%s: MBOX_CMD_CONN_CLOSE_SESS_LOGOUT "
                                  "failed sts %04X %04X", __func__,
                                  mbox_sts[0], mbox_sts[1]));
+               if ((mbox_sts[0] == MBOX_STS_COMMAND_ERROR) &&
+                   (mbox_sts[1] == DDB_NOT_LOGGED_IN)) {
+                       set_bit(DDB_CONN_CLOSE_FAILURE, &ddb_entry->flags);
+               }
        }
 
        return status;
index a78edc3b3d3b35062632667070f5d0deda6eff3a..3fec116e2724f29e5c8a1e5afe1cd6b243561959 100644 (file)
@@ -3074,6 +3074,7 @@ qla4xxx_session_create(struct iscsi_endpoint *ep,
        ddb_entry->sess = cls_sess;
        ddb_entry->unblock_sess = qla4xxx_unblock_ddb;
        ddb_entry->ddb_change = qla4xxx_ddb_change;
+       clear_bit(DDB_CONN_CLOSE_FAILURE, &ddb_entry->flags);
        cls_sess->recovery_tmo = ql4xsess_recovery_tmo;
        ha->fw_ddb_index_map[ddb_entry->fw_ddb_index] = ddb_entry;
        ha->tot_ddbs++;
@@ -3123,7 +3124,8 @@ static void qla4xxx_session_destroy(struct iscsi_cls_session *cls_sess)
 
 destroy_session:
        qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index);
-
+       if (test_and_clear_bit(DDB_CONN_CLOSE_FAILURE, &ddb_entry->flags))
+               clear_bit(ddb_entry->fw_ddb_index, ha->ddb_idx_map);
        spin_lock_irqsave(&ha->hardware_lock, flags);
        qla4xxx_free_ddb(ha, ddb_entry);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);