target: pass a device name to an alua user helper

Submitted by Andrei Vagin on Jan. 27, 2018, 5:16 p.m.

Details

Message ID 1517073414-23645-1-git-send-email-avagin@openvz.org
State New
Series "target: pass a device name to an alua user helper"
Headers show

Commit Message

Andrei Vagin Jan. 27, 2018, 5:16 p.m.
Now the helper is executed with this list of arguments:
TG_PT_Group ID prev_state new_state {explicit/implicit} dev_name

For exmaple:
default_tg_pt_gp 0 Active/Optimized Standby explicit iqn.2014-06.com.vstorage:test-2

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

Patch hide | download patch | download mbox

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index a88a51d..c59bf69 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1028,13 +1028,14 @@  static void core_alua_do_transition_ua(struct t10_alua_tg_pt_gp *tg_pt_gp)
 	spin_unlock(&tg_pt_gp->tg_pt_gp_lock);
 }
 
-static int core_alua_usermode_helper(struct t10_alua_tg_pt_gp *tg_pt_gp, int new_state, int explicit)
+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)
 {
 	char *envp[] = { "HOME=/",
 			"TERM=linux",
 			"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
 			NULL };
-	char *argv[7] = {}, str_id[6];
+	char *argv[8] = {}, str_id[6];
 	int ret;
 
 	if (!tg_pt_gp->tg_pt_gp_usermode_helper)
@@ -1057,7 +1058,8 @@  static int core_alua_usermode_helper(struct t10_alua_tg_pt_gp *tg_pt_gp, int new
 	argv[3] = core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_access_state);
 	argv[4] = core_alua_dump_state(new_state);
 	argv[5] = (explicit) ? "explicit" : "implicit";
-	argv[6] = NULL;
+	argv[6] = config_item_name(&l_dev->dev_group.cg_item);
+	argv[7] = NULL;
 
 	ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC | UMH_KILLABLE);
 	pr_debug("helper command: %s exit code %u (0x%x)\n",
@@ -1068,12 +1070,13 @@  static int core_alua_usermode_helper(struct t10_alua_tg_pt_gp *tg_pt_gp, int new
 
 static int core_alua_do_transition_tg_pt(
 	struct t10_alua_tg_pt_gp *tg_pt_gp,
+	struct se_device *l_dev,
 	int new_state,
 	int explicit)
 {
 	int prev_state;
 
-	if (core_alua_usermode_helper(tg_pt_gp, new_state, explicit))
+	if (core_alua_usermode_helper(tg_pt_gp, l_dev, new_state, explicit))
 		return -EAGAIN;
 
 	mutex_lock(&tg_pt_gp->tg_pt_gp_transition_mutex);
@@ -1181,7 +1184,7 @@  int core_alua_do_port_transition(
 		 */
 		l_tg_pt_gp->tg_pt_gp_alua_port = l_port;
 		l_tg_pt_gp->tg_pt_gp_alua_nacl = l_nacl;
-		rc = core_alua_do_transition_tg_pt(l_tg_pt_gp,
+		rc = core_alua_do_transition_tg_pt(l_tg_pt_gp, l_dev,
 						   new_state, explicit);
 		atomic_dec_mb(&lu_gp->lu_gp_ref_cnt);
 		return rc;
@@ -1230,7 +1233,7 @@  int core_alua_do_port_transition(
 			 * core_alua_do_transition_tg_pt() will always return
 			 * success.
 			 */
-			rc = core_alua_do_transition_tg_pt(tg_pt_gp,
+			rc = core_alua_do_transition_tg_pt(tg_pt_gp, l_dev,
 					new_state, explicit);
 
 			spin_lock(&dev->t10_alua.tg_pt_gps_lock);