Blame SOURCES/0124-RHBZ-1209275-retrigger-uevents.patch

ecd2a9
---
ecd2a9
 libmultipath/config.c    |    2 ++
ecd2a9
 libmultipath/config.h    |    2 ++
ecd2a9
 libmultipath/defaults.h  |    2 ++
ecd2a9
 libmultipath/dict.c      |   46 ++++++++++++++++++++++++++++++++++++++++++++++
ecd2a9
 libmultipath/discovery.c |    8 +++++---
ecd2a9
 libmultipath/structs.h   |    8 ++++++++
ecd2a9
 multipathd/main.c        |   15 ++++++++++++++-
ecd2a9
 7 files changed, 79 insertions(+), 4 deletions(-)
ecd2a9
ecd2a9
Index: multipath-tools-130222/libmultipath/config.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/config.c
ecd2a9
+++ multipath-tools-130222/libmultipath/config.c
ecd2a9
@@ -673,6 +673,8 @@ load_config (char * file, struct udev *u
ecd2a9
 	conf->force_sync = 0;
ecd2a9
 	conf->ignore_new_boot_devs = 0;
ecd2a9
 	conf->processed_main_config = 0;
ecd2a9
+	conf->retrigger_tries = DEFAULT_RETRIGGER_TRIES;
ecd2a9
+	conf->retrigger_delay = DEFAULT_RETRIGGER_DELAY;
ecd2a9
 
ecd2a9
 	/*
ecd2a9
 	 * preload default hwtable
ecd2a9
Index: multipath-tools-130222/libmultipath/config.h
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/config.h
ecd2a9
+++ multipath-tools-130222/libmultipath/config.h
ecd2a9
@@ -139,6 +139,8 @@ struct config {
ecd2a9
 	int processed_main_config;
ecd2a9
 	int delay_watch_checks;
ecd2a9
 	int delay_wait_checks;
ecd2a9
+	int retrigger_tries;
ecd2a9
+	int retrigger_delay;
ecd2a9
 	unsigned int version[3];
ecd2a9
 
ecd2a9
 	char * dev;
ecd2a9
Index: multipath-tools-130222/libmultipath/defaults.h
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/defaults.h
ecd2a9
+++ multipath-tools-130222/libmultipath/defaults.h
ecd2a9
@@ -21,6 +21,8 @@
ecd2a9
 #define DEFAULT_DETECT_PRIO DETECT_PRIO_OFF
ecd2a9
 #define DEFAULT_DEFERRED_REMOVE DEFERRED_REMOVE_OFF
ecd2a9
 #define DEFAULT_DELAY_CHECKS DELAY_CHECKS_OFF
ecd2a9
+#define DEFAULT_RETRIGGER_DELAY 10
ecd2a9
+#define DEFAULT_RETRIGGER_TRIES 3
ecd2a9
 
ecd2a9
 #define DEFAULT_CHECKINT	5
ecd2a9
 #define MAX_CHECKINT(a)		(a << 2)
ecd2a9
Index: multipath-tools-130222/libmultipath/dict.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/dict.c
ecd2a9
+++ multipath-tools-130222/libmultipath/dict.c
ecd2a9
@@ -839,6 +839,38 @@ def_delay_wait_checks_handler(vector str
ecd2a9
 	return 0;
ecd2a9
 }
ecd2a9
 
ecd2a9
+static int
ecd2a9
+def_retrigger_tries_handler(vector strvec)
ecd2a9
+{
ecd2a9
+	char * buff;
ecd2a9
+
ecd2a9
+	buff = set_value(strvec);
ecd2a9
+
ecd2a9
+	if (!buff)
ecd2a9
+		return 1;
ecd2a9
+
ecd2a9
+	conf->retrigger_tries = atoi(buff);
ecd2a9
+	FREE(buff);
ecd2a9
+
ecd2a9
+	return 0;
ecd2a9
+}
ecd2a9
+
ecd2a9
+static int
ecd2a9
+def_retrigger_delay_handler(vector strvec)
ecd2a9
+{
ecd2a9
+	char * buff;
ecd2a9
+
ecd2a9
+	buff = set_value(strvec);
ecd2a9
+
ecd2a9
+	if (!buff)
ecd2a9
+		return 1;
ecd2a9
+
ecd2a9
+	conf->retrigger_delay = atoi(buff);
ecd2a9
+	FREE(buff);
ecd2a9
+
ecd2a9
+	return 0;
ecd2a9
+}
ecd2a9
+
ecd2a9
 /*
ecd2a9
  * blacklist block handlers
ecd2a9
  */
ecd2a9
@@ -3194,6 +3226,18 @@ snprint_def_delay_wait_checks(char * buf
ecd2a9
 }
ecd2a9
 
ecd2a9
 static int
ecd2a9
+snprint_def_retrigger_tries (char * buff, int len, void * data)
ecd2a9
+{
ecd2a9
+	return snprintf(buff, len, "%i", conf->retrigger_tries);
ecd2a9
+}
ecd2a9
+
ecd2a9
+static int
ecd2a9
+snprint_def_retrigger_delay (char * buff, int len, void * data)
ecd2a9
+{
ecd2a9
+	return snprintf(buff, len, "%i", conf->retrigger_delay);
ecd2a9
+}
ecd2a9
+
ecd2a9
+static int
ecd2a9
 snprint_ble_simple (char * buff, int len, void * data)
ecd2a9
 {
ecd2a9
 	struct blentry * ble = (struct blentry *)data;
ecd2a9
@@ -3267,6 +3311,8 @@ init_keywords(void)
ecd2a9
 	install_keyword("config_dir", &def_config_dir_handler, &snprint_def_config_dir);
ecd2a9
 	install_keyword("delay_watch_checks", &def_delay_watch_checks_handler, &snprint_def_delay_watch_checks);
ecd2a9
 	install_keyword("delay_wait_checks", &def_delay_wait_checks_handler, &snprint_def_delay_wait_checks);
ecd2a9
+	install_keyword("retrigger_tries", &def_retrigger_tries_handler, &snprint_def_retrigger_tries);
ecd2a9
+	install_keyword("retrigger_delay", &def_retrigger_delay_handler, &snprint_def_retrigger_delay);
ecd2a9
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
ecd2a9
 	__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
ecd2a9
 	__deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
ecd2a9
Index: multipath-tools-130222/libmultipath/discovery.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/discovery.c
ecd2a9
+++ multipath-tools-130222/libmultipath/discovery.c
ecd2a9
@@ -1111,9 +1111,13 @@ get_uid (struct path * pp)
ecd2a9
 			len = strlen(value);
ecd2a9
 		}
ecd2a9
 		strncpy(pp->wwid, value, len);
ecd2a9
+		pp->missing_udev_info = INFO_OK;
ecd2a9
+		pp->tick = 0;
ecd2a9
 	} else {
ecd2a9
 		condlog(3, "%s: no %s attribute", pp->dev,
ecd2a9
 			pp->uid_attribute);
ecd2a9
+		pp->missing_udev_info = INFO_MISSING;
ecd2a9
+		pp->tick = conf->retrigger_delay;
ecd2a9
 	}
