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

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