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

Submitted by Andrei Vagin on Feb. 1, 2018, 1:40 a.m.

Details

Message ID 1517449214-8249-2-git-send-email-avagin@openvz.org
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrei Vagin Feb. 1, 2018, 1:40 a.m.
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@openvz.org>
---
 drivers/target/target_core_alua.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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;