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

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