dmparser: Use find_path_by_dev()
authorHannes Reinecke <hare@suse.de>
Thu, 24 Mar 2016 07:36:10 +0000 (08:36 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 3 May 2016 07:07:22 +0000 (09:07 +0200)
There are two functions for looking up paths, find_path_by_dev() and
find_path_by_devt(). To avoid any inconsistencies we should be
using find_path_by_dev() here and allocate a path with both values.

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

index d093cfd..affd1d5 100644 (file)
@@ -977,7 +977,11 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid)
 
        if (dev_type == DEV_DEVT) {
                strchop(dev);
-               pp = find_path_by_devt(pathvec, dev);
+               if (devt2devname(buff, FILE_NAME_SIZE, dev)) {
+                       condlog(0, "%s: cannot find block device\n", dev);
+                       return 1;
+               }
+               pp = find_path_by_dev(pathvec, buff);
                if (!pp) {
                        struct udev_device *udevice = udev_device_new_from_devnum(conf->udev, 'b', parse_devt(dev));
 
index c19c5d2..289be89 100644 (file)
@@ -320,14 +320,23 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp)
                FREE(word);
 
                for (j = 0; j < num_paths; j++) {
+                       char devname[FILE_NAME_SIZE];
+
                        pp = NULL;
                        p += get_word(p, &word);
 
                        if (!word)
                                goto out;
 
+                       if (devt2devname(devname, FILE_NAME_SIZE, word)) {
+                               condlog(2, "%s: cannot find block device",
+                                       word);
+                               FREE(word);
+                               continue;
+                       }
+
                        if (pathvec)
-                               pp = find_path_by_devt(pathvec, word);
+                               pp = find_path_by_dev(pathvec, devname);
 
                        if (!pp) {
                                pp = alloc_path();
@@ -336,6 +345,7 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp)
                                        goto out1;
 
                                strncpy(pp->dev_t, word, BLK_DEV_SIZE);
+                               strncpy(pp->dev, devname, FILE_NAME_SIZE);
                                if (strlen(mpp->wwid)) {
                                        strncpy(pp->wwid, mpp->wwid, WWID_SIZE);
                                }