diff mbox series

[3/4] libmultipath: cleanup ACT_CREATE code in select_action

Message ID 1675193661-1147-4-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath: fix multipathd renaming issue | expand

Commit Message

Benjamin Marzinski Jan. 31, 2023, 7:34 p.m. UTC
Combine the two separate blocks that set ACT_CREATE into one.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/configure.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

Comments

Martin Wilck Feb. 1, 2023, 8 a.m. UTC | #1
On Tue, 2023-01-31 at 13:34 -0600, Benjamin Marzinski wrote:
> Combine the two separate blocks that set ACT_CREATE into one.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>

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

> ---
>  libmultipath/configure.c | 38 +++++++++++++++++---------------------
>  1 file changed, 17 insertions(+), 21 deletions(-)
> 
> diff --git a/libmultipath/configure.c b/libmultipath/configure.c
> index 6811e661..e870e0f6 100644
> --- a/libmultipath/configure.c
> +++ b/libmultipath/configure.c
> @@ -686,33 +686,29 @@ void select_action (struct multipath *mpp,
> const struct _vector *curmp,
>         if (mpp->need_reload || (cmpp && cmpp->need_reload))
>                 force_reload = 1;
>  
> -       if (!cmpp_by_name) {
> -               if (cmpp) {
> -                       condlog(2, "%s: rename %s to %s", mpp->wwid,
> -                               cmpp->alias, mpp->alias);
> -                       strlcpy(mpp->alias_old, cmpp->alias,
> WWID_SIZE);
> -                       mpp->action = ACT_RENAME;
> -                       if (force_reload) {
> -                               mpp->force_udev_reload = 1;
> -                               mpp->action = ACT_FORCERENAME;
> -                       }
> -                       return;
> +       if (!cmpp) {
> +               if (cmpp_by_name) {
> +                       condlog(1, "%s: can't use alias \"%s\" used
> by %s, falling back to WWID",
> +                               mpp->wwid, mpp->alias, cmpp_by_name-
> >wwid);
> +                       /* We can do this because wwid wasn't found
> */
> +                       free(mpp->alias);
> +                       mpp->alias = strdup(mpp->wwid);
>                 }
>                 mpp->action = ACT_CREATE;
> -               condlog(3, "%s: set ACT_CREATE (map does not exist)",
> -                       mpp->alias);
> +               condlog(3, "%s: set ACT_CREATE (map does not
> exist%s)",
> +                       mpp->alias, cmpp_by_name ? ", name changed" :
> "");
>                 return;
>         }
>  
> -       if (!cmpp) {
> -               condlog(1, "%s: can't use alias \"%s\" used by %s,
> falling back to WWID",
> -                       mpp->wwid, mpp->alias, cmpp_by_name->wwid);
> -               /* We can do this because wwid wasn't found */
> -               free(mpp->alias);
> -               mpp->alias = strdup(mpp->wwid);
> -               mpp->action = ACT_CREATE;
> -               condlog(3, "%s: set ACT_CREATE (map does not exist,
> name changed)",
> +       if (!cmpp_by_name) {
> +               condlog(2, "%s: rename %s to %s", mpp->wwid, cmpp-
> >alias,
>                         mpp->alias);
> +               strlcpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
> +               mpp->action = ACT_RENAME;
> +               if (force_reload) {
> +                       mpp->force_udev_reload = 1;
> +                       mpp->action = ACT_FORCERENAME;
> +               }
>                 return;
>         }
>  



--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 6811e661..e870e0f6 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -686,33 +686,29 @@  void select_action (struct multipath *mpp, const struct _vector *curmp,
 	if (mpp->need_reload || (cmpp && cmpp->need_reload))
 		force_reload = 1;
 
-	if (!cmpp_by_name) {
-		if (cmpp) {
-			condlog(2, "%s: rename %s to %s", mpp->wwid,
-				cmpp->alias, mpp->alias);
-			strlcpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
-			mpp->action = ACT_RENAME;
-			if (force_reload) {
-				mpp->force_udev_reload = 1;
-				mpp->action = ACT_FORCERENAME;
-			}
-			return;
+	if (!cmpp) {
+		if (cmpp_by_name) {
+			condlog(1, "%s: can't use alias \"%s\" used by %s, falling back to WWID",
+				mpp->wwid, mpp->alias, cmpp_by_name->wwid);
+			/* We can do this because wwid wasn't found */
+			free(mpp->alias);
+			mpp->alias = strdup(mpp->wwid);
 		}
 		mpp->action = ACT_CREATE;
-		condlog(3, "%s: set ACT_CREATE (map does not exist)",
-			mpp->alias);
+		condlog(3, "%s: set ACT_CREATE (map does not exist%s)",
+			mpp->alias, cmpp_by_name ? ", name changed" : "");
 		return;
 	}
 
-	if (!cmpp) {
-		condlog(1, "%s: can't use alias \"%s\" used by %s, falling back to WWID",
-			mpp->wwid, mpp->alias, cmpp_by_name->wwid);
-		/* We can do this because wwid wasn't found */
-		free(mpp->alias);
-		mpp->alias = strdup(mpp->wwid);
-		mpp->action = ACT_CREATE;
-		condlog(3, "%s: set ACT_CREATE (map does not exist, name changed)",
+	if (!cmpp_by_name) {
+		condlog(2, "%s: rename %s to %s", mpp->wwid, cmpp->alias,
 			mpp->alias);
+		strlcpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
+		mpp->action = ACT_RENAME;
+		if (force_reload) {
+			mpp->force_udev_reload = 1;
+			mpp->action = ACT_FORCERENAME;
+		}
 		return;
 	}