4728c8
---
4728c8
 libmultipath/configure.c |    8 +++--
4728c8
 multipathd/main.c        |   68 +++++++++++++++++++++++++++++++++++++----------
4728c8
 2 files changed, 59 insertions(+), 17 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/configure.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/configure.c
4728c8
+++ multipath-tools-130222/libmultipath/configure.c
4728c8
@@ -829,8 +829,10 @@ coalesce_paths (struct vectors * vecs, v
4728c8
 		 * at this point, we know we really got a new mp
4728c8
 		 */
4728c8
 		mpp = add_map_with_path(vecs, pp1, 0);
4728c8
-		if (!mpp)
4728c8
-			return 1;
4728c8
+		if (!mpp) {
4728c8
+			orphan_path(pp1);
4728c8
+			continue;
4728c8
+		}
4728c8
 
4728c8
 		if (pp1->priority == PRIO_UNDEF)
4728c8
 			mpp->action = ACT_REJECT;
4728c8
@@ -879,7 +881,7 @@ coalesce_paths (struct vectors * vecs, v
4728c8
 			condlog(3, "%s: domap (%u) failure "
4728c8
 				   "for create/reload map",
4728c8
 				mpp->alias, r);
4728c8
-			if (r == DOMAP_FAIL) {
4728c8
+			if (r == DOMAP_FAIL || conf->daemon) {
4728c8
 				condlog(2, "%s: %s map",
4728c8
 					mpp->alias, (mpp->action == ACT_CREATE)?
4728c8
 					"ignoring" : "removing");
4728c8
Index: multipath-tools-130222/multipathd/main.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipathd/main.c
4728c8
+++ multipath-tools-130222/multipathd/main.c
4728c8
@@ -821,7 +821,7 @@ map_discovery (struct vectors * vecs)
4728c8
 
4728c8
 	vector_foreach_slot (vecs->mpvec, mpp, i)
4728c8
 		if (setup_multipath(vecs, mpp))
4728c8
-			return 1;
4728c8
+			i--;
4728c8
 
4728c8
 	return 0;
4728c8
 }
4728c8
@@ -1523,21 +1523,29 @@ configure (struct vectors * vecs, int st
4728c8
 	vector mpvec;
4728c8
 	int i, ret;
4728c8
 
4728c8
-	if (!vecs->pathvec && !(vecs->pathvec = vector_alloc()))
4728c8
+	if (!vecs->pathvec && !(vecs->pathvec = vector_alloc())) {
4728c8
+		condlog(0, "couldn't allocate path vec in configure");
4728c8
 		return 1;
4728c8
+	}
4728c8
 
4728c8
-	if (!vecs->mpvec && !(vecs->mpvec = vector_alloc()))
4728c8
+	if (!vecs->mpvec && !(vecs->mpvec = vector_alloc())) {
4728c8
+		condlog(0, "couldn't allocate multipath vec in configure");
4728c8
 		return 1;
4728c8
+	}
4728c8
 
4728c8
-	if (!(mpvec = vector_alloc()))
4728c8
+	if (!(mpvec = vector_alloc())) {
4728c8
+		condlog(0, "couldn't allocate new maps vec in configure");
4728c8
 		return 1;
4728c8
+	}
4728c8
 
4728c8
 	/*
4728c8
 	 * probe for current path (from sysfs) and map (from dm) sets
4728c8
 	 */
4728c8
 	ret = path_discovery(vecs->pathvec, conf, DI_ALL);
4728c8
-	if (ret < 0)
4728c8
+	if (ret < 0) {
4728c8
+		condlog(0, "configure failed at path discovery");
4728c8
 		return 1;
4728c8
+	}
4728c8
 
4728c8
 	vector_foreach_slot (vecs->pathvec, pp, i){
4728c8
 		if (filter_path(conf, pp) > 0){
4728c8
@@ -1548,21 +1556,27 @@ configure (struct vectors * vecs, int st
4728c8
 		else
4728c8
 			pp->checkint = conf->checkint;
4728c8
 	}
4728c8
-	if (map_discovery(vecs))
4728c8
+	if (map_discovery(vecs)) {
4728c8
+		condlog(0, "configure failed at map discovery");
4728c8
 		return 1;
4728c8
+	}
4728c8
 
4728c8
 	/*
4728c8
 	 * create new set of maps & push changed ones into dm
4728c8
 	 */
4728c8
-	if (coalesce_paths(vecs, mpvec, NULL, 1))
4728c8
+	if (coalesce_paths(vecs, mpvec, NULL, 1)) {
4728c8
+		condlog(0, "configure failed while coalescing paths");
4728c8
 		return 1;
4728c8
+	}
4728c8
 
4728c8
 	/*
4728c8
 	 * may need to remove some maps which are no longer relevant
4728c8
 	 * e.g., due to blacklist changes in conf file
4728c8
 	 */
4728c8
-	if (coalesce_maps(vecs, mpvec))
4728c8
+	if (coalesce_maps(vecs, mpvec)) {
4728c8
+		condlog(0, "configure failed while coalescing maps");
4728c8
 		return 1;
4728c8
+	}
4728c8
 
4728c8
 	dm_lib_release();
4728c8
 
4728c8
@@ -1588,11 +1602,15 @@ configure (struct vectors * vecs, int st
4728c8
 	 * start dm event waiter threads for these new maps
4728c8
 	 */
4728c8
 	vector_foreach_slot(vecs->mpvec, mpp, i) {
4728c8
-		if (setup_multipath(vecs, mpp))
4728c8
-			return 1;
4728c8
+		if (setup_multipath(vecs, mpp)) {
4728c8
+			i--;
4728c8
+			continue;
4728c8
+		}
4728c8
 		if (start_waiters)
4728c8
-			if (start_waiter_thread(mpp, vecs))
4728c8
-				return 1;
4728c8
+			if (start_waiter_thread(mpp, vecs)) {
4728c8
+				remove_map(mpp, vecs, 1);
4728c8
+				i--;
4728c8
+			}
4728c8
 	}
4728c8
 	return 0;
4728c8
 }
4728c8
@@ -1857,15 +1875,23 @@ child (void * param)
4728c8
 	condlog(2, "--------start up--------");
4728c8
 	condlog(2, "read " DEFAULT_CONFIGFILE);
4728c8
 
4728c8
-	if (load_config(DEFAULT_CONFIGFILE, udev))
4728c8
+	if (load_config(DEFAULT_CONFIGFILE, udev)) {
4728c8
+		condlog(0, "failed to load config");
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
+	}
4728c8
 
4728c8
 	if (init_checkers()) {
4728c8
 		condlog(0, "failed to initialize checkers");
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
 	}
4728c8
 	if (init_prio()) {
4728c8
 		condlog(0, "failed to initialize prioritizers");
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
 	}
4728c8
 
4728c8
@@ -1898,8 +1924,12 @@ child (void * param)
4728c8
 	}
4728c8
 
4728c8
 	vecs = gvecs = init_vecs();
4728c8
-	if (!vecs)
4728c8
+	if (!vecs) {
4728c8
+		condlog(0, "failed to create vecs");
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
+	}
4728c8
 
4728c8
 	setscheduler();
4728c8
 	set_oom_adj();
4728c8
@@ -1911,11 +1941,15 @@ child (void * param)
4728c8
 	 */
4728c8
 	if ((rc = pthread_create(&uevent_thr, &uevent_attr, ueventloop, udev))) {
4728c8
 		condlog(0, "failed to create uevent thread: %d", rc);
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
 	}
4728c8
 	pthread_attr_destroy(&uevent_attr);
4728c8
 	if ((rc = pthread_create(&uxlsnr_thr, &misc_attr, uxlsnrloop, vecs))) {
4728c8
 		condlog(0, "failed to create cli listener: %d", rc);
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
 	}
4728c8
 	/*
4728c8
@@ -1927,6 +1961,8 @@ child (void * param)
4728c8
 	if (configure(vecs, 1)) {
4728c8
 		unlock(vecs->lock);
4728c8
 		condlog(0, "failure during configuration");
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
 	}
4728c8
 	unlock(vecs->lock);
4728c8
@@ -1936,10 +1972,14 @@ child (void * param)
4728c8
 	 */
4728c8
 	if ((rc = pthread_create(&check_thr, &misc_attr, checkerloop, vecs))) {
4728c8
 		condlog(0,"failed to create checker loop thread: %d", rc);
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
 	}
4728c8
 	if ((rc = pthread_create(&uevq_thr, &misc_attr, uevqloop, vecs))) {
4728c8
 		condlog(0, "failed to create uevent dispatcher: %d", rc);
4728c8
+		if (logsink)
4728c8
+			log_thread_stop();
4728c8
 		exit(1);
4728c8
 	}
4728c8
 	pthread_attr_destroy(&misc_attr);