Commit 1ca4d4fa authored by Mike Christie's avatar Mike Christie Committed by Nicholas Bellinger

target: allow userspace to set state to transitioning

Userspace target_core_user handlers like tcmu-runner may want to set the
ALUA state to transitioning while it does implicit transitions. This
patch allows that state when set from configfs.
Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent d7175373
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include "target_core_ua.h" #include "target_core_ua.h"
static sense_reason_t core_alua_check_transition(int state, int valid, static sense_reason_t core_alua_check_transition(int state, int valid,
int *primary); int *primary, int explicit);
static int core_alua_set_tg_pt_secondary_state( static int core_alua_set_tg_pt_secondary_state(
struct se_lun *lun, int explicit, int offline); struct se_lun *lun, int explicit, int offline);
...@@ -335,8 +335,8 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd) ...@@ -335,8 +335,8 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd)
* the state is a primary or secondary target port asymmetric * the state is a primary or secondary target port asymmetric
* access state. * access state.
*/ */
rc = core_alua_check_transition(alua_access_state, rc = core_alua_check_transition(alua_access_state, valid_states,
valid_states, &primary); &primary, 1);
if (rc) { if (rc) {
/* /*
* If the SET TARGET PORT GROUPS attempts to establish * If the SET TARGET PORT GROUPS attempts to establish
...@@ -762,7 +762,7 @@ target_alua_state_check(struct se_cmd *cmd) ...@@ -762,7 +762,7 @@ target_alua_state_check(struct se_cmd *cmd)
* Check implicit and explicit ALUA state change request. * Check implicit and explicit ALUA state change request.
*/ */
static sense_reason_t static sense_reason_t
core_alua_check_transition(int state, int valid, int *primary) core_alua_check_transition(int state, int valid, int *primary, int explicit)
{ {
/* /*
* OPTIMIZED, NON-OPTIMIZED, STANDBY and UNAVAILABLE are * OPTIMIZED, NON-OPTIMIZED, STANDBY and UNAVAILABLE are
...@@ -804,11 +804,14 @@ core_alua_check_transition(int state, int valid, int *primary) ...@@ -804,11 +804,14 @@ core_alua_check_transition(int state, int valid, int *primary)
*primary = 0; *primary = 0;
break; break;
case ALUA_ACCESS_STATE_TRANSITION: case ALUA_ACCESS_STATE_TRANSITION:
if (!(valid & ALUA_T_SUP) || explicit)
/* /*
* Transitioning is set internally, and * Transitioning is set internally and by tcmu daemon,
* cannot be selected manually. * and cannot be selected through a STPG.
*/ */
goto not_supported; goto not_supported;
*primary = 0;
break;
default: default:
pr_err("Unknown ALUA access state: 0x%02x\n", state); pr_err("Unknown ALUA access state: 0x%02x\n", state);
return TCM_INVALID_PARAMETER_LIST; return TCM_INVALID_PARAMETER_LIST;
...@@ -1070,7 +1073,7 @@ static int core_alua_do_transition_tg_pt( ...@@ -1070,7 +1073,7 @@ static int core_alua_do_transition_tg_pt(
if (atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state) == new_state) if (atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state) == new_state)
return 0; return 0;
if (new_state == ALUA_ACCESS_STATE_TRANSITION) if (explicit && new_state == ALUA_ACCESS_STATE_TRANSITION)
return -EAGAIN; return -EAGAIN;
/* /*
...@@ -1091,10 +1094,6 @@ static int core_alua_do_transition_tg_pt( ...@@ -1091,10 +1094,6 @@ static int core_alua_do_transition_tg_pt(
* Save the old primary ALUA access state, and set the current state * Save the old primary ALUA access state, and set the current state
* to ALUA_ACCESS_STATE_TRANSITION. * to ALUA_ACCESS_STATE_TRANSITION.
*/ */
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, atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state,
ALUA_ACCESS_STATE_TRANSITION); ALUA_ACCESS_STATE_TRANSITION);
tg_pt_gp->tg_pt_gp_alua_access_status = (explicit) ? tg_pt_gp->tg_pt_gp_alua_access_status = (explicit) ?
...@@ -1103,6 +1102,13 @@ static int core_alua_do_transition_tg_pt( ...@@ -1103,6 +1102,13 @@ static int core_alua_do_transition_tg_pt(
core_alua_queue_state_change_ua(tg_pt_gp); core_alua_queue_state_change_ua(tg_pt_gp);
if (new_state == ALUA_ACCESS_STATE_TRANSITION)
return 0;
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;
/* /*
* Check for the optional ALUA primary state transition delay * Check for the optional ALUA primary state transition delay
*/ */
...@@ -1144,7 +1150,8 @@ int core_alua_do_port_transition( ...@@ -1144,7 +1150,8 @@ int core_alua_do_port_transition(
return -ENODEV; return -ENODEV;
valid_states = l_tg_pt_gp->tg_pt_gp_alua_supported_states; valid_states = l_tg_pt_gp->tg_pt_gp_alua_supported_states;
if (core_alua_check_transition(new_state, valid_states, &primary) != 0) if (core_alua_check_transition(new_state, valid_states, &primary,
explicit) != 0)
return -EINVAL; return -EINVAL;
local_lu_gp_mem = l_dev->dev_alua_lu_gp_mem; local_lu_gp_mem = l_dev->dev_alua_lu_gp_mem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment