Skip to contentSkip to conversation

multipath-tools: fixes for path wwid detection and path change uevents

PATCH RESEND In review Martin Wilck 2 participants 9 messages Mar 7, 2018 – Oct 8, 2018 Device mapper

lore
Share & tools
lore
#0 lore raw

cover multipath-tools: fixes for path wwid detection and path change uevents

Hi Christophe,

this small series fixes some minor glitches I found in the current path discovery code, and attempts to implement the safe part of the functionality discussed in the thread "multipathd: update path's udev in uev_update_path" in January (based on an idea from Wu Chongyun).

Resending the series, unchanged, rebased on 0.7.5.

Regards,
Martin

Martin Wilck (4):
libmultipath: get_uid: check VPD pages for SCSI only
libmultipath: get_uid: don't quit prematurely without udev
libmultipath: uev_update_path: always warn if WWID changed
libmultipath: uev_update_path: update path properties

 libmultipath/discovery.c | 58 ++++++++++++++++++++++++++++--------------------
 multipathd/main.c        | 29 +++++++++++++++++-------
 2 files changed, 55 insertions(+), 32 deletions(-)
Signature · 1 line
2.16.1
#1 lore raw

PATCH RESEND 1/4 libmultipath: get_uid: check VPD pages for SCSI only

The VPD code won't work for non-SCSI devices, anyway. For indentation reasons, I moved the "retrigger_tries" case to a separate function, which is also called only for SCSI devices.

---
 libmultipath/discovery.c | 50 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 18 deletions(-)
libmultipath/discovery.c +32 -18
index 3d38a2550980..53182a85fa10 100644
@@ -1807,9 +1807,38 @@ get_vpd_uid(struct path * pp)
 		parent = udev_device_get_parent(parent);
 	}
 
+	if (!parent)
+		return -EINVAL;
+
 	return get_vpd_sysfs(parent, 0x83, pp->wwid, WWID_SIZE);
 }
 
+static ssize_t scsi_uid_fallback(struct path *pp, int path_state,
+			     const char **origin)
+{
+	ssize_t len = 0;
+	int retrigger;
+	struct config *conf;
+
+	conf = get_multipath_config();
+	retrigger = conf->retrigger_tries;
+	put_multipath_config(conf);
+	if (pp->retriggers >= retrigger &&
+	    !strcmp(pp->uid_attribute, DEFAULT_UID_ATTRIBUTE)) {
+		len = get_vpd_uid(pp);
+		*origin = "sysfs";
+		pp->uid_attribute = NULL;
+		if (len < 0 && path_state == PATH_UP) {
+			condlog(1, "%s: failed to get sysfs uid: %s",
+				pp->dev, strerror(-len));
+			len = get_vpd_sgio(pp->fd, 0x83, pp->wwid,
+					   WWID_SIZE);
+			*origin = "sgio";
+		}
+	}
+	return len;
+}
+
 int
 get_uid (struct path * pp, int path_state, struct udev_device *udev)
 {
@@ -1851,7 +1880,6 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev)
 		len = get_rbd_uid(pp);
 		origin = "sysfs";
 	} else {
-		int retrigger;
 
 		if (pp->uid_attribute) {
 			len = get_udev_uid(pp, pp->uid_attribute, udev);
@@ -1861,26 +1889,12 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev)
 					"%s: failed to get udev uid: %s",
 					pp->dev, strerror(-len));
 
-		} else {
+		} else if (pp->bus == SYSFS_BUS_SCSI) {
 			len = get_vpd_uid(pp);
 			origin = "sysfs";
 		}
-		conf = get_multipath_config();
-		retrigger = conf->retrigger_tries;
-		put_multipath_config(conf);
-		if (len <= 0 && pp->retriggers >= retrigger &&
-		    !strcmp(pp->uid_attribute, DEFAULT_UID_ATTRIBUTE)) {
-			len = get_vpd_uid(pp);
-			origin = "sysfs";
-			pp->uid_attribute = NULL;
-			if (len < 0 && path_state == PATH_UP) {
-				condlog(1, "%s: failed to get sysfs uid: %s",
-					pp->dev, strerror(-len));
-				len = get_vpd_sgio(pp->fd, 0x83, pp->wwid,
-						   WWID_SIZE);
-				origin = "sgio";
-			}
-		}
+		if (len <= 0 && pp->bus == SYSFS_BUS_SCSI)
+			len = scsi_uid_fallback(pp, path_state, &origin);
 	}
 	if ( len < 0 ) {
 		condlog(1, "%s: failed to get %s uid: %s",
Signature · 1 line
2.16.1
#2 lore raw

PATCH RESEND 2/4 libmultipath: get_uid: don't quit prematurely without udev

In reply to Martin Wilck

Not all the implemented methods to derive the UID rely on udev information being present. For example getuid callout, rbd, and the SCSI vpd code work fine without it. It's unlikely that we don't get udev data, but we want to be as good as possible at deriving the uid.

---
 libmultipath/discovery.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
libmultipath/discovery.c +2 -6
index 53182a85fa10..9f2a9c907914 100644
@@ -1853,11 +1853,6 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev)
 		put_multipath_config(conf);
 	}
 
