Blame SOURCES/0242-RHBZ-1541116-all-tg-pt.patch

4ae388
---
4ae388
 libmpathpersist/mpath_persist.c |   28 +++++++++++---
4ae388
 libmultipath/config.c           |    3 +
4ae388
 libmultipath/config.h           |    2 +
4ae388
 libmultipath/defaults.h         |    1 
4ae388
 libmultipath/dict.c             |   77 ++++++++++++++++++++++++++++++++++++++++
4ae388
 libmultipath/propsel.c          |   20 ++++++++++
4ae388
 libmultipath/propsel.h          |    1 
4ae388
 libmultipath/structs.h          |    7 +++
4ae388
 multipath/multipath.conf.5      |    7 +++
4ae388
 9 files changed, 140 insertions(+), 6 deletions(-)
4ae388
4ae388
Index: multipath-tools-130222-patched/libmpathpersist/mpath_persist.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmpathpersist/mpath_persist.c
4ae388
+++ multipath-tools-130222-patched/libmpathpersist/mpath_persist.c
4ae388
@@ -287,6 +287,7 @@ int mpath_persistent_reserve_out ( int f
4ae388
 	}
4ae388
 
4ae388
 	select_reservation_key(mpp);
4ae388
+	select_all_tg_pt(mpp);
4ae388
 
4ae388
 	memcpy(&prkey, paramp->sa_key, 8);
