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