Do not automatically fall back to vpd uid generation
authorHannes Reinecke <hare@suse.de>
Tue, 16 Dec 2014 10:51:12 +0000 (11:51 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Sun, 29 Mar 2015 16:23:35 +0000 (18:23 +0200)
When a wwid via uid_attribute cannot be generated we should
not fall back to using sysfs vpd attributes automatically.
The uid_attribute can be set to virtually anything and an
automatic fallback will then generated a different wwid,
leading to an incorrect setup.
A fallback is only valid if the uid_attribute value
is the default setting of 'ID_SERIAL', for which the
format is fixed.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/discovery.c

index 009ef0c..d1a16e6 100644 (file)
@@ -1509,7 +1509,7 @@ static int
 get_uid (struct path * pp)
 {
        char *c;
-       const char *origin = "none";
+       const char *origin = "unknown";
        ssize_t len = 0;
 
        if (!pp->uid_attribute && !pp->getuid)
@@ -1542,35 +1542,28 @@ get_uid (struct path * pp)
                        len = get_udev_uid(pp, pp->uid_attribute);
                        origin = "udev";
                        if (len <= 0)
-                               condlog(2,
-                                       "%s: failed to get UID attribute '%s'",
-                                       pp->dev, pp->uid_attribute);
+                               condlog(1,
+                                       "%s: failed to get udev uid: %s",
+                                       pp->dev, strerror(-len));
+
                }
-               if (len <= 0) {
+               if (len <= 0 &&
+                   !strcmp(pp->uid_attribute, DEFAULT_UID_ATTRIBUTE)) {
                        len = get_vpd_uid(pp);
-                       if (len > 0) {
-                               origin = "sysfs";
-                               pp->uid_attribute = NULL;
-                       } else {
-                               condlog(2, "%s: failed to get sysfs vpd pg83",
-                                       pp->dev);
-                       }
-               }
-               if (len <= 0) {
-                       len = get_vpd_sgio(pp->fd, 0x83, pp->wwid,
-                                          WWID_SIZE);
-                       if (len > 0) {
+                       origin = "sysfs";
+                       pp->uid_attribute = NULL;
+                       if (len < 0) {
+                               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";
-                               pp->uid_attribute = NULL;
-                       } else {
-                               condlog(2, "%s: failed to get sgio vpd pg83",
-                                       pp->dev);
                        }
                }
        }
        if ( len < 0 ) {
-               condlog(1, "%s: failed to get uid: %s",
-                       pp->dev, strerror(-len));
+               condlog(1, "%s: failed to get %s uid: %s",
+                       pp->dev, origin, strerror(-len));
                memset(pp->wwid, 0x0, WWID_SIZE);
        } else {
                /* Strip any trailing blanks */