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

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