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