From b68fc8b7d9312d204b04cf1af290f50dd6a425fa Mon Sep 17 00:00:00 2001 From: xueyamao Date: Wed, 31 Aug 2022 15:55:28 +0800 Subject: [PATCH] fix multipath return failure on an invalid remove command When "multipath -f" is run on a device that doesn't exist or isn't a multipath device, the command will not remove any device, but it will still return success. Signed-off-by: xueyamao --- ...urn-failure-on-an-invalid-remove-cmd.patch | 37 +++++++++++++++++++ multipath-tools.spec | 6 ++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 0016-multipath-return-failure-on-an-invalid-remove-cmd.patch diff --git a/0016-multipath-return-failure-on-an-invalid-remove-cmd.patch b/0016-multipath-return-failure-on-an-invalid-remove-cmd.patch new file mode 100644 index 0000000..6ad85a5 --- /dev/null +++ b/0016-multipath-return-failure-on-an-invalid-remove-cmd.patch @@ -0,0 +1,37 @@ +From a7c13c340eb76c1b20580663e7ea2ad99b37022f Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 30 Mar 2022 15:14:56 -0500 +Subject: [PATCH] multipath: return failure on an invalid remove command + +When "multipath -f" is run on a device that doesn't exist or isn't a +multipath device, the command will not remove any device, but it will +still return success. Multiple functions rely on _dm_flush_map() +returning success when called with name that doesn't match any +multipath device. So before calling _dm_flush_map(), call dm_is_mpath(), +to check if the device exists and is a multipath device, and return +failure if it's not. + +Signed-off-by: Benjamin Marzinski +--- + multipath/main.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/multipath/main.c b/multipath/main.c +index 65ece83..743f3e0 100644 +--- a/multipath/main.c ++++ b/multipath/main.c +@@ -1060,6 +1060,11 @@ main (int argc, char *argv[]) + if (retries < 0) + retries = conf->remove_retries; + if (cmd == CMD_FLUSH_ONE) { ++ if (dm_is_mpath(dev) != 1) { ++ condlog(0, "%s is not a multipath device", dev); ++ r = RTVL_FAIL; ++ goto out; ++ } + r = dm_suspend_and_flush_map(dev, retries) ? + RTVL_FAIL : RTVL_OK; + goto out; +-- +2.33.0 + diff --git a/multipath-tools.spec b/multipath-tools.spec index 0652f30..7cc0e4b 100644 --- a/multipath-tools.spec +++ b/multipath-tools.spec @@ -1,7 +1,7 @@ #needsrootforbuild Name: multipath-tools Version: 0.8.7 -Release: 2 +Release: 3 Summary: Tools to manage multipath devices with the device-mapper License: GPL-2.0-or-later and LGPL-2.0-only URL: http://christophe.varoqui.free.fr/ @@ -24,6 +24,7 @@ Patch12: 0012-device-mapper-multipath-fix-find-multipath-failure.patch Patch13: 0013-kpartx-change-kpartx-file-and-default-bindir.patch Patch14: 0014-remove-local-disk-from-pathvec.patch Patch15: 0015-clear-mpp-path-reference-when-path-is-freed-otherwis.patch +Patch16: 0016-multipath-return-failure-on-an-invalid-remove-cmd.patch BuildRequires: multipath-tools, libcmocka, libcmocka-devel BuildRequires: gcc, libaio-devel, userspace-rcu-devel, device-mapper-devel >= 1.02.89 @@ -170,6 +171,9 @@ fi %changelog +* Wed Aug 31 2022 xueyamao - 0.8.7-3 +- fix multipath return failure on an invalid remove command + * Tue Mar 8 2022 lixiaokeng - 0.8.7-2 - don't create nvme multipath device when enable remove_local_path -- Gitee