-	if (!udev) {
-		condlog(1, "%s: no udev information", pp->dev);
-		return 1;
-	}
-
 	memset(pp->wwid, 0, WWID_SIZE);
 	if (pp->getuid) {
 		char buff[CALLOUT_MAX_SIZE];
@@ -1881,7 +1876,7 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev)
 		origin = "sysfs";
 	} else {
 
-		if (pp->uid_attribute) {
+		if (udev && pp->uid_attribute) {
 			len = get_udev_uid(pp, pp->uid_attribute, udev);
 			origin = "udev";
 			if (len <= 0)
@@ -1900,6 +1895,7 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev)
 		condlog(1, "%s: failed to get %s uid: %s",
 			pp->dev, origin, strerror(-len));
 		memset(pp->wwid, 0x0, WWID_SIZE);
+		return 1;
 	} else {
 		/* Strip any trailing blanks */
 		c = strchr(pp->wwid, '\0');
Signature · 1 line
2.16.1
#3 lore raw

PATCH RESEND 3/4 libmultipath: uev_update_path: always warn if WWID changed

In reply to Martin Wilck

Print the warning about changed WWID not only if disable_changed_wwids is set, but always. It's actually more dangerous if that option is not set.

---
 multipathd/main.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
multipathd/main.c +13 -8
index f85995810950..e9668205ce92 100644
@@ -940,15 +940,18 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
 	pp = find_path_by_dev(vecs->pathvec, uev->kernel);
 	if (pp) {
 		struct multipath *mpp = pp->mpp;
+		char wwid[WWID_SIZE];
 
-		if (disable_changed_wwids &&
-		    (strlen(pp->wwid) || pp->wwid_changed)) {
-			char wwid[WWID_SIZE];
+		strcpy(wwid, pp->wwid);
+		get_uid(pp, pp->state, uev->udev);
 
-			strcpy(wwid, pp->wwid);
-			get_uid(pp, pp->state, uev->udev);
-			if (strcmp(wwid, pp->wwid) != 0) {
-				condlog(0, "%s: path wwid changed from '%s' to '%s'. disallowing", uev->kernel, wwid, pp->wwid);
+		if (strncmp(wwid, pp->wwid, WWID_SIZE) != 0) {
+			condlog(0, "%s: path wwid changed from '%s' to '%s'. %s",
+				uev->kernel, wwid, pp->wwid,
+				(disable_changed_wwids ? "disallowing" :
+				 "continuing"));
+			if (disable_changed_wwids &&
+			    (strlen(wwid) || pp->wwid_changed)) {
 				strcpy(pp->wwid, wwid);
 				if (!pp->wwid_changed) {
 					pp->wwid_changed = 1;
@@ -957,7 +960,9 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
 						dm_fail_path(pp->mpp->alias, pp->dev_t);
 				}
 				goto out;
-			} else
+			} else if (!disable_changed_wwids)
+				strcpy(pp->wwid, wwid);
+			else
 				pp->wwid_changed = 0;
 		}
 
Signature · 1 line
2.16.1
#4 lore raw

PATCH RESEND 4/4 libmultipath: uev_update_path: update path properties

In reply to Martin Wilck

Update pp->udev and those path attributes that can be cheaply updated from sysfs, i.e. without IO to the disk.

---
 multipathd/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
multipathd/main.c +8 -0
index e9668205ce92..6e6c52a52783 100644
@@ -964,6 +964,14 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
 				strcpy(pp->wwid, wwid);
 			else
 				pp->wwid_changed = 0;
+		} else {
+			udev_device_unref(pp->udev);
+			pp->udev = udev_device_ref(uev->udev);
+			conf = get_multipath_config();
+			if (pathinfo(pp, conf, DI_SYSFS|DI_NOIO) != PATHINFO_OK)
+				condlog(1, "%s: pathinfo failed after change uevent",
+					uev->kernel);
+			put_multipath_config(conf);
 		}
 
 		if (pp->initialized == INIT_REQUESTED_UDEV)
Signature · 1 line
2.16.1
maintainer Reviewed-by on the v1 series
#5 lore raw
In reply to Martin Wilck
Quoted 7 lines · Martin Wilck

Hi Christophe,

this small series fixes some minor glitches I found in the current path discovery code, and attempts to implement the safe part of the functionality discussed in the thread "multipathd: update path's udev in uev_update_path" in January (based on an idea from Wu Chongyun).

Quoted 5 lines

Resending the series, unchanged, rebased on 0.7.5.

Regards,
Martin

for the set.

Quoted 12 lines

Martin Wilck (4):
libmultipath: get_uid: check VPD pages for SCSI only
libmultipath: get_uid: don't quit prematurely without udev
libmultipath: uev_update_path: always warn if WWID changed
libmultipath: uev_update_path: update path properties

 libmultipath/discovery.c | 58 ++++++++++++++++++++++++++++--------------------
 multipathd/main.c        | 29 +++++++++++++++++-------
 2 files changed, 55 insertions(+), 32 deletions(-)
Signature · 1 line
2.16.1
#6 lore raw

Hi Ben, Christophe,

I found a problem with this old patch series of mine.

Quoted 13 lines · Benjamin Marzinski
Quoted 12 lines · Martin Wilck

Hi Christophe,

this small series fixes some minor glitches I found in the current path
discovery code, and attempts to implement the safe part of the functionality
discussed in the thread "multipathd: update path's udev in uev_update_path"
in January (based on an idea from Wu Chongyun).

Resending the series, unchanged, rebased on 0.7.5.

Quoted 13 lines
Quoted 3 lines

Regards,
Martin

for the set.

Quoted 5 lines

Martin Wilck (4):
libmultipath: get_uid: check VPD pages for SCSI only
libmultipath: get_uid: don't quit prematurely without udev
libmultipath: uev_update_path: always warn if WWID changed
libmultipath: uev_update_path: update path properties

while I am still pondering about your latest series, it occured to me that my patch "get_uid: don't quit prematurely without udev" is against the spirit of your "retrigger uevents to try and get the uid through udev" patch from 2016 (688aa22b).

"get_uid: don't quit prematurely without udev" has been merged a while ago (08d42ee6). Should it be reverted??

Pro: the patch is against the "udev first" philosophy and subverts the retrigger logic.
Con: with the patch, we'll be able to retrieve WWIDs more quickly in some situations, as we don't have to wait for udev.

Either way (but more likely with my patch), it may happen that we retrieve a WWID from sysfs or elsewhere first, and from udev later. These WWIDs may not necessarily match, and a "WWID changed" problem may occur.

Please tell me what you think.

Martin

Signature · 9 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)


--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#7 lore raw
Quoted 17 lines · Martin Wilck

Hi Ben, Christophe,

I found a problem with this old patch series of mine.

while I am still pondering about your latest series, it occured to me that my patch "get_uid: don't quit prematurely without udev" is against the spirit of your "retrigger uevents to try and get the uid through udev" patch from 2016 (688aa22b).

"get_uid: don't quit prematurely without udev" has been merged a while ago (08d42ee6). Should it be reverted??

Pro: the patch is against the "udev first" philosophy and subverts the retrigger logic.
Con: with the patch, we'll be able to retrieve WWIDs more quickly in some situations, as we don't have to wait for udev.

Quoted 6 lines

Either way (but more likely with my patch), it may happen that we retrieve a WWID from sysfs or elsewhere first, and from udev later. These WWIDs may not necessarily match, and a "WWID changed" problem may occur.

Please tell me what you think.

I'm having a hard time seeing how get_uid() could get called on a path without a udev device attached in multipathd. It can happen because of update_paths() in multipath, for paths that don't get discovered when searching for paths, but do belong to an existing multipath device. I don't think you patch will hurt anything here. So, unless I'm missing some code path in multipathd, I don't see a problem with this patch.

In fact, we should probably make scsi_uid_fallback() skip (or at least always pass) the retrigger check if we aren't in the daemon, so we always try the failback when we run multipath.

-Ben

Quoted 9 lines

Martin

Signature · 3 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
#8 lore raw
Quoted 32 lines · Benjamin Marzinski
Quoted 23 lines · Martin Wilck

Hi Ben, Christophe,

I found a problem with this old patch series of mine.

while I am still pondering about your latest series, it occured to me
that my patch "get_uid: don't quit prematurely without udev" is against
the spirit of your "retrigger uevents to try and get the uid through
udev" patch from 2016 (688aa22b).

"get_uid: don't quit prematurely without udev" has been merged a while
ago (08d42ee6). Should it be reverted??

Pro: the patch is against the "udev first" philosophy and subverts the
retrigger logic.
Con: with the patch, we'll be able to retrieve WWIDs more quickly in
some situations, as we don't have to wait for udev.

Quoted 7 lines

Either way (but more likely with my patch), it may happen that we retrieve a WWID from sysfs or elsewhere first, and from udev later. These WWIDs may not necessarily match, and a "WWID changed" problem may
occur.

Please tell me what you think.

Quoted 8 lines

I'm having a hard time seeing how get_uid() could get called on a path
without a udev device attached in multipathd. It can happen because of
update_paths() in multipath, for paths that don't get discovered when searching for paths, but do belong to an existing multipath device. I don't think you patch will hurt anything here. So, unless I'm missing some code path in multipathd, I don't see a problem with this patch.

OK, fine then. Thanks for clarifying this.

Quoted 4 lines

In fact, we should probably make scsi_uid_fallback() skip (or at least
always pass) the retrigger check if we aren't in the daemon, so we always try the failback when we run multipath.

AFAICS that's already the case, because multipath sets conf->retrigger_tries = 0 on startup.

Regards,
Martin

Signature · 9 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)


--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel