Blame SOURCES/0016-multipathd-Don-t-use-fallback-code-after-getting-wwi.patch

b7ef27
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b7ef27
From: Benjamin Marzinski <bmarzins@redhat.com>
b7ef27
Date: Thu, 28 Mar 2019 15:17:48 -0500
b7ef27
Subject: [PATCH] multipathd: Don't use fallback code after getting wwid
b7ef27
b7ef27
The fallback code is necessary to set up mutipath devices, if multipath
b7ef27
temporarily can't get the information from udev.  However, once the
b7ef27
devices are set up, udev is the definitive source of this information.
b7ef27
b7ef27
The wwid gotten from the fallback code and the udev code should always
b7ef27
be the same, in which case it doesn't matter where we get the wwid
b7ef27
from. But if they are different, it's important to try to do the
b7ef27
right thing.
b7ef27
b7ef27
Working under the assumption that udev will either never give us this
b7ef27
information, or that it usually will. multipath should assume that if
b7ef27
there are multiple paths to a device, either they will all never get
b7ef27
a wwid from udev, or some of them will likely already have gotten the
b7ef27
correct wwid from udev.  In this case, we should fix this as soon as
b7ef27
possible.
b7ef27
b7ef27
This does mean that devices where udev will never give out the uuid
b7ef27
will not notice if the wwid changes, but that's a small price to pay
b7ef27
for doing the right thing most of the time.
b7ef27
b7ef27
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
b7ef27
---
b7ef27
 libmultipath/discovery.c | 22 +++++++++-------------
b7ef27
 libmultipath/discovery.h |  3 ++-
b7ef27
 multipathd/main.c        |  2 +-
b7ef27
 3 files changed, 12 insertions(+), 15 deletions(-)
b7ef27
b7ef27
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
b7ef27
index 3ec60d6..744cf2c 100644
b7ef27
--- a/libmultipath/discovery.c
b7ef27
+++ b/libmultipath/discovery.c
b7ef27
@@ -1763,7 +1763,6 @@ static ssize_t uid_fallback(struct path *pp, int path_state,
b7ef27
 	    !strcmp(pp->uid_attribute, DEFAULT_UID_ATTRIBUTE)) {
b7ef27
 		len = get_vpd_uid(pp);
b7ef27
 		*origin = "sysfs";
b7ef27
-		pp->uid_attribute = NULL;
b7ef27
 		if (len < 0 && path_state == PATH_UP) {
b7ef27
 			condlog(1, "%s: failed to get sysfs uid: %s",
b7ef27
 				pp->dev, strerror(-len));
b7ef27
@@ -1787,7 +1786,6 @@ static ssize_t uid_fallback(struct path *pp, int path_state,
b7ef27
 			len = WWID_SIZE;
b7ef27
 		}
b7ef27
 		*origin = "sysfs";
b7ef27
-		pp->uid_attribute = NULL;
b7ef27
 	}
b7ef27
 	return len;
b7ef27
 }
b7ef27
@@ -1800,12 +1798,14 @@ static int has_uid_fallback(struct path *pp)
b7ef27
 }
b7ef27
 
b7ef27
 int
b7ef27
-get_uid (struct path * pp, int path_state, struct udev_device *udev)
b7ef27
+get_uid (struct path * pp, int path_state, struct udev_device *udev,
b7ef27
+	 int allow_fallback)
b7ef27
 {
b7ef27
 	char *c;
b7ef27
 	const char *origin = "unknown";
b7ef27
 	ssize_t len = 0;
b7ef27
 	struct config *conf;
b7ef27
+	int used_fallback = 0;
b7ef27
 
b7ef27
 	if (!pp->uid_attribute && !pp->getuid) {
b7ef27
 		conf = get_multipath_config();
b7ef27
@@ -1846,14 +1846,9 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev)
b7ef27
 			len = get_vpd_uid(pp);
b7ef27
 			origin = "sysfs";
b7ef27
 		}
b7ef27
-		if (len <= 0 && has_uid_fallback(pp)) {
b7ef27
-			int retrigger_tries;
b7ef27
-
b7ef27
-			conf = get_multipath_config();
b7ef27
-			retrigger_tries = conf->retrigger_tries;
b7ef27
-			put_multipath_config(conf);
b7ef27
-			if (pp->retriggers >= retrigger_tries)
b7ef27
-				len = uid_fallback(pp, path_state, &origin);
b7ef27
+		if (len <= 0 && allow_fallback && has_uid_fallback(pp)) {
b7ef27
+			used_fallback = 1;
b7ef27
+			len = uid_fallback(pp, path_state, &origin);
b7ef27
 		}
b7ef27
 	}
b7ef27
 	if ( len < 0 ) {
b7ef27
@@ -1870,7 +1865,7 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev)
b7ef27
 			c--;
b7ef27
 		}
b7ef27
 	}
b7ef27
-	condlog(3, "%s: uid = %s (%s)", pp->dev,
b7ef27
+	condlog((used_fallback)? 1 : 3, "%s: uid = %s (%s)", pp->dev,
b7ef27
 		*pp->wwid == '\0' ? "<empty>" : pp->wwid, origin);
b7ef27
 	return 0;
b7ef27
 }
b7ef27
@@ -1994,7 +1989,8 @@ int pathinfo(struct path *pp, struct config *conf, int mask)
b7ef27
 	}
b7ef27
 
b7ef27
 	if ((mask & DI_WWID) && !strlen(pp->wwid)) {
b7ef27
-		get_uid(pp, path_state, pp->udev);
b7ef27
+		get_uid(pp, path_state, pp->udev,
b7ef27
+			(pp->retriggers >= conf->retrigger_tries));
b7ef27
 		if (!strlen(pp->wwid)) {
b7ef27
 			if (pp->bus == SYSFS_BUS_UNDEF)
b7ef27
 				return PATHINFO_SKIPPED;
b7ef27
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
b7ef27
index 9aacf75..8fd126b 100644
b7ef27
--- a/libmultipath/discovery.h
b7ef27
+++ b/libmultipath/discovery.h
b7ef27
@@ -52,7 +52,8 @@ ssize_t sysfs_get_vpd (struct udev_device * udev, int pg, unsigned char * buff,
b7ef27
 		       size_t len);
b7ef27
 int sysfs_get_asymmetric_access_state(struct path *pp,
b7ef27
 				      char *buff, int buflen);
b7ef27
-int get_uid(struct path * pp, int path_state, struct udev_device *udev);
b7ef27
+int get_uid(struct path * pp, int path_state, struct udev_device *udev,
b7ef27
+	    int allow_fallback);
b7ef27
 
b7ef27
 /*
b7ef27
  * discovery bitmask
b7ef27
diff --git a/multipathd/main.c b/multipathd/main.c
b7ef27
index e4f95a0..1413c6d 100644
b7ef27
--- a/multipathd/main.c
b7ef27
+++ b/multipathd/main.c
b7ef27
@@ -1227,7 +1227,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
b7ef27
 			goto out;
b7ef27
 
b7ef27
 		strcpy(wwid, pp->wwid);
b7ef27
-		rc = get_uid(pp, pp->state, uev->udev);
b7ef27
+		rc = get_uid(pp, pp->state, uev->udev, 0);
b7ef27
 
b7ef27
 		if (rc != 0)
b7ef27
 			strcpy(pp->wwid, wwid);
b7ef27
-- 
b7ef27
2.17.2
b7ef27