Blame SOURCES/0006-RH-add-find-multipaths.patch

38852f
---
38852f
 libmultipath/config.c    |    1 +
38852f
 libmultipath/config.h    |    1 +
38852f
 libmultipath/configure.c |   11 +++++++++++
38852f
 libmultipath/defaults.h  |    1 +
38852f
 libmultipath/dict.c      |   34 ++++++++++++++++++++++++++++++++++
38852f
 libmultipath/wwids.c     |   26 ++++++++++++++++++++++++++
38852f
 libmultipath/wwids.h     |    1 +
38852f
 multipath/main.c         |    2 +-
38852f
 multipathd/main.c        |    6 ++++++
38852f
 9 files changed, 82 insertions(+), 1 deletion(-)
38852f
38852f
Index: multipath-tools-130222/libmultipath/config.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/config.c
38852f
+++ multipath-tools-130222/libmultipath/config.c
38852f
@@ -547,6 +547,7 @@ load_config (char * file)
38852f
 	conf->reassign_maps = DEFAULT_REASSIGN_MAPS;
38852f
 	conf->checkint = DEFAULT_CHECKINT;
38852f
 	conf->max_checkint = MAX_CHECKINT(conf->checkint);
38852f
+	conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
38852f
 	conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
38852f
 	conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
38852f
 	conf->detect_prio = DEFAULT_DETECT_PRIO;
