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

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