From 816bea4c19c24a4ae9063ea2ec1e87f898288b91 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Mon, 1 Apr 2013 14:17:27 -0500 Subject: [PATCH] device-mapper-multipath-0.4.9-47 Add 0021-RHBZ-919119-respect-kernel-cmdline.patch * keep the multipath.rules udev file from running and multipathd from starting if nompath is on the kernel command line Add 0022-RH-multipathd-check-wwids.patch * Whenever multipath runs configure, it will check the wwids, and add any missing ones to the wwids file Add 0023-RH-multipath-wipe-wwid.patch * multipath's -w command will remove a wwid from the wwids file Add 0024-RH-multipath-wipe-wwids.patch * multipath's -W command will set reset the wwids file to just the current devices Add 0025-UPBZ-916668_add_maj_min.patch Resolves: bz #919119 --- 0021-RHBZ-919119-respect-kernel-cmdline.patch | 30 +++ 0022-RH-multipathd-check-wwids.patch | 16 ++ 0023-RH-multipath-wipe-wwid.patch | 239 ++++++++++++++++++ 0024-RH-multipath-wipe-wwids.patch | 164 ++++++++++++ 0025-UPBZ-916668_add_maj_min.patch | 29 +++ device-mapper-multipath.spec | 27 +- 6 files changed, 504 insertions(+), 1 deletion(-) create mode 100644 0021-RHBZ-919119-respect-kernel-cmdline.patch create mode 100644 0022-RH-multipathd-check-wwids.patch create mode 100644 0023-RH-multipath-wipe-wwid.patch create mode 100644 0024-RH-multipath-wipe-wwids.patch create mode 100644 0025-UPBZ-916668_add_maj_min.patch diff --git a/0021-RHBZ-919119-respect-kernel-cmdline.patch b/0021-RHBZ-919119-respect-kernel-cmdline.patch new file mode 100644 index 0000000..cea1e48 --- /dev/null +++ b/0021-RHBZ-919119-respect-kernel-cmdline.patch @@ -0,0 +1,30 @@ +--- + multipath/multipath.rules | 2 ++ + multipathd/multipathd.service | 1 + + 2 files changed, 3 insertions(+) + +Index: multipath-tools-130222/multipath/multipath.rules +=================================================================== +--- multipath-tools-130222.orig/multipath/multipath.rules ++++ multipath-tools-130222/multipath/multipath.rules +@@ -2,6 +2,8 @@ + # so name them after their devmap name + SUBSYSTEM!="block", GOTO="end_mpath" + ++IMPORT{cmdline}="nompath" ++ENV{nompath}=="?*", GOTO="end_mpath" + ENV{MPATH_SBIN_PATH}="/sbin" + TEST!="$env{MPATH_SBIN_PATH}/multipath", ENV{MPATH_SBIN_PATH}="/usr/sbin" + +Index: multipath-tools-130222/multipathd/multipathd.service +=================================================================== +--- multipath-tools-130222.orig/multipathd/multipathd.service ++++ multipath-tools-130222/multipathd/multipathd.service +@@ -3,6 +3,7 @@ Description=Device-Mapper Multipath Devi + Before=iscsi.service iscsid.service lvm2-activation-early.service + After=syslog.target + ConditionPathExists=/etc/multipath.conf ++ConditionKernelCommandLine=!nompath + DefaultDependencies=no + Conflicts=shutdown.target + diff --git a/0022-RH-multipathd-check-wwids.patch b/0022-RH-multipathd-check-wwids.patch new file mode 100644 index 0000000..b6e8f42 --- /dev/null +++ b/0022-RH-multipathd-check-wwids.patch @@ -0,0 +1,16 @@ +--- + multipathd/main.c | 1 + + 1 file changed, 1 insertion(+) + +Index: multipath-tools-130222/multipathd/main.c +=================================================================== +--- multipath-tools-130222.orig/multipathd/main.c ++++ multipath-tools-130222/multipathd/main.c +@@ -1363,6 +1363,7 @@ configure (struct vectors * vecs, int st + + sync_maps_state(mpvec); + vector_foreach_slot(mpvec, mpp, i){ ++ remember_wwid(mpp->wwid); + update_map_pr(mpp); + } + diff --git a/0023-RH-multipath-wipe-wwid.patch b/0023-RH-multipath-wipe-wwid.patch new file mode 100644 index 0000000..6de04bf --- /dev/null +++ b/0023-RH-multipath-wipe-wwid.patch @@ -0,0 +1,239 @@ +--- + libmultipath/discovery.c | 3 + + libmultipath/wwids.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ + libmultipath/wwids.h | 1 + multipath/main.c | 26 ++++++++++++-- + multipath/multipath.8 | 5 ++ + 5 files changed, 115 insertions(+), 6 deletions(-) + +Index: multipath-tools-130222/libmultipath/discovery.c +=================================================================== +--- multipath-tools-130222.orig/libmultipath/discovery.c ++++ multipath-tools-130222/libmultipath/discovery.c +@@ -53,7 +53,8 @@ store_pathinfo (vector pathvec, vector h + goto out; + } + pp->udev = udev_device_ref(udevice); +- err = pathinfo(pp, hwtable, flag | DI_BLACKLIST); ++ err = pathinfo(pp, hwtable, ++ (conf->dry_run == 3)? flag : (flag | DI_BLACKLIST)); + if (err) + goto out; + +Index: multipath-tools-130222/libmultipath/wwids.c +=================================================================== +--- multipath-tools-130222.orig/libmultipath/wwids.c ++++ multipath-tools-130222/libmultipath/wwids.c +@@ -82,6 +82,92 @@ write_out_wwid(int fd, char *wwid) { + } + + int ++do_remove_wwid(int fd, char *str) { ++ char buf[4097]; ++ char *ptr; ++ off_t start = 0; ++ int bytes; ++ ++ while (1) { ++ if (lseek(fd, start, SEEK_SET) < 0) { ++ condlog(0, "wwid file read lseek failed : %s", ++ strerror(errno)); ++ return -1; ++ } ++ bytes = read(fd, buf, 4096); ++ if (bytes < 0) { ++ if (errno == EINTR || errno == EAGAIN) ++ continue; ++ condlog(0, "failed to read from wwids file : %s", ++ strerror(errno)); ++ return -1; ++ } ++ if (!bytes) /* didn't find wwid to remove */ ++ return 1; ++ buf[bytes] = '\0'; ++ ptr = strstr(buf, str); ++ if (ptr != NULL) { ++ condlog(3, "found '%s'", str); ++ if (lseek(fd, start + (ptr - buf), SEEK_SET) < 0) { ++ condlog(0, "write lseek failed : %s", ++ strerror(errno)); ++ return -1; ++ } ++ while (1) { ++ if (write(fd, "#", 1) < 0) { ++ if (errno == EINTR || errno == EAGAIN) ++ continue; ++ condlog(0, "failed to write to wwids file : %s", strerror(errno)); ++ return -1; ++ } ++ return 0; ++ } ++ } ++ ptr = strrchr(buf, '\n'); ++ if (ptr == NULL) { /* shouldn't happen, assume it is EOF */ ++ condlog(4, "couldn't find newline, assuming end of file"); ++ return 1; ++ } ++ start = start + (ptr - buf) + 1; ++ } ++} ++ ++ ++int ++remove_wwid(char *wwid) { ++ int fd, len, can_write; ++ char *str; ++ int ret = -1; ++ ++ len = strlen(wwid) + 4; /* two slashes the newline and a zero byte */ ++ str = malloc(len); ++ if (str == NULL) { ++ condlog(0, "can't allocate memory to remove wwid : %s", ++ strerror(errno)); ++ return -1; ++ } ++ if (snprintf(str, len, "/%s/\n", wwid) >= len) { ++ condlog(0, "string overflow trying to remove wwid"); ++ goto out; ++ } ++ condlog(3, "removing line '%s' from wwids file", str); ++ fd = open_file(conf->wwids_file, &can_write, WWIDS_FILE_HEADER); ++ if (fd < 0) ++ goto out; ++ if (!can_write) { ++ condlog(0, "cannot remove wwid. wwids file is read-only"); ++ goto out_file; ++ } ++ ret = do_remove_wwid(fd, str); ++ ++out_file: ++ close(fd); ++out: ++ free(str); ++ return ret; ++} ++ ++int + check_wwids_file(char *wwid, int write_wwid) + { + int fd, can_write, found, ret; +Index: multipath-tools-130222/libmultipath/wwids.h +=================================================================== +--- multipath-tools-130222.orig/libmultipath/wwids.h ++++ multipath-tools-130222/libmultipath/wwids.h +@@ -15,5 +15,6 @@ + int should_multipath(struct path *pp, vector pathvec); + int remember_wwid(char *wwid); + int check_wwids_file(char *wwid, int write_wwid); ++int remove_wwid(char *wwid); + + #endif /* _WWIDS_H */ +Index: multipath-tools-130222/multipath/main.c +=================================================================== +--- multipath-tools-130222.orig/multipath/main.c ++++ multipath-tools-130222/multipath/main.c +@@ -83,7 +83,7 @@ usage (char * progname) + { + fprintf (stderr, VERSION_STRING); + fprintf (stderr, "Usage:\n"); +- fprintf (stderr, " %s [-c] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname); ++ fprintf (stderr, " %s [-c|-w] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname); + fprintf (stderr, " %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname); + fprintf (stderr, " %s -F [-v lvl]\n", progname); + fprintf (stderr, " %s -t\n", progname); +@@ -104,6 +104,7 @@ usage (char * progname) + " -B treat the bindings file as read only\n" \ + " -p policy failover|multibus|group_by_serial|group_by_prio\n" \ + " -b fil bindings file location\n" \ ++ " -w remove a device from the wwids file\n" \ + " -p pol force all maps to specified path grouping policy :\n" \ + " . failover one path per priority group\n" \ + " . multibus all paths in one priority group\n" \ +@@ -212,7 +213,6 @@ get_dm_mpvec (vector curmp, vector pathv + + if (!conf->dry_run) + reinstate_paths(mpp); +- remember_wwid(mpp->wwid); + } + return 0; + } +@@ -262,7 +262,7 @@ configure (void) + /* + * if we have a blacklisted device parameter, exit early + */ +- if (dev && conf->dev_type == DEV_DEVNODE && ++ if (dev && conf->dev_type == DEV_DEVNODE && conf->dry_run != 3 && + (filter_devnode(conf->blist_devnode, + conf->elist_devnode, dev) > 0)) { + if (conf->dry_run == 2) +@@ -284,6 +284,17 @@ configure (void) + condlog(3, "scope is nul"); + goto out; + } ++ if (conf->dry_run == 3) { ++ r = remove_wwid(refwwid); ++ if (r == 0) ++ printf("wwid '%s' removed\n", refwwid); ++ else if (r == 1) { ++ printf("wwid '%s' not in wwids file\n", ++ refwwid); ++ r = 0; ++ } ++ goto out; ++ } + condlog(3, "scope limited to %s", refwwid); + if (conf->dry_run == 2) { + if (check_wwids_file(refwwid, 0) == 0){ +@@ -439,7 +450,7 @@ main (int argc, char *argv[]) + if (dm_prereq()) + exit(1); + +- while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:Brtq")) != EOF ) { ++ while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:Brtqw")) != EOF ) { + switch(arg) { + case 1: printf("optarg : %s\n",optarg); + break; +@@ -504,6 +515,9 @@ main (int argc, char *argv[]) + case 'h': + usage(argv[0]); + exit(0); ++ case 'w': ++ conf->dry_run = 3; ++ break; + case ':': + fprintf(stderr, "Missing option argument\n"); + usage(argv[0]); +@@ -555,6 +569,10 @@ main (int argc, char *argv[]) + condlog(0, "the -c option requires a path to check"); + goto out; + } ++ if (conf->dry_run == 3 && !conf->dev) { ++ condlog(0, "the -w option requires a device"); ++ goto out; ++ } + if (conf->remove == FLUSH_ONE) { + if (conf->dev_type == DEV_DEVMAP) { + r = dm_suspend_and_flush_map(conf->dev); +Index: multipath-tools-130222/multipath/multipath.8 +=================================================================== +--- multipath-tools-130222.orig/multipath/multipath.8 ++++ multipath-tools-130222/multipath/multipath.8 +@@ -8,7 +8,7 @@ multipath \- Device mapper target autoco + .RB [\| \-b\ \c + .IR bindings_file \|] + .RB [\| \-d \|] +-.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r \|] ++.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-w \|] + .RB [\| \-p\ \c + .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|] + .RB [\| device \|] +@@ -68,6 +68,9 @@ check if a block device should be a path + .B \-q + allow device tables with queue_if_no_path when multipathd is not running + .TP ++.B \-w ++remove the wwid for the specified device from the wwids file ++.TP + .BI \-p " policy" + force new maps to use the specified policy: + .RS 1.2i diff --git a/0024-RH-multipath-wipe-wwids.patch b/0024-RH-multipath-wipe-wwids.patch new file mode 100644 index 0000000..b91836c --- /dev/null +++ b/0024-RH-multipath-wipe-wwids.patch @@ -0,0 +1,164 @@ +--- + libmultipath/wwids.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ + libmultipath/wwids.h | 1 + + multipath/main.c | 29 +++++++++++++++++++++++++++-- + multipath/multipath.8 | 5 ++++- + 4 files changed, 76 insertions(+), 3 deletions(-) + +Index: multipath-tools-130222/libmultipath/wwids.c +=================================================================== +--- multipath-tools-130222.orig/libmultipath/wwids.c ++++ multipath-tools-130222/libmultipath/wwids.c +@@ -82,6 +82,50 @@ write_out_wwid(int fd, char *wwid) { + } + + int ++replace_wwids(vector mp) ++{ ++ int i, fd, can_write; ++ struct multipath * mpp; ++ size_t len; ++ int ret = -1; ++ ++ fd = open_file(conf->wwids_file, &can_write, WWIDS_FILE_HEADER); ++ if (fd < 0) ++ goto out; ++ if (!can_write) { ++ condlog(0, "cannot replace wwids. wwids file is read-only"); ++ goto out_file; ++ } ++ if (ftruncate(fd, 0) < 0) { ++ condlog(0, "cannot truncate wwids file : %s", strerror(errno)); ++ goto out_file; ++ } ++ len = strlen(WWIDS_FILE_HEADER); ++ if (write_all(fd, WWIDS_FILE_HEADER, len) != len) { ++ condlog(0, "Can't write wwid file header : %s", ++ strerror(errno)); ++ /* cleanup partially written header */ ++ if (ftruncate(fd, 0) < 0) ++ condlog(0, "Cannot truncate header : %s", ++ strerror(errno)); ++ goto out_file; ++ } ++ if (!mp || !mp->allocated) { ++ ret = 0; ++ goto out_file; ++ } ++ vector_foreach_slot(mp, mpp, i) { ++ if (write_out_wwid(fd, mpp->wwid) < 0) ++ goto out_file; ++ } ++ ret = 0; ++out_file: ++ close(fd); ++out: ++ return ret; ++} ++ ++int + do_remove_wwid(int fd, char *str) { + char buf[4097]; + char *ptr; +Index: multipath-tools-130222/libmultipath/wwids.h +=================================================================== +--- multipath-tools-130222.orig/libmultipath/wwids.h ++++ multipath-tools-130222/libmultipath/wwids.h +@@ -16,5 +16,6 @@ int should_multipath(struct path *pp, ve + int remember_wwid(char *wwid); + int check_wwids_file(char *wwid, int write_wwid); + int remove_wwid(char *wwid); ++int replace_wwids(vector mp); + + #endif /* _WWIDS_H */ +Index: multipath-tools-130222/multipath/main.c +=================================================================== +--- multipath-tools-130222.orig/multipath/main.c ++++ multipath-tools-130222/multipath/main.c +@@ -83,7 +83,7 @@ usage (char * progname) + { + fprintf (stderr, VERSION_STRING); + fprintf (stderr, "Usage:\n"); +- fprintf (stderr, " %s [-c|-w] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname); ++ fprintf (stderr, " %s [-c|-w|-W] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname); + fprintf (stderr, " %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname); + fprintf (stderr, " %s -F [-v lvl]\n", progname); + fprintf (stderr, " %s -t\n", progname); +@@ -105,6 +105,7 @@ usage (char * progname) + " -p policy failover|multibus|group_by_serial|group_by_prio\n" \ + " -b fil bindings file location\n" \ + " -w remove a device from the wwids file\n" \ ++ " -W reset the wwids file include only the current devices\n" \ + " -p pol force all maps to specified path grouping policy :\n" \ + " . failover one path per priority group\n" \ + " . multibus all paths in one priority group\n" \ +@@ -450,7 +451,7 @@ main (int argc, char *argv[]) + if (dm_prereq()) + exit(1); + +- while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:Brtqw")) != EOF ) { ++ while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:BrtqwW")) != EOF ) { + switch(arg) { + case 1: printf("optarg : %s\n",optarg); + break; +@@ -518,6 +519,9 @@ main (int argc, char *argv[]) + case 'w': + conf->dry_run = 3; + break; ++ case 'W': ++ conf->dry_run = 4; ++ break; + case ':': + fprintf(stderr, "Missing option argument\n"); + usage(argv[0]); +@@ -573,6 +577,27 @@ main (int argc, char *argv[]) + condlog(0, "the -w option requires a device"); + goto out; + } ++ if (conf->dry_run == 4) { ++ struct multipath * mpp; ++ int i; ++ vector curmp; ++ ++ curmp = vector_alloc(); ++ if (!curmp) { ++ condlog(0, "can't allocate memory for mp list"); ++ goto out; ++ } ++ if (dm_get_maps(curmp) == 0) ++ r = replace_wwids(curmp); ++ if (r == 0) ++ printf("successfully reset wwids\n"); ++ vector_foreach_slot_backwards(curmp, mpp, i) { ++ vector_del_slot(curmp, i); ++ free_multipath(mpp, KEEP_PATHS); ++ } ++ vector_free(curmp); ++ goto out; ++ } + if (conf->remove == FLUSH_ONE) { + if (conf->dev_type == DEV_DEVMAP) { + r = dm_suspend_and_flush_map(conf->dev); +Index: multipath-tools-130222/multipath/multipath.8 +=================================================================== +--- multipath-tools-130222.orig/multipath/multipath.8 ++++ multipath-tools-130222/multipath/multipath.8 +@@ -8,7 +8,7 @@ multipath \- Device mapper target autoco + .RB [\| \-b\ \c + .IR bindings_file \|] + .RB [\| \-d \|] +-.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-w \|] ++.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-w | \-W \|] + .RB [\| \-p\ \c + .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|] + .RB [\| device \|] +@@ -71,6 +71,9 @@ allow device tables with queue_if_no_pat + .B \-w + remove the wwid for the specified device from the wwids file + .TP ++.B \-W ++reset the wwids file to only include the current multipath devices ++.TP + .BI \-p " policy" + force new maps to use the specified policy: + .RS 1.2i diff --git a/0025-UPBZ-916668_add_maj_min.patch b/0025-UPBZ-916668_add_maj_min.patch new file mode 100644 index 0000000..615533d --- /dev/null +++ b/0025-UPBZ-916668_add_maj_min.patch @@ -0,0 +1,29 @@ +--- + multipathd/main.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +Index: multipath-tools-130222/multipathd/main.c +=================================================================== +--- multipath-tools-130222.orig/multipathd/main.c ++++ multipath-tools-130222/multipathd/main.c +@@ -537,7 +537,8 @@ rescan: + goto fail_map; + + if (retries >= 0) { +- condlog(2, "%s path added to devmap %s", pp->dev, mpp->alias); ++ condlog(2, "%s [%s]: path added to devmap %s", ++ pp->dev, pp->dev_t, mpp->alias); + return 0; + } + else +@@ -642,8 +643,8 @@ ev_remove_path (struct path *pp, struct + } + sync_map_state(mpp); + +- condlog(2, "%s: path removed from map %s", +- pp->dev, mpp->alias); ++ condlog(2, "%s [%s]: path removed from map %s", ++ pp->dev, pp->dev_t, mpp->alias); + } + } + diff --git a/device-mapper-multipath.spec b/device-mapper-multipath.spec index 94b892f..794d5d9 100644 --- a/device-mapper-multipath.spec +++ b/device-mapper-multipath.spec @@ -1,7 +1,7 @@ Summary: Tools to manage multipath devices using device-mapper Name: device-mapper-multipath Version: 0.4.9 -Release: 46%{?dist} +Release: 47%{?dist} License: GPL+ Group: System Environment/Base URL: http://christophe.varoqui.free.fr/ @@ -28,6 +28,11 @@ Patch0017: 0017-RH-fix-sigusr1.patch Patch0018: 0018-RH-fix-factorize.patch Patch0019: 0019-RH-fix-sockets.patch Patch0020: 0020-RHBZ-907360-static-pthread-init.patch +Patch0021: 0021-RHBZ-919119-respect-kernel-cmdline.patch +Patch0022: 0022-RH-multipathd-check-wwids.patch +Patch0023: 0023-RH-multipath-wipe-wwid.patch +Patch0024: 0024-RH-multipath-wipe-wwids.patch +Patch0025: 0025-UPBZ-916668_add_maj_min.patch # runtime Requires: %{name}-libs = %{version}-%{release} @@ -100,6 +105,11 @@ kpartx manages partition creation and removal for device-mapper devices. %patch0018 -p1 %patch0019 -p1 %patch0020 -p1 +%patch0021 -p1 +%patch0022 -p1 +%patch0023 -p1 +%patch0024 -p1 +%patch0025 -p1 cp %{SOURCE1} . %build @@ -190,6 +200,21 @@ bin/systemctl --no-reload enable multipathd.service >/dev/null 2>&1 ||: %{_mandir}/man8/kpartx.8.gz %changelog +* Mon Apr 1 2013 Benjamin Marzinski 0.4.9-47 +- Add 0021-RHBZ-919119-respect-kernel-cmdline.patch + * keep the multipath.rules udev file from running and multipathd from + starting if nompath is on the kernel command line +- Add 0022-RH-multipathd-check-wwids.patch + * Whenever multipath runs configure, it will check the wwids, and + add any missing ones to the wwids file +- Add 0023-RH-multipath-wipe-wwid.patch + * multipath's -w command will remove a wwid from the wwids file +- Add 0024-RH-multipath-wipe-wwids.patch + * multipath's -W command will set reset the wwids file to just the current + devices +- Add 0025-UPBZ-916668_add_maj_min.patch +- Resolves: bz #919119 + * Thu Mar 28 2013 Benjamin Marzinski 0.4.9-46 - Add 0020-RHBZ-907360-static-pthread-init.patch * statically initialize the uevent pthread structures