Blame SOURCES/0106-RHBZ-1169935-no-new-devs.patch

4ae388
---
4ae388
 libmultipath/config.c    |    4 ++++
4ae388
 libmultipath/config.h    |    1 +
4ae388
 libmultipath/configure.c |    5 ++---
4ae388
 libmultipath/dict.c      |   33 +++++++++++++++++++++++++++++++++
4ae388
 libmultipath/util.c      |   30 ++++++++++++++++++++++++++++++
4ae388
 libmultipath/util.h      |    1 +
4ae388
 libmultipath/wwids.c     |   21 ++++++++++++++-------
4ae388
 multipathd/main.c        |    3 +--
4ae388
 8 files changed, 86 insertions(+), 12 deletions(-)
4ae388
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
@@ -131,6 +131,7 @@ struct config {
4ae388
 	int detect_prio;
4ae388
 	int force_sync;
4ae388
 	int deferred_remove;
4ae388
+	int ignore_new_boot_devs;
4ae388
 	unsigned int version[3];
4ae388
 
4ae388
 	char * dev;
4ae388
Index: multipath-tools-130222/libmultipath/configure.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/configure.c
4ae388
+++ multipath-tools-130222/libmultipath/configure.c
4ae388
@@ -775,9 +775,8 @@ coalesce_paths (struct vectors * vecs, v
4ae388
 		if (refwwid && strncmp(pp1->wwid, refwwid, WWID_SIZE))
4ae388
 			continue;
4ae388
 
4ae388
-		/* If find_multipaths was selected check if the path is valid */
4ae388
-		if (conf->find_multipaths && !refwwid &&
4ae388
-		    !should_multipath(pp1, pathvec)) {
4ae388
+		/* check if the path is valid */
4ae388
+		if (!refwwid && !should_multipath(pp1, pathvec)) {
4ae388
 			orphan_path(pp1);
4ae388
 			continue;
4ae388
 		}
4ae388
Index: multipath-tools-130222/libmultipath/wwids.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/wwids.c
4ae388
+++ multipath-tools-130222/libmultipath/wwids.c
4ae388
@@ -15,6 +15,7 @@
4ae388
 #include "wwids.h"
4ae388
 #include "defaults.h"
4ae388
 #include "config.h"
4ae388
+#include "util.h"
4ae388
 
4ae388
 /*
4ae388
  * Copyright (c) 2010 Benjamin Marzinski, Redhat
4ae388
@@ -268,15 +269,21 @@ should_multipath(struct path *pp1, vecto
4ae388
 {
4ae388
 	int i;
4ae388
 	struct path *pp2;
4ae388
+	int ignore_new_devs = (conf->ignore_new_boot_devs && in_initrd());
4ae388
+
4ae388
+	if (!conf->find_multipaths && !ignore_new_devs)
4ae388
+		return 1;
4ae388
 
4ae388
 	condlog(4, "checking if %s should be multipathed", pp1->dev);
4ae388
-	vector_foreach_slot(pathvec, pp2, i) {
4ae388
-		if (pp1->dev == pp2->dev)
4ae388
-			continue;
4ae388
-		if (strncmp(pp1->wwid, pp2->wwid, WWID_SIZE) == 0) {
4ae388
-			condlog(3, "found multiple paths with wwid %s, "
4ae388
-				"multipathing %s", pp1->wwid, pp1->dev);
4ae388
-			return 1;
4ae388
+	if (!ignore_new_devs) {
4ae388
+		vector_foreach_slot(pathvec, pp2, i) {
4ae388
+			if (pp1->dev == pp2->dev)
4ae388
+				continue;
4ae388
+			if (strncmp(pp1->wwid, pp2->wwid, WWID_SIZE) == 0) {
4ae388
+				condlog(3, "found multiple paths with wwid %s, "
4ae388
+					"multipathing %s", pp1->wwid, pp1->dev);
4ae388
+				return 1;
4ae388
+			}
4ae388
 		}
4ae388
 	}
4ae388
 	if (check_wwids_file(pp1->wwid, 0) < 0) {
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
@@ -503,8 +503,7 @@ rescan:
4ae388
 			return 1;
4ae388
 		}
4ae388
 
4ae388
-		if (conf->find_multipaths &&
4ae388
-		    !should_multipath(pp, vecs->pathvec)) {
4ae388
+		if (!should_multipath(pp, vecs->pathvec)) {
4ae388
 			orphan_path(pp);
4ae388
 			return 0;
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
@@ -622,6 +622,7 @@ load_config (char * file, struct udev *u
4ae388
 	conf->deferred_remove = DEFAULT_DEFERRED_REMOVE;
4ae388
 	conf->hw_strmatch = 0;
4ae388
 	conf->force_sync = 0;
4ae388
+	conf->ignore_new_boot_devs = 0;
4ae388
 
4ae388
 	/*
4ae388
 	 * preload default hwtable
4ae388
@@ -732,6 +733,9 @@ load_config (char * file, struct udev *u
4ae388
 	    !conf->wwids_file)
4ae388
 		goto out;
4ae388
 
4ae388
+	if (conf->ignore_new_boot_devs)
4ae388
+		in_initrd();
4ae388
+
4ae388
 	return 0;
4ae388
 out:
4ae388
 	free_config(conf);
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
@@ -761,6 +761,29 @@ def_deferred_remove_handler(vector strve
4ae388
 	return 0;
4ae388
 }
4ae388
 
4ae388
+static int
4ae388
+def_ignore_new_boot_devs_handler(vector strvec)
4ae388
+{
4ae388
+	char * buff;
4ae388
+
4ae388
+	buff = set_value(strvec);
4ae388
+
4ae388
+	if (!buff)
4ae388
+		return 1;
4ae388
+
4ae388
+	if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
4ae388
+	    (strlen(buff) == 1 && !strcmp(buff, "0")))
4ae388
+		conf->ignore_new_boot_devs = 0;
4ae388
+	else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
4ae388
+		 (strlen(buff) == 1 && !strcmp(buff, "1")))
4ae388
+		conf->ignore_new_boot_devs = 1;
4ae388
+	else
4ae388
+		conf->ignore_new_boot_devs = 0;
4ae388
+
4ae388
+	FREE(buff);
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
 /*
4ae388
  * blacklist block handlers
4ae388
  */
4ae388
@@ -3011,6 +3034,15 @@ snprint_def_deferred_remove(char * buff,
4ae388
 }
4ae388
 
4ae388
 static int
4ae388
+snprint_def_ignore_new_boot_devs(char * buff, int len, void * data)
4ae388
+{
4ae388
+	if (conf->ignore_new_boot_devs == 1)
4ae388
+		return snprintf(buff, len, "yes");
4ae388
+	else
4ae388
+		return snprintf(buff, len, "no");
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
 snprint_ble_simple (char * buff, int len, void * data)
4ae388
 {
4ae388
 	struct blentry * ble = (struct blentry *)data;
4ae388
@@ -3080,6 +3112,7 @@ init_keywords(void)
4ae388
 	install_keyword("hw_str_match", &def_hw_strmatch_handler, &snprint_def_hw_strmatch);
4ae388
 	install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync);
4ae388
 	install_keyword("deferred_remove", &def_deferred_remove_handler, &snprint_def_deferred_remove);
4ae388
+	install_keyword("ignore_new_boot_devs", &def_ignore_new_boot_devs_handler, &snprint_def_ignore_new_boot_devs);
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/util.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/util.c
4ae388
+++ multipath-tools-130222/libmultipath/util.c
4ae388
@@ -3,6 +3,8 @@
4ae388
 #include <sys/types.h>
4ae388
 #include <sys/stat.h>
4ae388
 #include <unistd.h>
4ae388
+#include <sys/vfs.h>
4ae388
+#include <linux/magic.h>
4ae388
 
4ae388
 #include "debug.h"
4ae388
 #include "memory.h"
4ae388
@@ -267,3 +269,31 @@ dev_t parse_devt(const char *dev_t)
4ae388
 
4ae388
 	return makedev(maj, min);
4ae388
 }
4ae388
+
4ae388
+/* This define was taken from systemd. src/shared/macro.h */
4ae388
+#define F_TYPE_EQUAL(a, b) (a == (typeof(a)) b)
4ae388
+
4ae388
+/* This function was taken from systemd. src/shared/util.c */
4ae388
+int in_initrd(void) {
4ae388
+	static int saved = -1;
4ae388
+	struct statfs s;
4ae388
+
4ae388
+	if (saved >= 0)
4ae388
+		return saved;
4ae388
+
4ae388
+	/* We make two checks here:
4ae388
+	 *
4ae388
+	 * 1. the flag file /etc/initrd-release must exist
4ae388
+	 * 2. the root file system must be a memory file system
4ae388
+	 * The second check is extra paranoia, since misdetecting an
4ae388
+	 * initrd can have bad bad consequences due the initrd
4ae388
+	 * emptying when transititioning to the main systemd.
4ae388
+	 */
4ae388
+
4ae388
+	saved = access("/etc/initrd-release", F_OK) >= 0 &&
4ae388
+		statfs("/", &s) >= 0 &&
4ae388
+		(F_TYPE_EQUAL(s.f_type, TMPFS_MAGIC) ||
4ae388
+		 F_TYPE_EQUAL(s.f_type, RAMFS_MAGIC));
4ae388
+
4ae388
+	return saved;
4ae388
+}
4ae388
Index: multipath-tools-130222/libmultipath/util.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/util.h
4ae388
+++ multipath-tools-130222/libmultipath/util.h
4ae388
@@ -11,6 +11,7 @@ void remove_trailing_chars(char *path, c
4ae388
 int devt2devname (char *, int, char *);
4ae388
 dev_t parse_devt(const char *dev_t);
4ae388
 char *convert_dev(char *dev, int is_path_device);
4ae388
+int in_initrd(void);
4ae388
 
4ae388
 #define safe_sprintf(var, format, args...)	\
4ae388
 	snprintf(var, sizeof(var), format, ##args) >= sizeof(var)