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

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