From 7d5024a1ee009842950c88084d64c812c9618b41 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 30 May 2018 04:15:29 -0400 Subject: [PATCH] alua: allow handlers missing lock routine Signed-off-by: Prasanna Kumar Kalever Signed-off-by: Xiubo Li --- alua.c | 24 +++++++----------------- alua.h | 2 +- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/alua.c b/alua.c index 136a15df..d173d327 100644 --- a/alua.c +++ b/alua.c @@ -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; @@ -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 @@ -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); @@ -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; @@ -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; @@ -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: @@ -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"); @@ -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; } diff --git a/alua.h b/alua.h index dd136c2f..a2959d84 100644 --- a/alua.h +++ b/alua.h @@ -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