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

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