[PATCH 45/54] libmultipath: path_discover(): use find_path_by_devt()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

In path_discover(), it's actually expected that a the path to be discovered is
not already in pathvec. So, do search by devt in the first place rather than
searching twice.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/discovery.c | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index e26aae2..5f4ebf0 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -125,27 +125,19 @@ static int
 path_discover (vector pathvec, struct config * conf,
 	       struct udev_device *udevice, int flag)
 {
-	struct path * pp;
-	const char * devname;
-
-	devname = udev_device_get_sysname(udevice);
-	if (!devname)
-		return PATHINFO_FAILED;
-
-	pp = find_path_by_dev(pathvec, devname);
-	if (!pp) {
-		char devt[BLK_DEV_SIZE];
-		dev_t devnum = udev_device_get_devnum(udevice);
+	struct path *pp;
+	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 | DI_BLACKLIST,
-					      NULL);
-	}
-	return pathinfo(pp, conf, flag);
+	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 | DI_BLACKLIST,
+				      NULL);
+	else
+		return pathinfo(pp, conf, flag);
 }
 
 static void cleanup_udev_enumerate_ptr(void *arg)
-- 
2.26.2


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux