!199 multipath: return failure on an invalid remove command

From: @kouwq 
Reviewed-by: @swf504 
Signed-off-by: @swf504
This commit is contained in:
openeuler-ci-bot 2024-08-08 01:09:30 +00:00 committed by Gitee
commit 35ad6d85c1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 774b5ad984a9c4f1d8d869d804ad1dc35dab7d8b Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
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 <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com
---
multipath/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/multipath/main.c b/multipath/main.c
index f52430f..008de0b 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -1088,6 +1088,11 @@ main (int argc, char *argv[])
retries = conf->remove_retries;
if (conf->remove == FLUSH_ONE) {
if (dev_type == DEV_DEVMAP) {
+ 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;
} else
--
2.27.0

View File

@ -2,7 +2,7 @@
Name: multipath-tools
Version: 0.8.4
Release: 26
Release: 27
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/
@ -60,6 +60,7 @@ Patch47: 0047-libmultipath-sysfs_set_scsi_tmo-do-nothing-for-ACT_D.patch
Patch48: 0048-multipath.conf.5-fix-documentation-for-find_multipat.patch
Patch49: 0049-multipath.conf.5-fix-the-description-of-prio_args-fo.patch
Patch50: 0050-multipath-display-the-correct-configuration-when-dum.patch
Patch51: 0051-multipath-return-failure-on-an-invalid-remove-comman.patch
BuildRequires: multipath-tools, libcmocka, libcmocka-devel
BuildRequires: gcc, libaio-devel, userspace-rcu-devel, device-mapper-devel >= 1.02.89
@ -207,6 +208,9 @@ fi
%changelog
* Wed Aug 7 2024 kouwenqi <kouwenqi@kylinos.cn> - 0.8.4-27
- multipath: return failure on an invalid remove command
* Mon Aug 5 2024 kouwenqi <kouwenqi@kylinos.cn> - 0.8.4-26
- multipath: display the correct configuration when dumpping config