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

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