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

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