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

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