ecd2a9
 
ecd2a9
 	/* Strip any trailing blanks */
ecd2a9
@@ -1201,10 +1205,8 @@ pathinfo (struct path *pp, vector hwtabl
ecd2a9
 	  * Retrieve path priority, even for PATH_DOWN paths if it has never
ecd2a9
 	  * been successfully obtained before.
ecd2a9
 	  */
ecd2a9
-	if ((mask & DI_PRIO) && path_state == PATH_UP) {
ecd2a9
+	if ((mask & DI_PRIO) && path_state == PATH_UP && strlen(pp->wwid)) {
ecd2a9
 		if (pp->state != PATH_DOWN || pp->priority == PRIO_UNDEF) {
ecd2a9
-			if (!strlen(pp->wwid))
ecd2a9
-				get_uid(pp);
ecd2a9
 			get_prio(pp);
ecd2a9
 		}
ecd2a9
 	}
ecd2a9
Index: multipath-tools-130222/libmultipath/structs.h
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/structs.h
ecd2a9
+++ multipath-tools-130222/libmultipath/structs.h
ecd2a9
@@ -139,6 +139,12 @@ enum delay_checks_states {
ecd2a9
 	DELAY_CHECKS_UNDEF = 0,
ecd2a9
 };
ecd2a9
 
ecd2a9
+enum missing_udev_info_states {
ecd2a9
+	INFO_OK,
ecd2a9
+	INFO_MISSING,
ecd2a9
+	INFO_REQUESTED,
ecd2a9
+};
ecd2a9
+
ecd2a9
 struct sg_id {
ecd2a9
 	int host_no;
ecd2a9
 	int channel;
ecd2a9
@@ -193,6 +199,8 @@ struct path {
ecd2a9
 	struct checker checker;
ecd2a9
 	struct multipath * mpp;
ecd2a9
 	int fd;
ecd2a9
+	int missing_udev_info;
ecd2a9
+	int retriggers;
ecd2a9
 
ecd2a9
 	/* configlet pointers */
ecd2a9
 	struct hwentry * hwe;
ecd2a9
Index: multipath-tools-130222/multipathd/main.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/multipathd/main.c
ecd2a9
+++ multipath-tools-130222/multipathd/main.c
ecd2a9
@@ -708,6 +708,10 @@ uev_update_path (struct uevent *uev, str
ecd2a9
 			uev->kernel);
ecd2a9
 		return 1;
ecd2a9
 	}
ecd2a9
+
ecd2a9
+	if (pp->missing_udev_info == INFO_REQUESTED)
ecd2a9
+		return uev_add_path(uev, vecs);
ecd2a9
+
ecd2a9
 	/* reinit the prio values on change event, in case something is
ecd2a9
 	 * different */
ecd2a9
 	prio_init(&pp->prio);
ecd2a9
@@ -1133,12 +1137,21 @@ check_path (struct vectors * vecs, struc
ecd2a9
 	int chkr_new_path_up = 0;
ecd2a9
 	int oldchkrstate = pp->chkrstate;
ecd2a9
 
ecd2a9
-	if (!pp->mpp)
ecd2a9
+	if (!pp->mpp && (pp->missing_udev_info != INFO_MISSING ||
ecd2a9
+			 pp->retriggers >= conf->retrigger_tries))
ecd2a9
 		return;
ecd2a9
 
ecd2a9
 	if (pp->tick && --pp->tick)
ecd2a9
 		return; /* don't check this path yet */
ecd2a9
 
ecd2a9
+	if (!pp->mpp) {
ecd2a9
+		pp->missing_udev_info = INFO_REQUESTED;
ecd2a9
+		pp->retriggers++;
ecd2a9
+		sysfs_attr_set_value(pp->udev, "uevent", "change",
ecd2a9
+				     strlen("change"));
ecd2a9
+		return;
ecd2a9
+	}
ecd2a9
+
ecd2a9
 	/*
ecd2a9
 	 * provision a next check soonest,
ecd2a9
 	 * in case we exit abnormaly from here