diff mbox

[07/33] libmultipath: fall back to search paths by devt

Message ID 20170228162329.14517-8-mwilck@suse.com (mailing list archive)
State Superseded, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Martin Wilck Feb. 28, 2017, 4:23 p.m. UTC
From: Hannes Reinecke <hare@suse.de>

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 | 11 +++++++++--
 libmultipath/dmparser.c  | 11 +++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 4e99845e..e4186de1 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -120,8 +120,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);
 }
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index b504961f..274eb947 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -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();