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

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