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

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