[dm-devel] [PATCH v2] multipath: return failure on an invalid remove command
Benjamin Marzinski
bmarzins at redhat.com
Wed Mar 30 20:14:56 UTC 2022
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 at redhat.com>
---
changes since v1:
- more meaningful error message. Suggested by mwilck
multipath/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/multipath/main.c b/multipath/main.c
index d09f62db..01eba9ae 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.17.2
More information about the dm-devel
mailing list