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