Blame SOURCES/0156-UPBZ-1313324-dont-fail-discovery.patch

4ae388
---
4ae388
 libmpathpersist/mpath_persist.c |   14 ++++++------
4ae388
 libmultipath/discovery.c        |   46 ++++++++++++++++++++--------------------
4ae388
 libmultipath/discovery.h        |    4 +++
4ae388
 multipath/main.c                |    2 -
4ae388
 multipathd/main.c               |    6 +++--
4ae388
 5 files changed, 39 insertions(+), 33 deletions(-)
4ae388
4ae388
Index: multipath-tools-130222/libmpathpersist/mpath_persist.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.c
4ae388
+++ multipath-tools-130222/libmpathpersist/mpath_persist.c
4ae388
@@ -178,7 +178,7 @@ int mpath_persistent_reserve_in (int fd,
4ae388
 		goto out;
4ae388
 	}
4ae388
 
4ae388
-	if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER)) {
4ae388
+	if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER) < 0) {
4ae388
 		ret = MPATH_PR_DMMP_ERROR;
4ae388
 		goto out1;
4ae388
 	}
4ae388
@@ -262,13 +262,13 @@ int mpath_persistent_reserve_out ( int f
4ae388
 	curmp = vector_alloc ();
4ae388
 	pathvec = vector_alloc ();
4ae388
 
4ae388
-	 if (!curmp || !pathvec){
4ae388
-                condlog (0, "%s: vector allocation failed.", alias);
4ae388
-                ret = MPATH_PR_DMMP_ERROR;
4ae388
-                goto out;
4ae388
-        }
4ae388
+	if (!curmp || !pathvec){
4ae388
+		condlog (0, "%s: vector allocation failed.", alias);
4ae388
+		ret = MPATH_PR_DMMP_ERROR;
4ae388
+		goto out;
4ae388
+	}
4ae388
 
4ae388
-	if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER)) {
4ae388
+	if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER) < 0) {
4ae388
 		ret = MPATH_PR_DMMP_ERROR;
4ae388
 		goto out1;
4ae388
 	}
4ae388
Index: multipath-tools-130222/libmultipath/discovery.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/discovery.c
4ae388
+++ multipath-tools-130222/libmultipath/discovery.c
4ae388
@@ -32,7 +32,7 @@ int
4ae388
 store_pathinfo (vector pathvec, vector hwtable, struct udev_device *udevice,
4ae388
 		int flag, struct path **pp_ptr)
