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

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