File multipath-tools-fixup-waiter-creation-on-single-paths of Package multipath-tools

commit 938fe00eda2cba6809229a3a343f8f209f11c7d2
Author: Hannes Reinecke <hare@suse.de>
Date:   Fri Mar 20 12:21:52 2009 +0100

    Fixup waiter creation for newly added paths
    
    A previous commit mass-changed #ifdef DAEMON to checki
    for 'mpp->waiter'. Unfortunatly when the 'domap' function
    is called with ACT_CREATE in the daemon, the mpp->waiter is
    not set, hence the multipath client mode logic is choosen.
    Fixing this triggers another issues which is that newly
    added path via ACT_CREATE won't have their waitevent thread
    created as the caller checks mpp->action (which changed to
    ACT_NOTHING) and won't start the thread.
    
    References: bnc#473841
    
    Signed-off-by: Konrad Rzeszutek <konrad@virtualiron.com>
    Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/libmultipath/config.h b/libmultipath/config.h
index 08c2542..5688093 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -72,6 +72,7 @@ struct config {
 	int force_reload;
 	int dev_loss_tmo;
 	int fast_io_fail_tmo;
+	int daemon;
 
 	char * dev;
 	char * sysfs_dir;
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index f6d8e05..cf8296e 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -378,7 +378,7 @@ domap (struct multipath * mpp, char * params)
 		 * DM_DEVICE_CREATE, DM_DEVICE_RENAME, or DM_DEVICE_RELOAD
 		 * succeeded
 		 */
-		if (!mpp->waiter) {
+		if (!conf->daemon) {
 			/* multipath client mode */
 			dm_switchgroup(mpp->alias, mpp->bestpg);
 			if (mpp->action != ACT_NOTHING)
@@ -389,9 +389,12 @@ domap (struct multipath * mpp, char * params)
 			condlog(2, "%s: load table [0 %llu %s %s]", mpp->alias,
 				mpp->size, TGT_MPATH, params);
 			/*
-			 * Required action is over, reset for the stateful daemon
+			 * Required action is over, reset for the stateful daemon.
+			 * But don't do it for creation as we use in the caller the
+			 * mpp->action to figure out whether to start the watievent checker.
 			 */
-			mpp->action = ACT_NOTHING;
+			if (mpp->action != ACT_CREATE)
+				mpp->action = ACT_NOTHING;
 		}
 		return DOMAP_OK;
 	}
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index f1975fb..2d024ff 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -13,6 +13,7 @@
 #include "structs.h"
 #include "util.h"
 #include "debug.h"
+#include "config.h"
 
 #define WORD_SIZE 64
 
@@ -297,7 +298,7 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp)
 				strncpy(pp->dev_t, word, BLK_DEV_SIZE);
 
 				/* Only call this in multipath client mode */
-				if (!mpp->waiter && store_path(pathvec, pp))
+				if (!conf->daemon && store_path(pathvec, pp))
 					goto out1;
 			}
 			FREE(word);
diff --git a/multipath/main.c b/multipath/main.c
index 340a761..6f2c566 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -494,6 +494,7 @@ main (int argc, char *argv[])
 			condlog(0, "can't set open fds limit to %d : %s\n",
 				conf->max_fds, strerror(errno));
 	}
+	conf->daemon = 0;
 
 	dm_init();
 
@@ -511,7 +512,7 @@ main (int argc, char *argv[])
 	}
 	while ((r = configure()) < 0)
 		condlog(3, "restart multipath configuration process");
-	
+
 out:
 	sysfs_cleanup();
 	dm_lib_release();
diff --git a/multipathd/main.c b/multipathd/main.c
index 1d8ff5a..7222c0c 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1379,7 +1379,7 @@ child (void * param)
 		condlog(0, "can not find sysfs mount point");
 		exit(1);
 	}
-
+	conf->daemon = 1;
 	/*
 	 * fetch and configure both paths and multipaths
 	 */
diff --git a/multipathd/main.h b/multipathd/main.h
index 5d6f1b8..4b8e983 100644
--- a/multipathd/main.h
+++ b/multipathd/main.h
@@ -1,7 +1,6 @@
 #ifndef MAIN_H
 #define MAIN_H
 
-#define DAEMON 1
 #define MAPGCINT 5
 
 int reconfigure (struct vectors *);
openSUSE Build Service is sponsored by