@@ -1876,20 +1876,20 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev,
len = strlen(pp->wwid);
origin = "callout";
} else {
+ bool udev_available = udev && pp->uid_attribute
+ && *pp->uid_attribute;
- if (udev && pp->uid_attribute) {
+ if (udev_available) {
len = get_udev_uid(pp, pp->uid_attribute, udev);
- origin = "udev";
if (len <= 0)
condlog(1,
"%s: failed to get udev uid: %s",
pp->dev, strerror(-len));
-
- } else if (pp->bus == SYSFS_BUS_SCSI) {
- len = get_vpd_uid(pp);
- origin = "sysfs";
+ else
+ origin = "udev";
}
- if (len <= 0 && allow_fallback && has_uid_fallback(pp)) {
+ if ((!udev_available || (len <= 0 && allow_fallback))
+ && has_uid_fallback(pp)) {
used_fallback = 1;
len = uid_fallback(pp, path_state, &origin);
}
The code had two distinct fallback paths, with non-obvious logic. Try to straighten it out. The "allow_fallback" logic from ffaf9477d115 "multipathd: Don't use fallback code after getting wwid" should only apply in the case where get_udev_uid() failed, not if it wasn't even tried. Moreover, uid_attribute is hardly ever NULL since ffaf9477; allow the user to set it to the empty string to skip udev-based WWID determination. This is rather not meant for production, but it's useful for testing. Finally, only set "origin" to "udev" if a WWID was actually retrieved from udev. Signed-off-by: Martin Wilck <mwilck@suse.com> --- libmultipath/discovery.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)