Blame SOURCES/0098-UPBZ-1067171-mutipath-i.patch

38852f
---
38852f
 libmultipath/config.h    |   15 ++++++++-
38852f
 libmultipath/configure.c |    2 -
38852f
 libmultipath/discovery.c |    5 +--
38852f
 multipath/main.c         |   75 +++++++++++++++++++++++++----------------------
38852f
 multipath/multipath.8    |    5 ++-
38852f
 5 files changed, 61 insertions(+), 41 deletions(-)
38852f
38852f
Index: multipath-tools-130222/libmultipath/config.h
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/config.h
38852f
+++ multipath-tools-130222/libmultipath/config.h
38852f
@@ -23,6 +23,17 @@ enum devtypes {
38852f
 	DEV_DEVMAP
38852f
 };
38852f
 
38852f
+enum mpath_cmds {
38852f
+	CMD_CREATE,
38852f
+	CMD_DRY_RUN,
38852f
+	CMD_LIST_SHORT,
38852f
+	CMD_LIST_LONG,
38852f
+	CMD_VALID_PATH,
38852f
+	CMD_REMOVE_WWID,
38852f
+	CMD_RESET_WWIDS,
38852f
+	CMD_ADD_WWID,
38852f
+};
38852f
+
38852f
 struct hwentry {
38852f
 	char * vendor;
38852f
 	char * product;
38852f
@@ -79,8 +90,7 @@ struct mpentry {
38852f
 
38852f
 struct config {
38852f
 	int verbosity;
38852f
-	int dry_run;
38852f
-	int list;
38852f
+	enum mpath_cmds cmd;
38852f
 	int pgpolicy_flag;
38852f
 	int pgpolicy;
38852f
 	enum devtypes dev_type;
38852f
@@ -98,6 +108,7 @@ struct config {
38852f
 	int max_fds;
38852f
 	int force_reload;
38852f
 	int queue_without_daemon;
38852f
+	int ignore_wwids;
38852f
 	int checker_timeout;
38852f
 	int daemon;
38852f
 	int flush_on_last_del;
38852f
Index: multipath-tools-130222/multipath/main.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/multipath/main.c
38852f
+++ multipath-tools-130222/multipath/main.c
38852f
@@ -85,7 +85,7 @@ usage (char * progname)
38852f
 {
38852f
 	fprintf (stderr, VERSION_STRING);
38852f
 	fprintf (stderr, "Usage:\n");
38852f
-	fprintf (stderr, "  %s [-a|-A|-c|-w|-W] [-d] [-T tm:val] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
38852f
+	fprintf (stderr, "  %s [-a|-A|-c|-w|-W] [-d] [-T tm:val] [-r] [-i] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
38852f
 	fprintf (stderr, "  %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname);
38852f
 	fprintf (stderr, "  %s -F [-v lvl]\n", progname);
38852f
 	fprintf (stderr, "  %s -t\n", progname);
38852f
@@ -109,6 +109,7 @@ usage (char * progname)
38852f
 		"  -d      dry run, do not create or update devmaps\n" \
38852f
 		"  -t      dump internal hardware table\n" \
38852f
 		"  -r      force devmap reload\n" \
38852f
+		"  -i      ignore wwids file\n" \
38852f
 		"  -B      treat the bindings file as read only\n" \
38852f
 		"  -p      policy failover|multibus|group_by_serial|group_by_prio\n" \
38852f
 		"  -b fil  bindings file location\n" \
38852f
@@ -209,18 +210,19 @@ get_dm_mpvec (vector curmp, vector pathv
38852f
 		 * If not in "fast list mode", we need to fetch information
38852f
 		 * about them
38852f
 		 */
38852f
-		if (conf->list != 1)
38852f
+		if (conf->cmd != CMD_LIST_SHORT)
38852f
 			update_paths(mpp);
38852f
 
38852f
-		if (conf->list > 1)
38852f
+		if (conf->cmd == CMD_LIST_LONG)
38852f
 			mpp->bestpg = select_path_group(mpp);
38852f
 
38852f
 		disassemble_status(status, mpp);
38852f
 
38852f
-		if (conf->list)
38852f
+		if (conf->cmd == CMD_LIST_SHORT ||
38852f
+		    conf->cmd == CMD_LIST_LONG)
38852f
 			print_multipath_topology(mpp, conf->verbosity);
38852f
 
38852f
-		if (!conf->dry_run)
38852f
+		if (conf->cmd == CMD_CREATE)
38852f
 			reinstate_paths(mpp);
38852f
 	}
38852f
 	return 0;
38852f
@@ -262,10 +264,11 @@ configure (void)
38852f
 	/*
38852f
 	 * if we have a blacklisted device parameter, exit early
38852f
 	 */
38852f
-	if (dev && conf->dev_type == DEV_DEVNODE && conf->dry_run != 3 &&
38852f
+	if (dev && conf->dev_type == DEV_DEVNODE &&
38852f
+	    conf->cmd != CMD_REMOVE_WWID &&
38852f
 	    (filter_devnode(conf->blist_devnode,
38852f
 			    conf->elist_devnode, dev) > 0)) {
38852f
-		if (conf->dry_run == 2)
38852f
+		if (conf->cmd == CMD_VALID_PATH)
38852f
 			printf("%s is not a valid multipath device path\n",
38852f
 			       conf->dev);
38852f
 		goto out;
38852f
@@ -278,13 +281,13 @@ configure (void)
38852f
 		int failed = get_refwwid(conf->dev, conf->dev_type, pathvec,
38852f
 					 &refwwid);
38852f
 		if (!refwwid) {
38852f
-			if (failed == 2 && conf->dry_run == 2)
38852f
+			if (failed == 2 && conf->cmd == CMD_VALID_PATH)
38852f
 				printf("%s is not a valid multipath device path\n", conf->dev);
38852f
 			else
38852f
 				condlog(3, "scope is nul");
38852f
 			goto out;
38852f
 		}
38852f
-		if (conf->dry_run == 3) {
38852f
+		if (conf->cmd == CMD_REMOVE_WWID) {
38852f
 			r = remove_wwid(refwwid);
38852f
 			if (r == 0)
38852f
 				printf("wwid '%s' removed\n", refwwid);
38852f
@@ -295,7 +298,7 @@ configure (void)
38852f
 			}
38852f
 			goto out;
38852f
 		}
38852f
-		if (conf->dry_run == 5) {
38852f
+		if (conf->cmd == CMD_ADD_WWID) {
38852f
 			r = remember_wwid(refwwid);
38852f
 			if (r == 0)
38852f
 				printf("wwid '%s' added\n", refwwid);
38852f
@@ -305,13 +308,13 @@ configure (void)
38852f
 			goto out;
38852f
 		}
38852f
 		condlog(3, "scope limited to %s", refwwid);
38852f
-		if (conf->dry_run == 2) {
38852f
-			if (check_wwids_file(refwwid, 0) == 0){
38852f
-				printf("%s is a valid multipath device path\n", conf->dev);
38852f
+		if (conf->cmd == CMD_VALID_PATH) {
38852f
+			if (conf->ignore_wwids ||
38852f
+			    check_wwids_file(refwwid, 0) == 0)
38852f
 				r = 0;
38852f
-			}
38852f
-			else
38852f
-				printf("%s is not a valid multipath device path\n", conf->dev);
38852f
+
38852f
+			printf("%s %s a valid multipath device path\n",
38852f
+			       conf->dev, r == 0 ? "is" : "is not");
38852f
 			goto out;
38852f
 		}
38852f
 	}
38852f
@@ -319,13 +322,13 @@ configure (void)
38852f
 	/*
38852f
 	 * get a path list
38852f
 	 */
38852f
-	if (conf->dev && !conf->list)
38852f
+	if (conf->dev)
38852f
 		di_flag = DI_WWID;
38852f
 
38852f
-	if (conf->list > 1)
38852f
+	if (conf->cmd == CMD_LIST_LONG)
38852f
 		/* extended path info '-ll' */
38852f
 		di_flag |= DI_SYSFS | DI_CHECKER;
38852f
-	else if (conf->list)
38852f
+	else if (conf->cmd == CMD_LIST_SHORT)
38852f
 		/* minimum path info '-l' */
38852f
 		di_flag |= DI_SYSFS;
38852f
 	else
38852f
@@ -345,7 +348,7 @@ configure (void)
38852f
 
38852f
 	filter_pathvec(pathvec, refwwid);
38852f
 
38852f
-	if (conf->list) {
38852f
+	if (conf->cmd != CMD_CREATE && conf->cmd != CMD_DRY_RUN) {
38852f
 		r = 0;
38852f
 		goto out;
38852f
 	}
38852f
@@ -440,7 +443,7 @@ main (int argc, char *argv[])
38852f
 	int r = 1;
38852f
 	long int timestamp = -1;
38852f
 	int valid = -1;
38852f
-	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
38852f
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BritT:qwW")) != EOF ) {
38852f
 		switch(arg) {
38852f
 		case 'T':
38852f
 			if (optarg[0] == ':')
38852f
@@ -476,7 +479,7 @@ main (int argc, char *argv[])
38852f
 	if (dm_prereq())
38852f
 		exit(1);
38852f
 
38852f
-	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
38852f
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BritT:qwW")) != EOF ) {
38852f
 		switch(arg) {
38852f
 		case 1: printf("optarg : %s\n",optarg);
38852f
 			break;
38852f
@@ -499,11 +502,11 @@ main (int argc, char *argv[])
38852f
 			conf->allow_queueing = 1;
38852f
 			break;
38852f
 		case 'c':
38852f
-			conf->dry_run = 2;
38852f
+			conf->cmd = CMD_VALID_PATH;
38852f
 			break;
38852f
 		case 'd':
38852f
-			if (!conf->dry_run)
38852f
-				conf->dry_run = 1;
38852f
+			if (conf->cmd == CMD_CREATE)
38852f
+				conf->cmd = CMD_DRY_RUN;
38852f
 			break;
38852f
 		case 'f':
38852f
 			conf->remove = FLUSH_ONE;
38852f
@@ -512,11 +515,10 @@ main (int argc, char *argv[])
38852f
 			conf->remove = FLUSH_ALL;
38852f
 			break;
38852f
 		case 'l':
38852f
-			conf->list = 1;
38852f
-			conf->dry_run = 1;
38852f
-
38852f
 			if (optarg && !strncmp(optarg, "l", 1))
38852f
-				conf->list++;
38852f
+				conf->cmd = CMD_LIST_LONG;
38852f
+			else
38852f
+				conf->cmd = CMD_LIST_SHORT;
38852f
 
38852f
 			break;
38852f
 		case 'M':
38852f
@@ -535,6 +537,9 @@ main (int argc, char *argv[])
38852f
 		case 'r':
38852f
 			conf->force_reload = 1;
38852f
 			break;
38852f
+		case 'i':
38852f
+			conf->ignore_wwids = 1;
38852f
+			break;
38852f
 		case 't':
38852f
 			r = dump_config();
38852f
 			goto out;
38852f
@@ -548,13 +553,13 @@ main (int argc, char *argv[])
38852f
 			usage(argv[0]);
38852f
 			exit(0);
38852f
 		case 'w':
38852f
-			conf->dry_run = 3;
38852f
+			conf->cmd = CMD_REMOVE_WWID;
38852f
 			break;
38852f
 		case 'W':
38852f
-			conf->dry_run = 4;
38852f
+			conf->cmd = CMD_RESET_WWIDS;
38852f
 			break;
38852f
 		case 'a':
38852f
-			conf->dry_run = 5;
38852f
+			conf->cmd = CMD_ADD_WWID;
38852f
 			break;
38852f
 		case ':':
38852f
 			fprintf(stderr, "Missing option argument\n");
38852f
@@ -600,16 +605,16 @@ main (int argc, char *argv[])
38852f
 	}
38852f
 	dm_init();
38852f
 
38852f
-	if (conf->dry_run == 2 &&
38852f
+	if (conf->cmd == CMD_VALID_PATH &&
38852f
 	    (!conf->dev || conf->dev_type == DEV_DEVMAP)) {
38852f
 		condlog(0, "the -c option requires a path to check");
38852f
 		goto out;
38852f
 	}
38852f
-	if (conf->dry_run == 3 && !conf->dev) {
38852f
+	if (conf->cmd == CMD_REMOVE_WWID && !conf->dev) {
38852f
 		condlog(0, "the -w option requires a device");
38852f
 		goto out;
38852f
 	}
38852f
-	if (conf->dry_run == 4) {
38852f
+	if (conf->cmd == CMD_RESET_WWIDS) {
38852f
 		struct multipath * mpp;
38852f
 		int i;
38852f
 		vector curmp;
38852f
Index: multipath-tools-130222/multipath/multipath.8
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/multipath/multipath.8
38852f
+++ multipath-tools-130222/multipath/multipath.8
38852f
@@ -8,7 +8,7 @@ multipath \- Device mapper target autoco
38852f
 .RB [\| \-b\ \c
38852f
 .IR bindings_file \|]
38852f
 .RB [\| \-d \|]
38852f
-.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-a | \-A | \-w | \-W \|]
38852f
+.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-r | \-a | \-A | \-w | \-W \|]
38852f
 .RB [\| \-p\ \c
38852f
 .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
38852f
 .RB [\| device \|]
38852f
@@ -55,6 +55,9 @@ print internal hardware table to stdout
38852f
 .B \-r
38852f
 force devmap reload
38852f
 .TP
38852f
+.B \-i
38852f
+ignore wwids file when processing devices
38852f
+.TP
38852f
 .B \-B
38852f
 treat the bindings file as read only
38852f
 .TP
38852f
Index: multipath-tools-130222/libmultipath/configure.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/configure.c
38852f
+++ multipath-tools-130222/libmultipath/configure.c
38852f
@@ -580,7 +580,7 @@ domap (struct multipath * mpp, char * pa
38852f
 	/*
38852f
 	 * last chance to quit before touching the devmaps
38852f
 	 */
38852f
-	if (conf->dry_run && mpp->action != ACT_NOTHING) {
38852f
+	if (conf->cmd == CMD_DRY_RUN && mpp->action != ACT_NOTHING) {
38852f
 		print_multipath_topology(mpp, conf->verbosity);
38852f
 		return DOMAP_DRY;
38852f
 	}
38852f
Index: multipath-tools-130222/libmultipath/discovery.c
38852f
===================================================================
38852f
--- multipath-tools-130222.orig/libmultipath/discovery.c
38852f
+++ multipath-tools-130222/libmultipath/discovery.c
38852f
@@ -54,7 +54,8 @@ store_pathinfo (vector pathvec, vector h
38852f
 	}
38852f
 	pp->udev = udev_device_ref(udevice);
38852f
 	err = pathinfo(pp, hwtable,
38852f
-		       (conf->dry_run == 3)? flag : (flag | DI_BLACKLIST));
38852f
+		       (conf->cmd == CMD_REMOVE_WWID)? flag :
38852f
+						       (flag | DI_BLACKLIST));
38852f
 	if (err)
38852f
 		goto out;
38852f
 
38852f
@@ -1101,7 +1102,7 @@ get_uid (struct path * pp)
38852f
 
38852f
 	memset(pp->wwid, 0, WWID_SIZE);
38852f
 	value = udev_device_get_property_value(pp->udev, pp->uid_attribute);
38852f
-	if ((!value || strlen(value) == 0) && conf->dry_run == 2)
38852f
+	if ((!value || strlen(value) == 0) && conf->cmd == CMD_VALID_PATH)
38852f
 		value = getenv(pp->uid_attribute);
38852f
 	if (value && strlen(value)) {
38852f
 		size_t len = WWID_SIZE;