|
|
f20720 |
---
|
|
|
f20720 |
libmultipath/wwids.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
f20720 |
libmultipath/wwids.h | 1 +
|
|
|
f20720 |
multipath/main.c | 29 +++++++++++++++++++++++++++--
|
|
|
f20720 |
multipath/multipath.8 | 5 ++++-
|
|
|
f20720 |
4 files changed, 76 insertions(+), 3 deletions(-)
|
|
|
f20720 |
|
|
|
f20720 |
Index: multipath-tools-130222/libmultipath/wwids.c
|
|
|
f20720 |
===================================================================
|
|
|
f20720 |
--- multipath-tools-130222.orig/libmultipath/wwids.c
|
|
|
f20720 |
+++ multipath-tools-130222/libmultipath/wwids.c
|
|
|
f20720 |
@@ -82,6 +82,50 @@ write_out_wwid(int fd, char *wwid) {
|
|
|
f20720 |
}
|
|
|
f20720 |
|
|
|
f20720 |
int
|
|
|
f20720 |
+replace_wwids(vector mp)
|
|
|
f20720 |
+{
|
|
|
f20720 |
+ int i, fd, can_write;
|
|
|
f20720 |
+ struct multipath * mpp;
|
|
|
f20720 |
+ size_t len;
|
|
|
f20720 |
+ int ret = -1;
|
|
|
f20720 |
+
|
|
|
f20720 |
+ fd = open_file(conf->wwids_file, &can_write, WWIDS_FILE_HEADER);
|
|
|
f20720 |
+ if (fd < 0)
|
|
|
f20720 |
+ goto out;
|
|
|
f20720 |
+ if (!can_write) {
|
|
|
f20720 |
+ condlog(0, "cannot replace wwids. wwids file is read-only");
|
|
|
f20720 |
+ goto out_file;
|
|
|
f20720 |
+ }
|
|
|
f20720 |
+ if (ftruncate(fd, 0) < 0) {
|
|
|
f20720 |
+ condlog(0, "cannot truncate wwids file : %s", strerror(errno));
|
|
|
f20720 |
+ goto out_file;
|
|
|
f20720 |
+ }
|
|
|
f20720 |
+ len = strlen(WWIDS_FILE_HEADER);
|
|
|
f20720 |
+ if (write_all(fd, WWIDS_FILE_HEADER, len) != len) {
|
|
|
f20720 |
+ condlog(0, "Can't write wwid file header : %s",
|
|
|
f20720 |
+ strerror(errno));
|
|
|
f20720 |
+ /* cleanup partially written header */
|
|
|
f20720 |
+ if (ftruncate(fd, 0) < 0)
|
|
|
f20720 |
+ condlog(0, "Cannot truncate header : %s",
|
|
|
f20720 |
+ strerror(errno));
|
|
|
f20720 |
+ goto out_file;
|
|
|
f20720 |
+ }
|
|
|
f20720 |
+ if (!mp || !mp->allocated) {
|
|
|
f20720 |
+ ret = 0;
|
|
|
f20720 |
+ goto out_file;
|
|
|
f20720 |
+ }
|
|
|
f20720 |
+ vector_foreach_slot(mp, mpp, i) {
|
|
|
f20720 |
+ if (write_out_wwid(fd, mpp->wwid) < 0)
|
|
|
f20720 |
+ goto out_file;
|
|
|
f20720 |
+ }
|
|
|
f20720 |
+ ret = 0;
|
|
|
f20720 |
+out_file:
|
|
|
f20720 |
+ close(fd);
|
|
|
f20720 |
+out:
|
|
|
f20720 |
+ return ret;
|
|
|
f20720 |
+}
|
|
|
f20720 |
+
|
|
|
f20720 |
+int
|
|
|
f20720 |
do_remove_wwid(int fd, char *str) {
|
|
|
f20720 |
char buf[4097];
|
|
|
f20720 |
char *ptr;
|
|
|
f20720 |
Index: multipath-tools-130222/libmultipath/wwids.h
|
|
|
f20720 |
===================================================================
|
|
|
f20720 |
--- multipath-tools-130222.orig/libmultipath/wwids.h
|
|
|
f20720 |
+++ multipath-tools-130222/libmultipath/wwids.h
|
|
|
f20720 |
@@ -16,5 +16,6 @@ int should_multipath(struct path *pp, ve
|
|
|
f20720 |
int remember_wwid(char *wwid);
|
|
|
f20720 |
int check_wwids_file(char *wwid, int write_wwid);
|
|
|
f20720 |
int remove_wwid(char *wwid);
|
|
|
f20720 |
+int replace_wwids(vector mp);
|
|
|
f20720 |
|
|
|
f20720 |
#endif /* _WWIDS_H */
|
|
|
f20720 |
Index: multipath-tools-130222/multipath/main.c
|
|
|
f20720 |
===================================================================
|
|
|
f20720 |
--- multipath-tools-130222.orig/multipath/main.c
|
|
|
f20720 |
+++ multipath-tools-130222/multipath/main.c
|
|
|
f20720 |
@@ -83,7 +83,7 @@ usage (char * progname)
|
|
|
f20720 |
{
|
|
|
f20720 |
fprintf (stderr, VERSION_STRING);
|
|
|
f20720 |
fprintf (stderr, "Usage:\n");
|
|
|
f20720 |
- fprintf (stderr, " %s [-c|-w] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
|
|
|
f20720 |
+ fprintf (stderr, " %s [-c|-w|-W] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
|
|
|
f20720 |
fprintf (stderr, " %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname);
|
|
|
f20720 |
fprintf (stderr, " %s -F [-v lvl]\n", progname);
|
|
|
f20720 |
fprintf (stderr, " %s -t\n", progname);
|
|
|
f20720 |
@@ -105,6 +105,7 @@ usage (char * progname)
|
|
|
f20720 |
" -p policy failover|multibus|group_by_serial|group_by_prio\n" \
|
|
|
f20720 |
" -b fil bindings file location\n" \
|
|
|
f20720 |
" -w remove a device from the wwids file\n" \
|
|
|
f20720 |
+ " -W reset the wwids file include only the current devices\n" \
|
|
|
f20720 |
" -p pol force all maps to specified path grouping policy :\n" \
|
|
|
f20720 |
" . failover one path per priority group\n" \
|
|
|
f20720 |
" . multibus all paths in one priority group\n" \
|
|
|
f20720 |
@@ -450,7 +451,7 @@ main (int argc, char *argv[])
|
|
|
f20720 |
if (dm_prereq())
|
|
|
f20720 |
exit(1);
|
|
|
f20720 |
|
|
|
f20720 |
- while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:Brtqw")) != EOF ) {
|
|
|
f20720 |
+ while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:BrtqwW")) != EOF ) {
|
|
|
f20720 |
switch(arg) {
|
|
|
f20720 |
case 1: printf("optarg : %s\n",optarg);
|
|
|
f20720 |
break;
|
|
|
f20720 |
@@ -518,6 +519,9 @@ main (int argc, char *argv[])
|
|
|
f20720 |
case 'w':
|
|
|
f20720 |
conf->dry_run = 3;
|
|
|
f20720 |
break;
|
|
|
f20720 |
+ case 'W':
|
|
|
f20720 |
+ conf->dry_run = 4;
|
|
|
f20720 |
+ break;
|
|
|
f20720 |
case ':':
|
|
|
f20720 |
fprintf(stderr, "Missing option argument\n");
|
|
|
f20720 |
usage(argv[0]);
|
|
|
f20720 |
@@ -573,6 +577,27 @@ main (int argc, char *argv[])
|
|
|
f20720 |
condlog(0, "the -w option requires a device");
|
|
|
f20720 |
goto out;
|
|
|
f20720 |
}
|
|
|
f20720 |
+ if (conf->dry_run == 4) {
|
|
|
f20720 |
+ struct multipath * mpp;
|
|
|
f20720 |
+ int i;
|
|
|
f20720 |
+ vector curmp;
|
|
|
f20720 |
+
|
|
|
f20720 |
+ curmp = vector_alloc();
|
|
|
f20720 |
+ if (!curmp) {
|
|
|
f20720 |
+ condlog(0, "can't allocate memory for mp list");
|
|
|
f20720 |
+ goto out;
|
|
|
f20720 |
+ }
|
|
|
f20720 |
+ if (dm_get_maps(curmp) == 0)
|
|
|
f20720 |
+ r = replace_wwids(curmp);
|
|
|
f20720 |
+ if (r == 0)
|
|
|
f20720 |
+ printf("successfully reset wwids\n");
|
|
|
f20720 |
+ vector_foreach_slot_backwards(curmp, mpp, i) {
|
|
|
f20720 |
+ vector_del_slot(curmp, i);
|
|
|
f20720 |
+ free_multipath(mpp, KEEP_PATHS);
|
|
|
f20720 |
+ }
|
|
|
f20720 |
+ vector_free(curmp);
|
|
|
f20720 |
+ goto out;
|
|
|
f20720 |
+ }
|
|
|
f20720 |
if (conf->remove == FLUSH_ONE) {
|
|
|
f20720 |
if (conf->dev_type == DEV_DEVMAP) {
|
|
|
f20720 |
r = dm_suspend_and_flush_map(conf->dev);
|
|
|
f20720 |
Index: multipath-tools-130222/multipath/multipath.8
|
|
|
f20720 |
===================================================================
|
|
|
f20720 |
--- multipath-tools-130222.orig/multipath/multipath.8
|
|
|
f20720 |
+++ multipath-tools-130222/multipath/multipath.8
|
|
|
f20720 |
@@ -8,7 +8,7 @@ multipath \- Device mapper target autoco
|
|
|
f20720 |
.RB [\| \-b\ \c
|
|
|
f20720 |
.IR bindings_file \|]
|
|
|
f20720 |
.RB [\| \-d \|]
|
|
|
f20720 |
-.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-w \|]
|
|
|
f20720 |
+.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-w | \-W \|]
|
|
|
f20720 |
.RB [\| \-p\ \c
|
|
|
f20720 |
.BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
|
|
|
f20720 |
.RB [\| device \|]
|
|
|
f20720 |
@@ -71,6 +71,9 @@ allow device tables with queue_if_no_pat
|
|
|
f20720 |
.B \-w
|
|
|
f20720 |
remove the wwid for the specified device from the wwids file
|
|
|
f20720 |
.TP
|
|
|
f20720 |
+.B \-W
|
|
|
f20720 |
+reset the wwids file to only include the current multipath devices
|
|
|
f20720 |
+.TP
|
|
|
f20720 |
.BI \-p " policy"
|
|
|
f20720 |
force new maps to use the specified policy:
|
|
|
f20720 |
.RS 1.2i
|