Blame SOURCES/0250-RHBZ-1610867-rescan-change.patch

4ae388
---
4ae388
 libmultipath/structs_vec.c |  103 +++++++++------------------------------------
4ae388
 libmultipath/structs_vec.h |    6 ++
4ae388
 multipathd/main.c          |   50 +++++++++++++++++++++
4ae388
 3 files changed, 75 insertions(+), 84 deletions(-)
4ae388
4ae388
Index: multipath-tools-130222/libmultipath/structs_vec.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/structs_vec.c
4ae388
+++ multipath-tools-130222/libmultipath/structs_vec.c
4ae388
@@ -103,7 +103,7 @@ orphan_paths (vector pathvec, struct mul
4ae388
 	}
4ae388
 }
4ae388
 
4ae388
-static void
4ae388
+void
4ae388
 set_multipath_wwid (struct multipath * mpp)
4ae388
 {
4ae388
 	if (strlen(mpp->wwid))
4ae388
@@ -188,57 +188,36 @@ remove_maps_and_stop_waiters (struct vec
4ae388
 	_remove_maps(vecs, STOP_WAITER);
4ae388
 }
4ae388
 
4ae388
-static struct hwentry *
4ae388
+void
4ae388
 extract_hwe_from_path(struct multipath * mpp)
4ae388
 {
4ae388
 	struct path * pp = NULL;
4ae388
-	int pg_num = -1, p_num = -1, i;
4ae388
-	struct pathgroup * pgp = NULL;
4ae388
-
4ae388
-	condlog(3, "%s: searching paths for valid hwe", mpp->alias);
4ae388
+	int i;
4ae388
 
4ae388
-	if (mpp && mpp->pg) {
4ae388
-		vector_foreach_slot(mpp->pg, pgp, i) {
4ae388
-			if (pgp->status == PGSTATE_ACTIVE ||
4ae388
-			    pgp->status == PGSTATE_ENABLED) {
4ae388
-				pg_num = i;
4ae388
-				break;
4ae388
-			}
4ae388
-		}
4ae388
-		if (pg_num >= 0)
4ae388
-			pgp = VECTOR_SLOT(mpp->pg, pg_num);
4ae388
-	}
4ae388
+	if (mpp->hwe || !mpp->paths)
4ae388
+		return;
4ae388
 
4ae388
-	if (pgp && pgp->paths) {
4ae388
-		vector_foreach_slot(pgp->paths, pp, i) {
4ae388
-			if (pp->dmstate == PSTATE_FAILED)
4ae388
-				continue;
4ae388
-			if (strlen(pp->vendor_id) > 0 &&
4ae388
-			    strlen(pp->product_id) > 0 &&
4ae388
-			    strlen(pp->rev) > 0) {
4ae388
-				p_num = i;
4ae388
-				break;
4ae388
-			}
4ae388
+	condlog(3, "%s: searching paths for valid hwe", mpp->alias);
4ae388
+	/* doing this in two passes seems like paranoia to me */
4ae388
+	vector_foreach_slot(mpp->paths, pp, i) {
4ae388
+		if (pp->state != PATH_UP)
4ae388
+			continue;
4ae388
+		if (pp->hwe) {
4ae388
+			mpp->hwe = pp->hwe;
4ae388
+			return;
4ae388
 		}
4ae388
-		if (p_num >= 0)
4ae388
-			pp = VECTOR_SLOT(pgp->paths, i);
4ae388
 	}
4ae388
-
4ae388
-	if (pp) {
4ae388
-		condlog(3, "%s: vendor = %s", pp->dev, pp->vendor_id);
4ae388
-		condlog(3, "%s: product = %s", pp->dev, pp->product_id);
4ae388
-		condlog(3, "%s: rev = %s", pp->dev, pp->rev);
4ae388
-		if (!pp->hwe) {
4ae388
-			condlog(3, "searching hwtable");
4ae388
-			pp->hwe = find_hwe(conf->hwtable, pp->vendor_id,
4ae388
-					   pp->product_id, pp->rev);
4ae388
+	vector_foreach_slot(mpp->paths, pp, i) {
4ae388
+		if (pp->state == PATH_UP)
4ae388
+			continue;
4ae388
+		if (pp->hwe) {
4ae388
+			mpp->hwe = pp->hwe;
4ae388
+			return;
4ae388
 		}
4ae388
 	}
4ae388
-
4ae388
-	return pp?pp->hwe:NULL;
4ae388
 }
4ae388
 
4ae388
-static int
4ae388
+int
4ae388
 update_multipath_table (struct multipath *mpp, vector pathvec)
4ae388
 {
4ae388
 	char params[PARAMS_SIZE] = {0};
4ae388
@@ -259,7 +238,7 @@ update_multipath_table (struct multipath
4ae388
 	return 0;
4ae388
 }
4ae388
 
4ae388
-static int
4ae388
+int
4ae388
 update_multipath_status (struct multipath *mpp)
4ae388
 {
4ae388
 	char status[PARAMS_SIZE] = {0};
4ae388
@@ -371,21 +350,11 @@ __setup_multipath (struct vectors * vecs
4ae388
 		goto out;
4ae388
 	}
4ae388
 
4ae388
-	set_multipath_wwid(mpp);
4ae388
-	mpp->mpe = find_mpe(mpp->wwid);
4ae388
-	condlog(3, "%s: discover", mpp->alias);
4ae388
-
4ae388
 	if (update_multipath_strings(mpp, vecs->pathvec)) {
4ae388
 		condlog(0, "%s: failed to setup multipath", mpp->alias);
4ae388
 		goto out;
4ae388
 	}
4ae388
 
4ae388
-	if (!mpp->hwe)
4ae388
-		mpp->hwe = extract_hwe_from_path(mpp);
4ae388
-	if (!mpp->hwe) {
4ae388
-		condlog(3, "%s: no hardware entry found, using defaults",
4ae388
-			mpp->alias);
4ae388
-	}
4ae388
 	if (reset) {
4ae388
 		select_rr_weight(mpp);
4ae388
 		select_pgfailback(mpp);
4ae388
@@ -402,36 +371,6 @@ out:
4ae388
 	return 1;
4ae388
 }
4ae388
 
4ae388
-extern struct multipath *
4ae388
-add_map_without_path (struct vectors * vecs, char * alias)
4ae388
-{
4ae388
-	struct multipath * mpp = alloc_multipath();
4ae388
-
4ae388
-	if (!mpp || !alias)
4ae388
-		return NULL;
4ae388
-
4ae388
-	mpp->alias = STRDUP(alias);
4ae388
-
4ae388
-	if (setup_multipath(vecs, mpp))
4ae388
-		return NULL; /* mpp freed in setup_multipath */
4ae388
-
4ae388
-	if (adopt_paths(vecs->pathvec, mpp, 1))
4ae388
-		goto out;
4ae388
-
4ae388
-	if (!vector_alloc_slot(vecs->mpvec))
4ae388
-		goto out;
4ae388
-
4ae388
-	vector_set_slot(vecs->mpvec, mpp);
4ae388
-
4ae388
-	if (start_waiter_thread(mpp, vecs))
4ae388
-		goto out;
4ae388
-
4ae388
-	return mpp;
4ae388
-out:
4ae388
-	remove_map(mpp, vecs, PURGE_VEC);
4ae388
-	return NULL;
4ae388
-}
4ae388
-
4ae388
 static void
4ae388
 find_existing_alias (struct multipath * mpp,
4ae388
 		     struct vectors *vecs)
4ae388
Index: multipath-tools-130222/libmultipath/structs_vec.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/structs_vec.h
4ae388
+++ multipath-tools-130222/libmultipath/structs_vec.h
4ae388
@@ -31,11 +31,15 @@ void remove_map_and_stop_waiter (struct
4ae388
 void remove_maps (struct vectors * vecs);
4ae388
 void remove_maps_and_stop_waiters (struct vectors * vecs);
4ae388
 
4ae388
-struct multipath * add_map_without_path (struct vectors * vecs, char * alias);
4ae388
 struct multipath * add_map_with_path (struct vectors * vecs,
4ae388
 				struct path * pp, int add_vec);
4ae388
 int update_multipath (struct vectors *vecs, char *mapname, int reset);
4ae388
 void update_queue_mode_del_path(struct multipath *mpp);
4ae388
 void update_queue_mode_add_path(struct multipath *mpp);
4ae388
 
4ae388
+void extract_hwe_from_path(struct multipath * mpp);
4ae388
+void set_multipath_wwid (struct multipath * mpp);
4ae388
+int update_multipath_table (struct multipath *mpp, vector pathvec);
4ae388
+int update_multipath_status (struct multipath *mpp);
4ae388
+
4ae388
 #endif /* _STRUCTS_VEC_H */
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
@@ -273,6 +273,7 @@ retry:
4ae388
 	mpp->flush_on_last_del = FLUSH_UNDEF;
4ae388
 	mpp->action = ACT_RELOAD;
4ae388
 
4ae388
+	extract_hwe_from_path(mpp);
4ae388
 	if (setup_map(mpp, params, PARAMS_SIZE)) {
4ae388
 		condlog(0, "%s: failed to setup new map in update", mpp->alias);
4ae388
 		retries = -1;
4ae388
@@ -296,6 +297,49 @@ fail:
4ae388
 	return 0;
4ae388
 }
4ae388
 
4ae388
+static struct multipath *
4ae388
+add_map_without_path (struct vectors * vecs, char * alias)
4ae388
+{
4ae388
+	struct multipath * mpp = alloc_multipath();
4ae388
+
4ae388
+	if (!mpp)
4ae388
+		return NULL;
4ae388
+	if (!alias) {
4ae388
+		FREE(mpp);
4ae388
+		return NULL;
4ae388
+	}
4ae388
+
4ae388
+	mpp->alias = STRDUP(alias);
4ae388
+
4ae388
+	if (dm_get_info(mpp->alias, &mpp->dmi)) {
4ae388
+		condlog(3, "%s: cannot access table", mpp->alias);
4ae388
+		goto out;
4ae388
+	}
4ae388
+	set_multipath_wwid(mpp);
4ae388
+	mpp->mpe = find_mpe(mpp->wwid);
4ae388
+
4ae388
+	if (update_multipath_table(mpp, vecs->pathvec))
4ae388
+		 goto out;
4ae388
+	if (update_multipath_status(mpp))
4ae388
+		goto out;
4ae388
+
4ae388
+	if (!vector_alloc_slot(vecs->mpvec))
4ae388
+		goto out;
4ae388
+
4ae388
+	vector_set_slot(vecs->mpvec, mpp);
4ae388
+
4ae388
+	if (update_map(mpp, vecs) != 0) /* map removed */
4ae388
+		return NULL;
4ae388
+
4ae388
+	if (start_waiter_thread(mpp, vecs))
4ae388
+		goto out;
4ae388
+
4ae388
+	return mpp;
4ae388
+out:
4ae388
+	remove_map(mpp, vecs, 1);
4ae388
+	return NULL;
4ae388
+}
4ae388
+
4ae388
 static int
4ae388
 uev_add_map (struct uevent * uev, struct vectors * vecs)
4ae388
 {
4ae388
@@ -569,6 +613,7 @@ rescan:
4ae388
 		verify_paths(mpp, vecs, NULL);
4ae388
 		mpp->flush_on_last_del = FLUSH_UNDEF;
4ae388
 		mpp->action = ACT_RELOAD;
4ae388
+		extract_hwe_from_path(mpp);
4ae388
 	} else {
4ae388
 		if (!should_multipath(pp, vecs->pathvec)) {
4ae388
 			orphan_path(pp);
4ae388
@@ -855,8 +900,11 @@ map_discovery (struct vectors * vecs)
4ae388
 		return 1;
4ae388
 
4ae388
 	vector_foreach_slot (vecs->mpvec, mpp, i)
4ae388
-		if (setup_multipath(vecs, mpp))
4ae388
+		if (update_multipath_table(mpp, vecs->pathvec) ||
4ae388
+		    update_multipath_status(mpp)) {
4ae388
+			remove_map(mpp, vecs, 1);
4ae388
 			i--;
4ae388
+		}
4ae388
 
4ae388
 	return 0;
4ae388
 }