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

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