4ae388
 {
4ae388
-	int err = 1;
4ae388
+	int err = PATHINFO_FAILED;
4ae388
 	struct path * pp;
4ae388
 	const char * devname;
4ae388
 
4ae388
@@ -41,12 +41,12 @@ store_pathinfo (vector pathvec, vector h
4ae388
 
4ae388
 	devname = udev_device_get_sysname(udevice);
4ae388
 	if (!devname)
4ae388
-		return 1;
4ae388
+		return PATHINFO_FAILED;
4ae388
 
4ae388
 	pp = alloc_path();
4ae388
 
4ae388
 	if (!pp)
4ae388
-		return 1;
4ae388
+		return PATHINFO_FAILED;
4ae388
 
4ae388
 	if(safe_sprintf(pp->dev, "%s", devname)) {
4ae388
 		condlog(0, "pp->dev too small");
4ae388
@@ -80,19 +80,16 @@ path_discover (vector pathvec, struct co
4ae388
 
4ae388
 	devname = udev_device_get_sysname(udevice);
4ae388
 	if (!devname)
4ae388
-		return 0;
4ae388
+		return PATHINFO_FAILED;
4ae388
 
4ae388
 	if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
4ae388
 			   (char *)devname) > 0)
4ae388
-		return 0;
4ae388
+		return PATHINFO_SKIPPED;
4ae388
 
4ae388
 	pp = find_path_by_dev(pathvec, (char *)devname);
4ae388
 	if (!pp) {
4ae388
-		if (store_pathinfo(pathvec, conf->hwtable,
4ae388
-				   udevice, flag, NULL) != 1)
4ae388
-			return 0;
4ae388
-		else
4ae388
-			return 1;
4ae388
+		return store_pathinfo(pathvec, conf->hwtable,
4ae388
+				      udevice, flag, NULL);
4ae388
 	}
4ae388
 	return pathinfo(pp, conf->hwtable, flag);
4ae388
 }
4ae388
@@ -104,11 +101,11 @@ path_discovery (vector pathvec, struct c
4ae388
 	struct udev_list_entry *entry;
4ae388
 	struct udev_device *udevice;
4ae388
 	const char *devpath;
4ae388
-	int r = 0;
4ae388
+	int num_paths = 0, total_paths = 0;
4ae388
 
4ae388
 	udev_iter = udev_enumerate_new(conf->udev);
4ae388
 	if (!udev_iter)
4ae388
-		return 1;
4ae388
+		return -ENOMEM;
4ae388
 
4ae388
 	udev_enumerate_add_match_subsystem(udev_iter, "block");
4ae388
 	udev_enumerate_scan_devices(udev_iter);
4ae388
@@ -121,17 +118,20 @@ path_discovery (vector pathvec, struct c
4ae388
 		udevice = udev_device_new_from_syspath(conf->udev, devpath);
4ae388
 		if (!udevice) {
4ae388
 			condlog(4, "%s: no udev information", devpath);
4ae388
-			r++;
4ae388
 			continue;
4ae388
 		}
4ae388
 		devtype = udev_device_get_devtype(udevice);
4ae388
-		if(devtype && !strncmp(devtype, "disk", 4))
4ae388
-			r += path_discover(pathvec, conf, udevice, flag);
4ae388
+		if(devtype && !strncmp(devtype, "disk", 4)) {
4ae388
+			total_paths++;
4ae388
+			if (path_discover(pathvec, conf,
4ae388
+					  udevice, flag) == PATHINFO_OK)
4ae388
+				num_paths++;
4ae388
+		}
4ae388
 		udev_device_unref(udevice);
4ae388
 	}
4ae388
 	udev_enumerate_unref(udev_iter);
4ae388
-	condlog(4, "Discovery status %d", r);
4ae388
-	return r;
4ae388
+	condlog(4, "Discovered %d/%d paths", num_paths, total_paths);
4ae388
+	return (total_paths - num_paths);
4ae388
 }
4ae388
 
4ae388
 #define declare_sysfs_get_str(fname)					\
4ae388
@@ -1021,7 +1021,7 @@ get_state (struct path * pp, int daemon)
4ae388
 
4ae388
 	if (!checker_selected(c)) {
4ae388
 		if (daemon) {
4ae388
-			if (pathinfo(pp, conf->hwtable, DI_SYSFS) != 0) {
4ae388
+			if (pathinfo(pp, conf->hwtable, DI_SYSFS) != PATHINFO_OK) {
4ae388
 				condlog(3, "%s: couldn't get sysfs pathinfo",
4ae388
 					pp->dev);
4ae388
 				return PATH_UNCHECKED;
4ae388
@@ -1140,7 +1140,7 @@ pathinfo (struct path *pp, vector hwtabl
4ae388
 	int path_state;
4ae388
 
4ae388
 	if (!pp)
4ae388
-		return 1;
4ae388
+		return PATHINFO_FAILED;
4ae388
 
4ae388
 	condlog(3, "%s: mask = 0x%x", pp->dev, mask);
4ae388
 
4ae388
@@ -1148,12 +1148,12 @@ pathinfo (struct path *pp, vector hwtabl
4ae388
 	 * fetch info available in sysfs
4ae388
 	 */
4ae388
 	if (mask & DI_SYSFS && sysfs_pathinfo(pp))
4ae388
-		return 1;
4ae388
+		return PATHINFO_FAILED;
4ae388
 
4ae388
 	if (mask & DI_BLACKLIST && mask & DI_SYSFS) {
4ae388
 		if (filter_device(conf->blist_device, conf->elist_device,
4ae388
 				  pp->vendor_id, pp->product_id) > 0) {
4ae388
-			return 2;
4ae388
+			return PATHINFO_SKIPPED;
4ae388
 		}
4ae388
 	}
4ae388
 
4ae388
@@ -1199,7 +1199,7 @@ pathinfo (struct path *pp, vector hwtabl
4ae388
 	if (mask & DI_BLACKLIST && mask & DI_WWID) {
4ae388
 		if (filter_wwid(conf->blist_wwid, conf->elist_wwid,
4ae388
 				pp->wwid) > 0) {
4ae388
-			return 2;
4ae388
+			return PATHINFO_SKIPPED;
4ae388
 		}
4ae388
 	}
4ae388
 
4ae388
@@ -1213,7 +1213,7 @@ pathinfo (struct path *pp, vector hwtabl
4ae388
 		}
4ae388
 	}
4ae388
 
4ae388
-	return 0;
4ae388
+	return PATHINFO_OK;
4ae388
 
4ae388
 blank:
4ae388
 	/*
4ae388
Index: multipath-tools-130222/libmultipath/discovery.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/discovery.h
4ae388
+++ multipath-tools-130222/libmultipath/discovery.h
4ae388
@@ -24,6 +24,10 @@
4ae388
 #define SCSI_COMMAND_TERMINATED 0x22
4ae388
 #define SG_ERR_DRIVER_SENSE     0x08
4ae388
 
4ae388
+#define PATHINFO_OK 0
4ae388
+#define PATHINFO_FAILED 1
4ae388
+#define PATHINFO_SKIPPED 2
4ae388
+
4ae388
 struct config;
4ae388
 
4ae388
 int sysfs_get_dev (struct udev_device *udev, char * buff, size_t len);
4ae388
Index: multipath-tools-130222/multipath/main.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipath/main.c
4ae388
+++ multipath-tools-130222/multipath/main.c
4ae388
@@ -343,7 +343,7 @@ configure (void)
4ae388
 		/* maximum info */
4ae388
 		di_flag = DI_ALL;
4ae388
 
4ae388
-	if (path_discovery(pathvec, conf, di_flag))
4ae388
+	if (path_discovery(pathvec, conf, di_flag) < 0)
4ae388
 		goto out;
4ae388
 
4ae388
 	if (conf->verbosity > 2)
4ae388
Index: multipath-tools-130222/multipathd/main.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/main.c
4ae388
+++ multipath-tools-130222/multipathd/main.c
4ae388
@@ -1515,7 +1515,7 @@ configure (struct vectors * vecs, int st
4ae388
 	struct multipath * mpp;
4ae388
 	struct path * pp;
4ae388
 	vector mpvec;
4ae388
-	int i;
4ae388
+	int i, ret;
4ae388
 
4ae388
 	if (!vecs->pathvec && !(vecs->pathvec = vector_alloc()))
4ae388
 		return 1;
4ae388
@@ -1529,7 +1529,9 @@ configure (struct vectors * vecs, int st
4ae388
 	/*
4ae388
 	 * probe for current path (from sysfs) and map (from dm) sets
4ae388
 	 */
4ae388
-	path_discovery(vecs->pathvec, conf, DI_ALL);
4ae388
+	ret = path_discovery(vecs->pathvec, conf, DI_ALL);
4ae388
+	if (ret < 0)
4ae388
+		return 1;
4ae388
 
4ae388
 	vector_foreach_slot (vecs->pathvec, pp, i){
4ae388
 		if (filter_path(conf, pp) > 0){