libmultipath: fall back to search paths by devt
authorHannes Reinecke <hare@suse.de>
Tue, 28 Feb 2017 16:23:03 +0000 (17:23 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Thu, 16 Mar 2017 07:00:09 +0000 (08:00 +0100)
When removing path the device might already be gone from sysfs,
so we cannot lookup the device name. However, we still should
have the path vector available, so we should be trying to look
it up by using the device number.

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

index 7398040..69afdc2 100644 (file)
@@ -123,8 +123,15 @@ path_discover (vector pathvec, struct config * conf,
 
        pp = find_path_by_dev(pathvec, (char *)devname);
        if (!pp) {
-               return store_pathinfo(pathvec, conf,
-                                     udevice, flag, NULL);
+               char devt[BLK_DEV_SIZE];
+               dev_t devnum = udev_device_get_devnum(udevice);
+
+               snprintf(devt, BLK_DEV_SIZE, "%d:%d",
+                        major(devnum), minor(devnum));
+               pp = find_path_by_devt(pathvec, devt);
+               if (!pp)
+                       return store_pathinfo(pathvec, conf,
+                                             udevice, flag, NULL);
        }
        return pathinfo(pp, conf, flag);
 }
index b504961..274eb94 100644 (file)
@@ -330,12 +330,15 @@ int disassemble_map(vector pathvec, char *params, struct multipath *mpp,
                        if (devt2devname(devname, FILE_NAME_SIZE, word)) {
                                condlog(2, "%s: cannot find block device",
                                        word);
-                               FREE(word);
-                               continue;
+                               devname[0] = '\0';
                        }
 
-                       if (pathvec)
-                               pp = find_path_by_dev(pathvec, devname);
+                       if (pathvec) {
+                               if (strlen(devname))
+                                       pp = find_path_by_dev(pathvec, devname);
+                               else
+                                       pp = find_path_by_devt(pathvec, word);
+                       }
 
                        if (!pp) {
                                pp = alloc_path();