Blame SOURCES/0134-UPBZ-1328515-dont-fail-discovery.patch

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