[Devel] [PATCH 2/2] target: call alua helper before reporting group states to initiator

Andrei Vagin avagin at openvz.org
Thu Feb 1 04:40:14 MSK 2018


An alua helper is called with the same set of arguments as it is called
when a group state is changed, but the fourth argument will be "Read".

For example:
 default_tg_pt_gp 0 Active/Optimized Read implicit iqn.2014-06.com.vstorage:test-1

Signed-off-by: Andrei Vagin <avagin at openvz.org>
---
 drivers/target/target_core_alua.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 46c8beb..f1c1733 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -138,6 +138,8 @@ target_emulate_report_referrals(struct se_cmd *cmd)
 	return 0;
 }
 
+static int core_alua_usermode_helper(struct t10_alua_tg_pt_gp *tg_pt_gp,
+			struct se_device *l_dev, int new_state, int explicit);
 /*
  * REPORT_TARGET_PORT_GROUPS
  *
@@ -173,6 +175,8 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd)
 	if (!buf)
 		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 
+	core_alua_usermode_helper(dev->t10_alua.default_tg_pt_gp, dev, -1, 0);
+
 	spin_lock(&dev->t10_alua.tg_pt_gps_lock);
 	list_for_each_entry(tg_pt_gp, &dev->t10_alua.tg_pt_gps_list,
 			tg_pt_gp_list) {
@@ -1046,7 +1050,7 @@ static int core_alua_usermode_helper(struct t10_alua_tg_pt_gp *tg_pt_gp,
 	argv[1] = config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item);
 	argv[2] = str_id;
 	argv[3] = core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_access_state);
-	argv[4] = core_alua_dump_state(new_state);
+	argv[4] = new_state < 0 ? "Read" : core_alua_dump_state(new_state);
 	argv[5] = (explicit) ? "explicit" : "implicit";
 	argv[6] = config_item_name(&l_dev->dev_group.cg_item);
 	argv[7] = NULL;
-- 
1.8.3.1



More information about the Devel mailing list