diff --git a/SOURCES/0060-kpartx-free-loop-device-after-listing-partitions.patch b/SOURCES/0060-kpartx-free-loop-device-after-listing-partitions.patch new file mode 100644 index 0000000..c50bbc0 --- /dev/null +++ b/SOURCES/0060-kpartx-free-loop-device-after-listing-partitions.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Tue, 9 Feb 2021 17:16:04 -0600 +Subject: [PATCH] kpartx: free loop device after listing partitions + +If "kpartx -l" is run on a file that doesn't already have a loop device +associated with it, it will create a loop device to run the command. +Starting with da59d15c6 ("Fix loopback file with kpartx -av"), it will +not free the loop device when exitting. This is because it checks if the +the file it stat()ed is a regular file, before freeing the loop device. +However, after da59d15c6, stat() is rerun on the loop device itself, so +the check fails. There is no need to check this, if loopcreated is +true, then the file will be a kpartx created loop device, and should be +freed. + +Also, keep kpartx from printing that the loop device has been removed +at normal verbosity. + +Fixes: da59d15c6 ("Fix loopback file with kpartx -av") +Signed-off-by: Benjamin Marzinski +--- + kpartx/kpartx.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c +index 653ce0c8..a337a07b 100644 +--- a/kpartx/kpartx.c ++++ b/kpartx/kpartx.c +@@ -407,7 +407,7 @@ main(int argc, char **argv){ + fprintf(stderr, "can't del loop : %s\n", + loopdev); + r = 1; +- } else ++ } else if (verbose) + fprintf(stderr, "loop deleted : %s\n", loopdev); + } + goto end; +@@ -649,16 +649,17 @@ main(int argc, char **argv){ + if (n > 0) + break; + } +- if (what == LIST && loopcreated && S_ISREG (buf.st_mode)) { ++ if (what == LIST && loopcreated) { + if (fd != -1) + close(fd); + if (del_loop(device)) { + if (verbose) +- printf("can't del loop : %s\n", ++ fprintf(stderr, "can't del loop : %s\n", + device); + exit(1); + } +- printf("loop deleted : %s\n", device); ++ if (verbose) ++ fprintf(stderr, "loop deleted : %s\n", device); + } + + end: +-- +2.17.2 + diff --git a/SOURCES/0061-RH-fix-find_multipaths-in-mpathconf.patch b/SOURCES/0061-RH-fix-find_multipaths-in-mpathconf.patch new file mode 100644 index 0000000..ea9d530 --- /dev/null +++ b/SOURCES/0061-RH-fix-find_multipaths-in-mpathconf.patch @@ -0,0 +1,134 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 10 Feb 2021 15:42:42 -0600 +Subject: [PATCH] RH: fix find_multipaths in mpathconf + +mpathconf wasn't correctly dealing with the new rhel-8 values for +find_multipaths + +Signed-off-by: Benjamin Marzinski +--- + multipath/mpathconf | 38 +++++++++++++++++++------------------- + multipath/mpathconf.8 | 14 +++++++------- + 2 files changed, 26 insertions(+), 26 deletions(-) + +diff --git a/multipath/mpathconf b/multipath/mpathconf +index f34003c9..2f4f3eaf 100644 +--- a/multipath/mpathconf ++++ b/multipath/mpathconf +@@ -54,7 +54,7 @@ function usage + echo "Disable: --disable" + echo "Only allow certain wwids (instead of enable): --allow " + echo "Set user_friendly_names (Default y): --user_friendly_names " +- echo "Set find_multipaths (Default y): --find_multipaths " ++ echo "Set find_multipaths (Default y): --find_multipaths " + echo "Set default property blacklist (Default y): --property_blacklist " + echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign " + echo "Load the dm-multipath modules on enable (Default y): --with_module " +@@ -224,8 +224,12 @@ function validate_args + echo "--user_friendly_names must be either 'y' or 'n'" + exit 1 + fi +- if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then +- echo "--find_multipaths must be either 'y' or 'n'" ++ if [ "$FIND" = "y" ]; then ++ FIND="yes" ++ elif [ "$FIND" = "n" ]; then ++ FIND="no" ++ elif [ -n "$FIND" ] && [ "$FIND" != "yes" -a "$FIND" != "no" -a "$FIND" != "strict" -a "$FIND" != "greedy" -a "$FIND" != "smart" ]; then ++ echo "--find_multipaths must be one of 'yes' 'no' 'strict' 'greedy' or 'smart'" + exit 1 + fi + if [ -n "$PROPERTY" ] && [ "$PROPERTY" != "y" -a "$PROPERTY" != "n" ]; then +@@ -327,10 +331,11 @@ if [ "$HAVE_BLACKLIST" = "1" ]; then + fi + + if [ "$HAVE_DEFAULTS" = "1" ]; then +- if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then +- HAVE_FIND=1 +- elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then +- HAVE_FIND=0 ++ HAVE_FIND=`sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | sed -n 's/^[[:blank:]]*find_multipaths[[:blank:]]*\([^[:blank:]]*\).*$/\1/p' | sed -n 1p` ++ if [ "$HAVE_FIND" = "1" ]; then ++ HAVE_FIND="yes" ++ elif [ "$HAVE_FIND" = "0" ]; then ++ HAVE_FIND="no" + fi + if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then + HAVE_FRIENDLY=1 +@@ -360,10 +365,10 @@ if [ -n "$SHOW_STATUS" ]; then + else + echo "multipath is disabled" + fi +- if [ -z "$HAVE_FIND" -o "$HAVE_FIND" = 0 ]; then +- echo "find_multipaths is disabled" ++ if [ -z "$HAVE_FIND" ]; then ++ echo "find_multipaths is no" + else +- echo "find_multipaths is enabled" ++ echo "find_multipaths is $HAVE_FIND" + fi + if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then + echo "user_friendly_names is disabled" +@@ -455,19 +460,14 @@ elif [ "$ENABLE" = 0 ]; then + fi + fi + +-if [ "$FIND" = "n" ]; then +- if [ "$HAVE_FIND" = 1 ]; then +- sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/ find_multipaths no/' $TMPFILE +- CHANGED_CONFIG=1 +- fi +-elif [ "$FIND" = "y" ]; then ++if [ -n "$FIND" ]; then + if [ -z "$HAVE_FIND" ]; then + sed -i '/^defaults[[:space:]]*{/ a\ +- find_multipaths yes ++ find_multipaths '"$FIND"' + ' $TMPFILE + CHANGED_CONFIG=1 +- elif [ "$HAVE_FIND" = 0 ]; then +- sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/ find_multipaths yes/' $TMPFILE ++ elif [ "$FIND" != "$HAVE_FIND" ]; then ++ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:blank:]]*find_multipaths[[:blank:]]*[^[:blank:]]*/ find_multipaths '"$FIND"'/' $TMPFILE + CHANGED_CONFIG=1 + fi + fi +diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8 +index b82961d6..83515eb4 100644 +--- a/multipath/mpathconf.8 ++++ b/multipath/mpathconf.8 +@@ -38,9 +38,9 @@ If + already exists, mpathconf will edit it. If it does not exist, mpathconf will + create a default file with + .B user_friendly_names +-and ++set and + .B find_multipaths +-set. To disable these, use the ++set to \fByes\fP. To disable these, use the + .B --user_friendly_names n + and + .B --find_multipaths n +@@ -77,13 +77,13 @@ to the + defaults section. If set to \fBn\fP, this removes the line, if present. This + command can be used along with any other command. + .TP +-.B --find_multipaths\fP { \fBy\fP | \fBn\fP } +-If set to \fBy\fP, this adds the line +-.B find_multipaths yes ++.B --find_multipaths\fP { \fByes\fP | \fBno\fP | \fBstrict\fP | \fBgreedy\fP | \fBsmart\fP } ++If set to \fB\fP, this adds the line ++.B find_multipaths + to the + .B /etc/multipath.conf +-defaults section. If set to \fBn\fP, this removes the line, if present. This +-command can be used along with any other command. ++defaults section. This command can be used along with any other command. ++\fBy\fP and \fBn\fP can be used instead of \fByes\fP and \fBno\fP. + .TP + .B --property_blacklist \fP { \fBy\fP | \fBn\fP } + If set to \fBy\fP, this adds the line +-- +2.17.2 + diff --git a/SPECS/device-mapper-multipath.spec b/SPECS/device-mapper-multipath.spec index 8f4feda..0876147 100644 --- a/SPECS/device-mapper-multipath.spec +++ b/SPECS/device-mapper-multipath.spec @@ -1,7 +1,7 @@ Summary: Tools to manage multipath devices using device-mapper Name: device-mapper-multipath Version: 0.8.4 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2 Group: System Environment/Base URL: http://christophe.varoqui.free.fr/ @@ -70,6 +70,8 @@ Patch00056: 0056-multipathd-use-get_monotonic_time-in-io_err_stat-cod.patch Patch00057: 0057-multipathd-combine-free_io_err_stat_path-and-destroy.patch Patch00058: 0058-multipathd-cleanup-logging-for-marginal-paths.patch Patch00059: 0059-libmpathpersist-fix-thread-safety-of-default-functio.patch +Patch00060: 0060-kpartx-free-loop-device-after-listing-partitions.patch +Patch00061: 0061-RH-fix-find_multipaths-in-mpathconf.patch # runtime Requires: %{name}-libs = %{version}-%{release} @@ -271,6 +273,13 @@ fi %{_pkgconfdir}/libdmmp.pc %changelog +* Wed Feb 10 2021 Benjamin Marzinski 0.8.4-9 +- Add 0060-kpartx-free-loop-device-after-listing-partitions.patch + * Fixes bz #1925490 +- Add 0061-RH-fix-find_multipaths-in-mpathconf.patch + * Fixes bz #1921651 +- Resolves: bz #1921651, #1925490 + * Wed Jan 27 2021 Benjamin Marzinski 0.8.4-7 - Add 0052-libmultipath-check-for-null-wwid-before-strcmp.patch * Missing part of fix for bz #1897815