Blame SOURCES/0083-RHBZ-1080055-orphan-paths-on-reload.patch

1eb31d
---
1eb31d
 libmultipath/structs_vec.c |   31 +++++++++++++++++++++++++++----
1eb31d
 multipathd/main.c          |    4 ++++
1eb31d
 2 files changed, 31 insertions(+), 4 deletions(-)
1eb31d
1eb31d
Index: multipath-tools-130222/libmultipath/structs_vec.c
1eb31d
===================================================================
1eb31d
--- multipath-tools-130222.orig/libmultipath/structs_vec.c
1eb31d
+++ multipath-tools-130222/libmultipath/structs_vec.c
1eb31d
@@ -280,12 +280,38 @@ update_multipath_status (struct multipat
1eb31d
 	return 0;
1eb31d
 }
1eb31d
 
1eb31d
+void sync_paths(struct multipath *mpp, vector pathvec)
1eb31d
+{
1eb31d
+	struct path *pp;
1eb31d
+	struct pathgroup  *pgp;
1eb31d
+	int found, i, j;
1eb31d
+
1eb31d
+	vector_foreach_slot (mpp->paths, pp, i) {
1eb31d
+		found = 0;
1eb31d
+		vector_foreach_slot(mpp->pg, pgp, j) {
1eb31d
+			if (find_slot(pgp->paths, (void *)pp) != -1) {
1eb31d
+				found = 1;
1eb31d
+				break;
1eb31d
+			}
1eb31d
+		}
1eb31d
+		if (!found) {
1eb31d
+			condlog(3, "%s dropped path %s", mpp->alias, pp->dev);
1eb31d
+			vector_del_slot(mpp->paths, i--);
1eb31d
+			orphan_path(pp);
1eb31d
+		}
1eb31d
+	}
1eb31d
+	update_mpp_paths(mpp, pathvec);
1eb31d
+	vector_foreach_slot (mpp->paths, pp, i)
1eb31d
+		pp->mpp = mpp;
1eb31d
+}
1eb31d
+
1eb31d
 extern int
1eb31d
 update_multipath_strings (struct multipath *mpp, vector pathvec)
1eb31d
 {
1eb31d
 	if (!mpp)
1eb31d
 		return 1;
1eb31d
 
1eb31d
+	update_mpp_paths(mpp, pathvec);
1eb31d
 	condlog(4, "%s: %s", mpp->alias, __FUNCTION__);
1eb31d
 
1eb31d
 	free_multipath_attributes(mpp);
1eb31d
@@ -294,6 +320,7 @@ update_multipath_strings (struct multipa
1eb31d
 
1eb31d
 	if (update_multipath_table(mpp, pathvec))
1eb31d
 		return 1;
1eb31d
+	sync_paths(mpp, pathvec);
1eb31d
 
1eb31d
 	if (update_multipath_status(mpp))
1eb31d
 		return 1;
1eb31d
@@ -494,13 +521,9 @@ int update_multipath (struct vectors *ve
1eb31d
 		return 2;
1eb31d
 	}
1eb31d
 
1eb31d
-	free_pgvec(mpp->pg, KEEP_PATHS);
1eb31d
-	mpp->pg = NULL;
1eb31d
-
1eb31d
 	if (__setup_multipath(vecs, mpp, reset))
1eb31d
 		return 1; /* mpp freed in setup_multipath */
1eb31d
 
1eb31d
-	adopt_paths(vecs->pathvec, mpp, 0);
1eb31d
 	/*
1eb31d
 	 * compare checkers states with DM states
1eb31d
 	 */
1eb31d
Index: multipath-tools-130222/multipathd/main.c
1eb31d
===================================================================
1eb31d
--- multipath-tools-130222.orig/multipathd/main.c
1eb31d
+++ multipath-tools-130222/multipathd/main.c
1eb31d
@@ -1152,6 +1152,10 @@ check_path (struct vectors * vecs, struc
1eb31d
 			pp->dev);
1eb31d
 		pp->dmstate = PSTATE_UNDEF;
1eb31d
 	}
1eb31d
+	/* if update_multipath_strings orphaned the path, quit early */
1eb31d
+	if (!pp->mpp)
1eb31d
+		return;
1eb31d
+
1eb31d
 	pp->chkrstate = newstate;
1eb31d
 	if (newstate != pp->state) {
1eb31d
 		int oldstate = pp->state;