38852f
Index: multipath-tools-130222/libmultipath/configure.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/configure.c
38852f
+++ multipath-tools-130222/libmultipath/configure.c
38852f
@@ -508,6 +508,10 @@ coalesce_paths (struct vectors * vecs, v
38852f
 
38852f
 	memset(empty_buff, 0, WWID_SIZE);
38852f
 
38852f
+	/* ignore refwwid if it's empty */
38852f
+	if (refwwid && !strlen(refwwid))
38852f
+		refwwid = NULL;
38852f
+
38852f
 	if (force_reload) {
38852f
 		vector_foreach_slot (pathvec, pp1, k) {
38852f
 			pp1->mpp = NULL;
38852f
@@ -537,6 +541,13 @@ coalesce_paths (struct vectors * vecs, v
38852f
 		if (refwwid && strncmp(pp1->wwid, refwwid, WWID_SIZE))
38852f
 			continue;
38852f
 
38852f
+		/* If find_multipaths was selected check if the path is valid */
38852f
+		if (conf->find_multipaths && !refwwid &&
38852f
+		    !should_multipath(pp1, pathvec)) {
38852f
+			orphan_path(pp1);
38852f
+			continue;
38852f
+		}
38852f
+
38852f
 		/*
38852f
 		 * at this point, we know we really got a new mp
38852f
 		 */
38852f
Index: multipath-tools-130222/libmultipath/defaults.h
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/defaults.h
38852f
+++ multipath-tools-130222/libmultipath/defaults.h
38852f
@@ -15,6 +15,7 @@
38852f
 #define DEFAULT_USER_FRIENDLY_NAMES    0
38852f
 #define DEFAULT_VERBOSITY	2
38852f
 #define DEFAULT_REASSIGN_MAPS	1
38852f
+#define DEFAULT_FIND_MULTIPATHS	0
38852f
 #define DEFAULT_FAST_IO_FAIL	5
38852f
 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_OFF
38852f
 #define DEFAULT_DETECT_PRIO DETECT_PRIO_OFF
38852f
Index: multipath-tools-130222/libmultipath/dict.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/dict.c
38852f
+++ multipath-tools-130222/libmultipath/dict.c
38852f
@@ -585,6 +585,27 @@ def_reservation_key_handler(vector strve
38852f
 }
38852f
 
38852f
 static int
38852f
+def_find_multipaths_handler(vector strvec)
38852f
+{
38852f
+	char * buff;
38852f
+
38852f
+	buff = set_value(strvec);
38852f
+
38852f
+	if (!buff)
38852f
+		return 1;
38852f
+
38852f
+	if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
38852f
+	    (strlen(buff) == 1 && !strcmp(buff, "0")))
38852f
+		conf->find_multipaths = 0;
38852f
+	else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
38852f
+		 (strlen(buff) == 1 && !strcmp(buff, "1")))
38852f
+		conf->find_multipaths = 1;
38852f
+
38852f
+	FREE(buff);
38852f
+	return 0;
38852f
+}
38852f
+
38852f
+static int
38852f
 def_names_handler(vector strvec)
38852f
 {
38852f
 	char * buff;
38852f
@@ -2700,6 +2721,18 @@ snprint_def_log_checker_err (char * buff
38852f
 }
38852f
 
38852f
 static int
38852f
+snprint_def_find_multipaths (char * buff, int len, void * data)
38852f
+{
38852f
+	if (conf->find_multipaths == DEFAULT_FIND_MULTIPATHS)
38852f
+		return 0;
38852f
+	if (!conf->find_multipaths)
38852f
+		return snprintf(buff, len, "no");
38852f
+
38852f
+	return snprintf(buff, len, "yes");
38852f
+}
38852f
+
38852f
+
38852f
+static int
38852f
 snprint_def_user_friendly_names (char * buff, int len, void * data)
38852f
 {
38852f
 	if (conf->user_friendly_names  == USER_FRIENDLY_NAMES_ON)
38852f
@@ -2833,6 +2866,7 @@ init_keywords(void)
38852f
 	install_keyword("wwids_file", &wwids_file_handler, &snprint_def_wwids_file);
38852f
 	install_keyword("log_checker_err", &def_log_checker_err_handler, &snprint_def_log_checker_err);
38852f
 	install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
38852f
+	install_keyword("find_multipaths", &def_find_multipaths_handler, &snprint_def_find_multipaths);
38852f
 	install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler_handler);
38852f
 	install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
38852f
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
38852f
Index: multipath-tools-130222/libmultipath/wwids.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/wwids.c
38852f
+++ multipath-tools-130222/libmultipath/wwids.c
38852f
@@ -125,6 +125,32 @@ out:
38852f
 }
38852f
 
38852f
 int
38852f
+should_multipath(struct path *pp1, vector pathvec)
38852f
+{
38852f
+	int i;
38852f
+	struct path *pp2;
38852f
+
38852f
+	condlog(4, "checking if %s should be multipathed", pp1->dev);
38852f
+	vector_foreach_slot(pathvec, pp2, i) {
38852f
+		if (pp1->dev == pp2->dev)
38852f
+			continue;
38852f
+		if (strncmp(pp1->wwid, pp2->wwid, WWID_SIZE) == 0) {
38852f
+			condlog(3, "found multiple paths with wwid %s, "
38852f
+				"multipathing %s", pp1->wwid, pp1->dev);
38852f
+			return 1;
38852f
+		}
38852f
+	}
38852f
+	if (check_wwids_file(pp1->wwid, 0) < 0) {
38852f
+		condlog(3, "wwid %s not in wwids file, skipping %s",
38852f
+			pp1->wwid, pp1->dev);
38852f
+		return 0;
38852f
+	}
38852f
+	condlog(3, "found wwid %s in wwids file, multipathing %s", pp1->wwid,
38852f
+		pp1->dev);
38852f
+	return 1;
38852f
+}
38852f
+
38852f
+int
38852f
 remember_wwid(char *wwid)
38852f
 {
38852f
 	int ret = check_wwids_file(wwid, 1);
38852f
Index: multipath-tools-130222/libmultipath/wwids.h
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/wwids.h
38852f
+++ multipath-tools-130222/libmultipath/wwids.h
38852f
@@ -12,6 +12,7 @@
38852f
 "#\n" \
38852f
 "# Valid WWIDs:\n"
38852f
 
38852f
+int should_multipath(struct path *pp, vector pathvec);
38852f
 int remember_wwid(char *wwid);
38852f
 int check_wwids_file(char *wwid, int write_wwid);
38852f
 
38852f
Index: multipath-tools-130222/multipath/main.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/multipath/main.c
38852f
+++ multipath-tools-130222/multipath/main.c
38852f
@@ -333,7 +333,7 @@ configure (void)
38852f
 	/*
38852f
 	 * core logic entry point
38852f
 	 */
38852f
-	r = coalesce_paths(&vecs, NULL, NULL, conf->force_reload);
38852f
+	r = coalesce_paths(&vecs, NULL, refwwid, conf->force_reload);
38852f
 
38852f
 out:
38852f
 	if (refwwid)
38852f
Index: multipath-tools-130222/multipathd/main.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/multipathd/main.c
38852f
+++ multipath-tools-130222/multipathd/main.c
38852f
@@ -49,6 +49,7 @@
38852f
 #include <print.h>
38852f
 #include <configure.h>
38852f
 #include <prio.h>
38852f
+#include <wwids.h>
38852f
 #include <pgpolicies.h>
38852f
 #include <uevent.h>
38852f
 
38852f
@@ -471,6 +472,11 @@ rescan:
38852f
 			return 1;
38852f
 		}
38852f
 
38852f
+		if (conf->find_multipaths &&
38852f
+		    !should_multipath(pp, vecs->pathvec)) {
38852f
+			orphan_path(pp);
38852f
+			return 0;
38852f
+		}
38852f
 		condlog(4,"%s: creating new map", pp->dev);
38852f
 		if ((mpp = add_map_with_path(vecs, pp, 1))) {
38852f
 			mpp->action = ACT_CREATE;
38852f
Index: multipath-tools-130222/libmultipath/config.h
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/config.h
38852f
+++ multipath-tools-130222/libmultipath/config.h
38852f
@@ -106,6 +106,7 @@ struct config {
38852f
 	unsigned int dev_loss;
38852f
 	int log_checker_err;
38852f
 	int allow_queueing;
38852f
+	int find_multipaths;
38852f
 	uid_t uid;
38852f
 	gid_t gid;
38852f
 	mode_t mode;