4ae388
 	if (mpp->prkey_source == PRKEY_SOURCE_FILE && prkey &&
4ae388
@@ -419,7 +420,7 @@ int mpath_prout_reg(struct multipath *mp
4ae388
 	unsigned int rq_type, struct prout_param_descriptor * paramp, int noisy)
4ae388
 {
4ae388
 
4ae388
-	int i, j;
4ae388
+	int i, j, k;
4ae388
 	struct pathgroup *pgp = NULL;
4ae388
 	struct path *pp = NULL;
4ae388
 	int rollback = 0;
4ae388
@@ -444,11 +445,13 @@ int mpath_prout_reg(struct multipath *mp
4ae388
 	}
4ae388
 
4ae388
 	struct threadinfo thread[active_pathcount];
4ae388
+	int hosts[active_pathcount];
4ae388
 
4ae388
 	memset(thread, 0, sizeof(thread));
4ae388
 
4ae388
 	/* init thread parameter */
4ae388
 	for (i =0; i< active_pathcount; i++){
4ae388
+		hosts[i] = -1;
4ae388
 		thread[i].param.rq_servact = rq_servact;
4ae388
 		thread[i].param.rq_scope = rq_scope;
4ae388
 		thread[i].param.rq_type = rq_type;
4ae388
@@ -476,6 +479,17 @@ int mpath_prout_reg(struct multipath *mp
4ae388
 				condlog (1, "%s: %s path not up. Skip.", mpp->wwid, pp->dev);
4ae388
 				continue;
4ae388
 			}
4ae388
+			if (mpp->all_tg_pt == ALL_TG_PT_ON &&
4ae388
+			    pp->sg_id.host_no != -1) {
4ae388
+				for (k = 0; k < count; k++) {
4ae388
+					if (pp->sg_id.host_no == hosts[k]) {
4ae388
+						condlog(3, "%s: %s host %d matches skip.", pp->wwid, pp->dev, pp->sg_id.host_no);
4ae388
+						break;
4ae388
+					}
4ae388
+				}
4ae388
+				if (k < count)
4ae388
+					continue;
4ae388
+			}
4ae388
 			strncpy(thread[count].param.dev, pp->dev, FILE_NAME_SIZE);
4ae388
 
4ae388
 			if (count && (thread[count].param.paramp->sa_flags & MPATH_F_SPEC_I_PT_MASK)){
4ae388
@@ -492,10 +506,12 @@ int mpath_prout_reg(struct multipath *mp
4ae388
 				condlog (0, "%s: failed to create thread %d", mpp->wwid, rc);
4ae388
 				thread[count].param.status = MPATH_PR_THREAD_ERROR;
4ae388
 			}
4ae388
+			else
4ae388
+				hosts[count] = pp->sg_id.host_no;
4ae388
 			count = count +1;
4ae388
 		}
4ae388
 	}
4ae388
-	for( i=0; i < active_pathcount ; i++){
4ae388
+	for( i=0; i < count ; i++){
4ae388
 		if (thread[i].param.status != MPATH_PR_THREAD_ERROR) {
4ae388
 			rc = pthread_join(thread[i].id, NULL);
4ae388
 			if (rc){
4ae388
@@ -518,7 +534,7 @@ int mpath_prout_reg(struct multipath *mp
4ae388
 	}
4ae388
 	if (rollback && ((rq_servact == MPATH_PROUT_REG_SA) && sa_key != 0 )){
4ae388
 		condlog (3, "%s: ERROR: initiating pr out rollback", mpp->wwid);
4ae388
-		for( i=0 ; i < active_pathcount ; i++){
4ae388
+		for( i=0 ; i < count ; i++){
4ae388
 			if (thread[i].param.status == MPATH_PR_SUCCESS) {
4ae388
 				memcpy(&thread[i].param.paramp->key, &thread[i].param.paramp->sa_key, 8);
4ae388
 				memset(&thread[i].param.paramp->sa_key, 0, 8);
4ae388
@@ -532,7 +548,7 @@ int mpath_prout_reg(struct multipath *mp
4ae388
 			} else
4ae388
 				thread[i].param.status = MPATH_PR_SKIP;
4ae388
 		}
4ae388
-		for(i=0; i < active_pathcount ; i++){
4ae388
+		for(i=0; i < count ; i++){
4ae388
 			if (thread[i].param.status != MPATH_PR_SKIP &&
4ae388
 			    thread[i].param.status != MPATH_PR_THREAD_ERROR) {
4ae388
 				rc = pthread_join(thread[i].id, NULL);
4ae388
@@ -678,7 +694,7 @@ int mpath_prout_rel(struct multipath *mp
4ae388
 		}
4ae388
 	}
4ae388
 	pthread_attr_destroy (&attr);
4ae388
-	for (i = 0; i < active_pathcount; i++){
4ae388
+	for (i = 0; i < count; i++){
4ae388
 		if (thread[i].param.status != MPATH_PR_THREAD_ERROR) {
4ae388
 			rc = pthread_join (thread[i].id, NULL);
4ae388
 			if (rc){
4ae388
@@ -687,7 +703,7 @@ int mpath_prout_rel(struct multipath *mp
4ae388
 		}
4ae388
 	}
4ae388
 
4ae388
-	for (i = 0; i < active_pathcount; i++){
4ae388
+	for (i = 0; i < count; i++){
4ae388
 		/*  check thread status here and return the status */
4ae388
 
4ae388
 		if (thread[i].param.status == MPATH_PR_RESERV_CONFLICT)
4ae388
Index: multipath-tools-130222-patched/libmultipath/config.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmultipath/config.c
4ae388
+++ multipath-tools-130222-patched/libmultipath/config.c
4ae388
@@ -349,6 +349,7 @@ merge_hwe (struct hwentry * dst, struct
4ae388
 	merge_num(max_sectors_kb);
4ae388
 	merge_num(unpriv_sgio);
4ae388
 	merge_num(ghost_delay);
4ae388
+	merge_num(all_tg_pt);
4ae388
 
4ae388
 	/*
4ae388
 	 * Make sure features is consistent with
4ae388
@@ -414,6 +415,7 @@ overwrite_hwe (struct hwentry * dst, str
4ae388
 	overwrite_num(max_sectors_kb);
4ae388
 	overwrite_num(unpriv_sgio);
4ae388
 	overwrite_num(ghost_delay);
4ae388
+	overwrite_num(all_tg_pt);
4ae388
 
4ae388
 	/*
4ae388
 	 * Make sure features is consistent with
4ae388
@@ -700,6 +702,7 @@ load_config (char * file, struct udev *u
4ae388
 	conf->max_sectors_kb = DEFAULT_MAX_SECTORS_KB;
4ae388
 	conf->unpriv_sgio = DEFAULT_UNPRIV_SGIO;
4ae388
 	conf->ghost_delay = DEFAULT_GHOST_DELAY;
4ae388
+	conf->all_tg_pt = DEFAULT_ALL_TG_PT;
4ae388
 
4ae388
 	/*
4ae388
 	 * preload default hwtable
4ae388
Index: multipath-tools-130222-patched/libmultipath/config.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmultipath/config.h
4ae388
+++ multipath-tools-130222-patched/libmultipath/config.h
4ae388
@@ -71,6 +71,7 @@ struct hwentry {
4ae388
 	int max_sectors_kb;
4ae388
 	int unpriv_sgio;
4ae388
 	int ghost_delay;
4ae388
+	int all_tg_pt;
4ae388
 	char * bl_product;
4ae388
 };
4ae388
 
4ae388
@@ -162,6 +163,7 @@ struct config {
4ae388
 	int max_sectors_kb;
4ae388
 	int unpriv_sgio;
4ae388
 	int ghost_delay;
4ae388
+	int all_tg_pt;
4ae388
 	unsigned int version[3];
4ae388
 
4ae388
 	char * dev;
4ae388
Index: multipath-tools-130222-patched/libmultipath/dict.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmultipath/dict.c
4ae388
+++ multipath-tools-130222-patched/libmultipath/dict.c
4ae388
@@ -1051,6 +1051,29 @@ def_ghost_delay_handler(vector strvec)
4ae388
 	return 0;
4ae388
 }
4ae388
 
4ae388
+static int
4ae388
+def_all_tg_pt_handler(vector strvec)
4ae388
+{
4ae388
+        char * buff;
4ae388
+
4ae388
+        buff = set_value(strvec);
4ae388
+        if (!buff)
4ae388
+                return 1;
4ae388
+
4ae388
+        if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
4ae388
+            (strlen(buff) == 1 && !strcmp(buff, "0")))
4ae388
+                conf->all_tg_pt = ALL_TG_PT_OFF;
4ae388
+        else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
4ae388
+                 (strlen(buff) == 1 && !strcmp(buff, "1")))
4ae388
+                conf->all_tg_pt = ALL_TG_PT_ON;
4ae388
+        else
4ae388
+                conf->all_tg_pt = DEFAULT_ALL_TG_PT;
4ae388
+
4ae388
+        FREE(buff);
4ae388
+        return 0;
4ae388
+}
4ae388
+
4ae388
+
4ae388
 /*
4ae388
  * blacklist block handlers
4ae388
  */
4ae388
@@ -1969,6 +1992,33 @@ hw_ghost_delay_handler(vector strvec)
4ae388
 	return 0;
4ae388
 }
4ae388
 
4ae388
+static int
4ae388
+hw_all_tg_pt_handler(vector strvec)
4ae388
+{
4ae388
+	struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
4ae388
+	char * buff;
4ae388
+
4ae388
+	if (!hwe)
4ae388
+		return 1;
4ae388
+
4ae388
+	buff = set_value(strvec);
4ae388
+
4ae388
+	if (!buff)
4ae388
+		return 1;
4ae388
+
4ae388
+	if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
4ae388
+	    (strlen(buff) == 1 && !strcmp(buff, "0")))
4ae388
+		hwe->all_tg_pt = ALL_TG_PT_OFF;
4ae388
+	else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
4ae388
+		 (strlen(buff) == 1 && !strcmp(buff, "1")))
4ae388
+		hwe->all_tg_pt = ALL_TG_PT_ON;
4ae388
+	else
4ae388
+		hwe->all_tg_pt = ALL_TG_PT_UNDEF;
4ae388
+
4ae388
+	FREE(buff);
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
 /*
4ae388
  * multipaths block handlers
4ae388
  */
4ae388
@@ -3325,6 +3375,19 @@ snprint_hw_ghost_delay (char * buff, int
4ae388
 }
4ae388
 
4ae388
 static int
4ae388
+snprint_hw_all_tg_pt(char * buff, int len, void * data)
4ae388
+{
4ae388
+	struct hwentry * hwe = (struct hwentry *)data;
4ae388
+
4ae388
+	if (hwe->all_tg_pt == ALL_TG_PT_ON)
4ae388
+		return snprintf(buff, len, "yes");
4ae388
+	else if (hwe->all_tg_pt == ALL_TG_PT_OFF)
4ae388
+		return snprintf(buff, len, "no");
4ae388
+	else
4ae388
+		return 0;
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
 snprint_def_polling_interval (char * buff, int len, void * data)
4ae388
 {
4ae388
 	return snprintf(buff, len, "%i", conf->checkint);
4ae388
@@ -3829,6 +3892,15 @@ snprint_def_ghost_delay (char * buff, in
4ae388
 }
4ae388
 
4ae388
 static int
4ae388
+snprint_def_all_tg_pt(char * buff, int len, void * data)
4ae388
+{
4ae388
+	if (conf->all_tg_pt == ALL_TG_PT_ON)
4ae388
+		return snprintf(buff, len, "yes");
4ae388
+	else
4ae388
+		return snprintf(buff, len, "no");
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
 snprint_ble_simple (char * buff, int len, void * data)
4ae388
 {
4ae388
 	struct blentry * ble = (struct blentry *)data;
4ae388
@@ -3926,6 +3998,7 @@ init_keywords(void)
4ae388
 	install_keyword("max_sectors_kb", &def_max_sectors_kb_handler, &snprint_def_max_sectors_kb);
4ae388
 	install_keyword("unpriv_sgio", &def_unpriv_sgio_handler, &snprint_def_unpriv_sgio);
4ae388
 	install_keyword("ghost_delay", &def_ghost_delay_handler, &snprint_def_ghost_delay);
4ae388
+	install_keyword("all_tg_pt", &def_all_tg_pt_handler, &snprint_def_all_tg_pt);
4ae388
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
4ae388
 	__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
4ae388
 	__deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
4ae388
@@ -4000,6 +4073,7 @@ init_keywords(void)
4ae388
 	install_keyword("max_sectors_kb", &hw_max_sectors_kb_handler, &snprint_hw_max_sectors_kb);
4ae388
 	install_keyword("unpriv_sgio", &hw_unpriv_sgio_handler, &snprint_hw_unpriv_sgio);
4ae388
 	install_keyword("ghost_delay", &hw_ghost_delay_handler, &snprint_hw_ghost_delay);
4ae388
+	install_keyword("all_tg_pt", &hw_all_tg_pt_handler, &snprint_hw_all_tg_pt);
4ae388
 	install_sublevel_end();
4ae388
 
4ae388
 	install_keyword_root("overrides", &nop_handler);
4ae388
@@ -4031,6 +4105,9 @@ init_keywords(void)
4ae388
 	install_keyword("delay_wait_checks", &nop_handler, &snprint_nop);
4ae388
 	install_keyword("skip_kpartx", &nop_handler, &snprint_nop);
4ae388
 	install_keyword("max_sectors_kb", &nop_handler, &snprint_nop);
4ae388
+	install_keyword("unpriv_sgio", &nop_handler, &snprint_nop);
4ae388
+	install_keyword("ghost_delay", &nop_handler, &snprint_nop);
4ae388
+	install_keyword("all_tg_pt", &nop_handler, &snprint_nop);
4ae388
 
4ae388
 	install_keyword_root("multipaths", &multipaths_handler);
4ae388
 	install_keyword_multi("multipath", &multipath_handler, NULL);
4ae388
Index: multipath-tools-130222-patched/libmultipath/propsel.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmultipath/propsel.c
4ae388
+++ multipath-tools-130222-patched/libmultipath/propsel.c
4ae388
@@ -992,3 +992,23 @@ select_ghost_delay (struct multipath * m
4ae388
 	condlog(3, "ghost_delay = DISABLED (internal default)");
4ae388
 	return 0;
4ae388
 }
4ae388
+
4ae388
+extern int
4ae388
+select_all_tg_pt (struct multipath *mp)
4ae388
+{
4ae388
+	if (mp->hwe && mp->hwe->all_tg_pt != ALL_TG_PT_UNDEF) {
4ae388
+		mp->all_tg_pt = mp->hwe->all_tg_pt;
4ae388
+		condlog(3, "all_tg_pt = %i (controller setting)",
4ae388
+			mp->all_tg_pt);
4ae388
+		return 0;
4ae388
+	}
4ae388
+	if (conf->all_tg_pt != GHOST_DELAY_UNDEF) {
4ae388
+		mp->all_tg_pt = conf->all_tg_pt;
4ae388
+		condlog(3, "all_tg_pt = %i (config file default)",
4ae388
+			mp->all_tg_pt);
4ae388
+		return 0;
4ae388
+	}
4ae388
+	mp->all_tg_pt = DEFAULT_ALL_TG_PT;
4ae388
+	condlog(3, "all_tg_pt = %i (internal default)", mp->all_tg_pt);
4ae388
+	return 0;
4ae388
+}
4ae388
Index: multipath-tools-130222-patched/libmultipath/structs.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmultipath/structs.h
4ae388
+++ multipath-tools-130222-patched/libmultipath/structs.h
4ae388
@@ -154,6 +154,12 @@ enum unpriv_sgio_states {
4ae388
 	UNPRIV_SGIO_ON,
4ae388
 };
4ae388
 
4ae388
+enum all_tg_pt_states {
4ae388
+	ALL_TG_PT_UNDEF,
4ae388
+	ALL_TG_PT_OFF,
4ae388
+	ALL_TG_PT_ON,
4ae388
+};
4ae388
+
4ae388
 enum scsi_protocol {
4ae388
 	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
4ae388
 	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
4ae388
@@ -324,6 +330,7 @@ struct multipath {
4ae388
 	int prkey_source;
4ae388
 	struct be64 reservation_key;
4ae388
 	unsigned char prflag;
4ae388
+	int all_tg_pt;
4ae388
 };
4ae388
 
4ae388
 struct pathgroup {
4ae388
Index: multipath-tools-130222-patched/libmultipath/propsel.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmultipath/propsel.h
4ae388
+++ multipath-tools-130222-patched/libmultipath/propsel.h
4ae388
@@ -28,3 +28,4 @@ int select_skip_kpartx (struct multipath
4ae388
 int select_max_sectors_kb (struct multipath * mp);
4ae388
 int select_unpriv_sgio (struct multipath * mp);
4ae388
 int select_ghost_delay (struct multipath * mp);
4ae388
+int select_all_tg_pt (struct multipath *mp);
4ae388
Index: multipath-tools-130222-patched/libmultipath/defaults.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/libmultipath/defaults.h
4ae388
+++ multipath-tools-130222-patched/libmultipath/defaults.h
4ae388
@@ -29,6 +29,7 @@
4ae388
 #define DEFAULT_MAX_SECTORS_KB	MAX_SECTORS_KB_UNDEF
4ae388
 #define DEFAULT_UNPRIV_SGIO UNPRIV_SGIO_OFF
4ae388
 #define DEFAULT_GHOST_DELAY GHOST_DELAY_OFF
4ae388
+#define DEFAULT_ALL_TG_PT ALL_TG_PT_OFF
4ae388
 
4ae388
 #define DEFAULT_CHECKINT	5
4ae388
 #define MAX_CHECKINT(a)		(a << 2)
4ae388
Index: multipath-tools-130222-patched/multipath/multipath.conf.5
4ae388
===================================================================
4ae388
--- multipath-tools-130222-patched.orig/multipath/multipath.conf.5
4ae388
+++ multipath-tools-130222-patched/multipath/multipath.conf.5
4ae388
@@ -449,6 +449,13 @@ registration is removed, the RESERVATION
4ae388
 It is unset by default.
4ae388
 .RE
4ae388
 .TP
4ae388
+.B all_tg_pt
4ae388
+This must be set to \fIyes\fR to successfully use mpathpersist on arrays that
4ae388
+automatically set and clear registration keys on all target ports from a
4ae388
+host, instead of per target port per host.
4ae388
+Default is
4ae388
+.I no
4ae388
+.TP
4ae388
 .B retain_attached_hw_handler
4ae388
 If set to
4ae388
 .I yes