During state transition we should be storing both the original
and the pending state.

Signed-off-by: Hannes Reinecke <[email protected]>
---
 drivers/target/target_core_alua.c | 15 ++++++++++-----
 include/target/target_core_base.h |  6 ++++--
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/target/target_core_alua.c 
b/drivers/target/target_core_alua.c
index 3fa535c..5de2ea1 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -820,12 +820,15 @@ static int core_alua_do_transition_tg_pt(
        struct se_lun_acl *lacl;
        struct se_port *port;
        struct t10_alua_tg_pt_gp_member *mem;
-       int old_state = 0;
+
        /*
         * Save the old primary ALUA access state, and set the current state
         * to ALUA_ACCESS_STATE_TRANSITION.
         */
-       old_state = atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state);
+       tg_pt_gp->tg_pt_gp_alua_previous_state =
+               atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state);
+       tg_pt_gp->tg_pt_gp_alua_pending_state = new_state;
+
        atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state,
                        ALUA_ACCESS_STATE_TRANSITION);
        tg_pt_gp->tg_pt_gp_alua_status_modification = (explicit) ?
@@ -906,13 +909,15 @@ static int core_alua_do_transition_tg_pt(
        /*
         * Set the current primary ALUA access state to the requested new state
         */
-       atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, new_state);
+       atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state,
+                  tg_pt_gp->tg_pt_gp_alua_pending_state);
 
        pr_debug("Successful %s ALUA transition TG PT Group: %s ID: %hu"
                " from primary access state %s to %s\n", (explicit) ? 
"explicit" :
                "implicit", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item),
-               tg_pt_gp->tg_pt_gp_id, core_alua_dump_state(old_state),
-               core_alua_dump_state(new_state));
+               tg_pt_gp->tg_pt_gp_id,
+               core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_previous_state),
+               core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_pending_state));
 
        return 0;
 }
diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index faf7de0..b8b7ec8 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -283,8 +283,10 @@ struct t10_alua_lu_gp_member {
 struct t10_alua_tg_pt_gp {
        u16     tg_pt_gp_id;
        int     tg_pt_gp_valid_id;
-       int     tg_pt_gp_alua_supported_states;
-       int     tg_pt_gp_alua_status_modification;
+       u8      tg_pt_gp_alua_pending_state;
+       u8      tg_pt_gp_alua_previous_state;
+       u8      tg_pt_gp_alua_supported_states;
+       u8      tg_pt_gp_alua_status_modification;
        int     tg_pt_gp_alua_mgmt_type;
        int     tg_pt_gp_nonop_delay_msecs;
        int     tg_pt_gp_trans_delay_msecs;
-- 
1.7.12.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to