|
|
c90e5b |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
c90e5b |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
c90e5b |
Date: Wed, 30 Mar 2022 15:14:56 -0500
|
|
|
c90e5b |
Subject: [PATCH] multipath: return failure on an invalid remove command
|
|
|
c90e5b |
|
|
|
c90e5b |
When "multipath -f" is run on a device that doesn't exist or isn't a
|
|
|
c90e5b |
multipath device, the command will not remove any device, but it will
|
|
|
c90e5b |
still return success. Multiple functions rely on _dm_flush_map()
|
|
|
c90e5b |
returning success when called with name that doesn't match any
|
|
|
c90e5b |
multipath device. So before calling _dm_flush_map(), call dm_is_mpath(),
|
|
|
c90e5b |
to check if the device exists and is a multipath device, and return
|
|
|
c90e5b |
failure if it's not.
|
|
|
c90e5b |
|
|
|
c90e5b |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
c90e5b |
Reviewed-by: Martin Wilck
|
|
|
c90e5b |
---
|
|
|
c90e5b |
multipath/main.c | 5 +++++
|
|
|
c90e5b |
1 file changed, 5 insertions(+)
|
|
|
c90e5b |
|
|
|
c90e5b |
diff --git a/multipath/main.c b/multipath/main.c
|
|
|
c90e5b |
index 14d045c9..d5e6499c 100644
|
|
|
c90e5b |
--- a/multipath/main.c
|
|
|
c90e5b |
+++ b/multipath/main.c
|
|
|
c90e5b |
@@ -1150,6 +1150,11 @@ main (int argc, char *argv[])
|
|
|
c90e5b |
if (retries < 0)
|
|
|
c90e5b |
retries = conf->remove_retries;
|
|
|
c90e5b |
if (cmd == CMD_FLUSH_ONE) {
|
|
|
c90e5b |
+ if (dm_is_mpath(dev) != 1) {
|
|
|
c90e5b |
+ condlog(0, "%s is not a multipath device", dev);
|
|
|
c90e5b |
+ r = RTVL_FAIL;
|
|
|
c90e5b |
+ goto out;
|
|
|
c90e5b |
+ }
|
|
|
c90e5b |
r = dm_suspend_and_flush_map(dev, retries) ?
|
|
|
c90e5b |
RTVL_FAIL : RTVL_OK;
|
|
|
c90e5b |
goto out;
|