Skip to content

Commit

Permalink
Merge pull request #424 from lxbsz/lock
Browse files Browse the repository at this point in the history
alua: allow handlers missing lock routine
  • Loading branch information
mikechristie committed May 30, 2018
2 parents 83664e9 + 7d5024a commit 815e5f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
24 changes: 7 additions & 17 deletions alua.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,6 @@ tcmu_get_alua_grp(struct tcmu_device *dev, const char *name)

group->tpgs = TPGS_ALUA_IMPLICIT;
} else if (!strcmp(str_val, "Implicit")) {
if (!failover_is_supported(dev)) {
tcmu_dev_err(dev, "device failover is not supported with the alua access type: Implicit\n");
goto free_str_val;
}

rdev->failover_type = TMCUR_DEV_FAILOVER_IMPLICIT;

group->tpgs = TPGS_ALUA_IMPLICIT;
Expand All @@ -227,11 +222,6 @@ tcmu_get_alua_grp(struct tcmu_device *dev, const char *name)

goto free_str_val;
} else if (!strcmp(str_val, "Implicit and Explicit")) {
if (!failover_is_supported(dev)) {
tcmu_dev_err(dev, "device failover is not supported with the alua access type: Implicit and Explicit\n");
goto free_str_val;
}

/*
* Only report explicit so initiator always sends STPG.
* We only need implicit enabled in the kernel so we can
Expand Down Expand Up @@ -544,7 +534,7 @@ int tcmu_emulate_report_tgt_port_grps(struct tcmu_device *dev,
return ret;
}

bool failover_is_supported(struct tcmu_device *dev)
bool lock_is_required(struct tcmu_device *dev)
{
struct tcmur_handler *rhandler = tcmu_get_runner_handler(dev);

Expand All @@ -564,6 +554,9 @@ int alua_implicit_transition(struct tcmu_device *dev, struct tcmulib_cmd *cmd)
pthread_attr_t attr;
int ret = TCMU_STS_OK;

if (!lock_is_required(dev))
return ret;

pthread_mutex_lock(&rdev->state_lock);
if (rdev->lock_state == TCMUR_DEV_LOCK_LOCKED) {
goto done;
Expand Down Expand Up @@ -647,7 +640,7 @@ static int tcmu_explicit_transition(struct list_head *group_list,

switch (new_state) {
case ALUA_ACCESS_STATE_OPTIMIZED:
if (!failover_is_supported(dev))
if (!lock_is_required(dev))
/* just change local state */
break;

Expand Down Expand Up @@ -684,7 +677,7 @@ static int tcmu_explicit_transition(struct list_head *group_list,
tcmu_dev_err(dev, "Igoring ANO/unavail/offline\n");
return TCMU_STS_INVALID_PARAM_LIST;
case ALUA_ACCESS_STATE_STANDBY:
if (failover_is_supported(dev))
if (lock_is_required(dev))
tcmu_release_dev_lock(dev);
break;
default:
Expand Down Expand Up @@ -777,9 +770,6 @@ int alua_check_state(struct tcmu_device *dev, struct tcmulib_cmd *cmd)
{
struct tcmur_device *rdev = tcmu_get_daemon_dev_private(dev);

if (!failover_is_supported(dev))
return 0;

if (rdev->failover_type == TMCUR_DEV_FAILOVER_EXPLICIT) {
if (rdev->lock_state != TCMUR_DEV_LOCK_LOCKED) {
tcmu_dev_dbg(dev, "device lock not held.\n");
Expand All @@ -789,5 +779,5 @@ int alua_check_state(struct tcmu_device *dev, struct tcmulib_cmd *cmd)
return alua_implicit_transition(dev, cmd);
}

return 0;
return TCMU_STS_OK;
}
2 changes: 1 addition & 1 deletion alua.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct tgt_port *tcmu_get_enabled_port(struct list_head *);
int tcmu_get_alua_grps(struct tcmu_device *, struct list_head *);
void tcmu_release_alua_grps(struct list_head *);
int alua_implicit_transition(struct tcmu_device *dev, struct tcmulib_cmd *cmd);
bool failover_is_supported(struct tcmu_device *dev);
bool lock_is_required(struct tcmu_device *dev);
int alua_check_state(struct tcmu_device *dev, struct tcmulib_cmd *cmd);

#endif

0 comments on commit 815e5f8

Please sign in to comment.