diff mbox series

[4/7] multipathd: move post-reloading commands into resize_map()

Message ID 20231102221507.105371-5-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series Two multipath features. | expand

Commit Message

Benjamin Marzinski Nov. 2, 2023, 10:15 p.m. UTC
In preparation for reusing resize_map() in other code, move all code
necessary to resize the map to the resize_map() function. Also track if
map was removed in the function.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 multipathd/cli_handlers.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Martin Wilck Nov. 8, 2023, 5:58 p.m. UTC | #1
On Thu, 2023-11-02 at 18:15 -0400, Benjamin Marzinski wrote:
> In preparation for reusing resize_map() in other code, move all code
> necessary to resize the map to the resize_map() function. Also track
> if
> map was removed in the function.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>

Reviewed-by: Martin Wilck <mwilck@suse.com>
diff mbox series

Patch

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index ffea193d..8eb19fdf 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -835,6 +835,10 @@  static int resize_map(struct multipath *mpp, unsigned long long size,
 		mpp->size = orig_size;
 		return 1;
 	}
+	if (setup_multipath(vecs, mpp) != 0)
+		return 2;
+	sync_map_state(mpp);
+
 	return 0;
 }
 
@@ -848,7 +852,7 @@  cli_resize(void *v, struct strbuf *reply, void *data)
 	unsigned long long size = 0;
 	struct pathgroup *pgp;
 	struct path *pp;
-	unsigned int i, j;
+	unsigned int i, j, ret;
 	bool mismatch = false;
 
 	mapname = convert_dev(mapname, 0);
@@ -897,14 +901,12 @@  cli_resize(void *v, struct strbuf *reply, void *data)
 	condlog(3, "%s old size is %llu, new size is %llu", mapname, mpp->size,
 		size);
 
-	if (resize_map(mpp, size, vecs) != 0)
-		return 1;
+	ret = resize_map(mpp, size, vecs);
 
-	if (setup_multipath(vecs, mpp) != 0)
-		return 1;
-	sync_map_state(mpp);
+	if (ret == 2)
+		condlog(0, "%s: map removed while trying to resize", mapname);
 
-	return 0;
+	return (ret != 0);
 }
 
 static int