|
|
8b67ad |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8b67ad |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
8b67ad |
Date: Tue, 31 Jan 2023 12:00:31 -0600
|
|
|
8b67ad |
Subject: [PATCH] libmultipath: keep renames from stopping other multipath
|
|
|
8b67ad |
actions
|
|
|
8b67ad |
|
|
|
8b67ad |
If select_action() is called and a multipath device needs to be renamed,
|
|
|
8b67ad |
the code currently checks if force_reload is set, and if so, does the
|
|
|
8b67ad |
reload after the rename. But if force_reload isn't set, only the rename
|
|
|
8b67ad |
happens, regardless of what other actions are needed. This can happen if
|
|
|
8b67ad |
multipathd starts up and a device needs both a reload and a rename.
|
|
|
8b67ad |
|
|
|
8b67ad |
Make multipath check for resize, reload, and switch pathgroup along with
|
|
|
8b67ad |
rename, and do both if necessary.
|
|
|
8b67ad |
|
|
|
8b67ad |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
8b67ad |
---
|
|
|
8b67ad |
libmultipath/configure.c | 92 +++++++++++++++++++++-------------------
|
|
|
8b67ad |
libmultipath/configure.h | 4 +-
|
|
|
8b67ad |
2 files changed, 51 insertions(+), 45 deletions(-)
|
|
|
8b67ad |
|
|
|
8b67ad |
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
|
|
|
8b67ad |
index 303d2380..65a0b208 100644
|
|
|
8b67ad |
--- a/libmultipath/configure.c
|
|
|
8b67ad |
+++ b/libmultipath/configure.c
|
|
|
8b67ad |
@@ -690,6 +690,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
struct multipath * cmpp_by_name;
|
|
|
8b67ad |
char * mpp_feat, * cmpp_feat;
|
|
|
8b67ad |
|
|
|
8b67ad |
+ mpp->action = ACT_NOTHING;
|
|
|
8b67ad |
cmpp = find_mp_by_wwid(curmp, mpp->wwid);
|
|
|
8b67ad |
cmpp_by_name = find_mp_by_alias(curmp, mpp->alias);
|
|
|
8b67ad |
|
|
|
8b67ad |
@@ -712,14 +713,8 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
strlcpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
|
|
|
8b67ad |
mpp->action = ACT_RENAME;
|
|
|
8b67ad |
- if (force_reload) {
|
|
|
8b67ad |
- mpp->force_udev_reload = 1;
|
|
|
8b67ad |
- mpp->action = ACT_FORCERENAME;
|
|
|
8b67ad |
- }
|
|
|
8b67ad |
- return;
|
|
|
8b67ad |
- }
|
|
|
8b67ad |
-
|
|
|
8b67ad |
- if (cmpp != cmpp_by_name) {
|
|
|
8b67ad |
+ /* don't return here. Check for other needed actions */
|
|
|
8b67ad |
+ } else if (cmpp != cmpp_by_name) {
|
|
|
8b67ad |
condlog(2, "%s: unable to rename %s to %s (%s is used by %s)",
|
|
|
8b67ad |
mpp->wwid, cmpp->alias, mpp->alias,
|
|
|
8b67ad |
mpp->alias, cmpp_by_name->wwid);
|
|
|
8b67ad |
@@ -727,12 +722,13 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
FREE(mpp->alias);
|
|
|
8b67ad |
mpp->alias = STRDUP(cmpp->alias);
|
|
|
8b67ad |
mpp->action = ACT_IMPOSSIBLE;
|
|
|
8b67ad |
- return;
|
|
|
8b67ad |
+ /* don't return here. Check for other needed actions */
|
|
|
8b67ad |
}
|
|
|
8b67ad |
|
|
|
8b67ad |
if (cmpp->size != mpp->size) {
|
|
|
8b67ad |
mpp->force_udev_reload = 1;
|
|
|
8b67ad |
- mpp->action = ACT_RESIZE;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RESIZE_RENAME :
|
|
|
8b67ad |
+ ACT_RESIZE;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RESIZE (size change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
@@ -740,7 +736,8 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
|
|
|
8b67ad |
if (force_reload) {
|
|
|
8b67ad |
mpp->force_udev_reload = 1;
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (forced by user)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
@@ -749,7 +746,8 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF &&
|
|
|
8b67ad |
!!strstr(mpp->features, "queue_if_no_path") !=
|
|
|
8b67ad |
!!strstr(cmpp->features, "queue_if_no_path")) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (no_path_retry change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
@@ -759,7 +757,8 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
(strlen(cmpp->hwhandler) != strlen(mpp->hwhandler) ||
|
|
|
8b67ad |
strncmp(cmpp->hwhandler, mpp->hwhandler,
|
|
|
8b67ad |
strlen(mpp->hwhandler)))) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (hwhandler change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
@@ -769,7 +768,8 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
!!strstr(mpp->features, "retain_attached_hw_handler") !=
|
|
|
8b67ad |
!!strstr(cmpp->features, "retain_attached_hw_handler") &&
|
|
|
8b67ad |
get_linux_version_code() < KERNEL_VERSION(4, 3, 0)) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (retain_hwhandler change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
@@ -783,9 +783,13 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
remove_feature(&cmpp_feat, "queue_if_no_path");
|
|
|
8b67ad |
remove_feature(&cmpp_feat, "retain_attached_hw_handler");
|
|
|
8b67ad |
if (strncmp(mpp_feat, cmpp_feat, PARAMS_SIZE)) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ?
|
|
|
8b67ad |
+ ACT_RELOAD_RENAME : ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (features change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
+ FREE(cmpp_feat);
|
|
|
8b67ad |
+ FREE(mpp_feat);
|
|
|
8b67ad |
+ return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
}
|
|
|
8b67ad |
FREE(cmpp_feat);
|
|
|
8b67ad |
@@ -793,44 +797,49 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
|
|
|
8b67ad |
|
|
|
8b67ad |
if (!cmpp->selector || strncmp(cmpp->selector, mpp->selector,
|
|
|
8b67ad |
strlen(mpp->selector))) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (selector change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
if (cmpp->minio != mpp->minio) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (minio change, %u->%u)",
|
|
|
8b67ad |
mpp->alias, cmpp->minio, mpp->minio);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
if (!cmpp->pg || VECTOR_SIZE(cmpp->pg) != VECTOR_SIZE(mpp->pg)) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (path group number change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
if (pgcmp(mpp, cmpp)) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_RELOAD_RENAME :
|
|
|
8b67ad |
+ ACT_RELOAD;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (path group topology change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
if (cmpp->nextpg != mpp->bestpg) {
|
|
|
8b67ad |
- mpp->action = ACT_SWITCHPG;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_SWITCHPG_RENAME :
|
|
|
8b67ad |
+ ACT_SWITCHPG;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_SWITCHPG (next path group change)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
if (!is_mpp_known_to_udev(cmpp)) {
|
|
|
8b67ad |
- mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
+ mpp->action = mpp->action == ACT_RENAME ? ACT_SWITCHPG_RENAME :
|
|
|
8b67ad |
+ ACT_SWITCHPG;
|
|
|
8b67ad |
condlog(3, "%s: set ACT_RELOAD (udev device not initialized)",
|
|
|
8b67ad |
mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
- mpp->action = ACT_NOTHING;
|
|
|
8b67ad |
- condlog(3, "%s: set ACT_NOTHING (map unchanged)",
|
|
|
8b67ad |
- mpp->alias);
|
|
|
8b67ad |
+ if (mpp->action == ACT_NOTHING)
|
|
|
8b67ad |
+ condlog(3, "%s: set ACT_NOTHING (map unchanged)", mpp->alias);
|
|
|
8b67ad |
return;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
|
|
|
8b67ad |
@@ -924,6 +933,17 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
|
|
|
8b67ad |
mpp->action = ACT_RELOAD;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
|
|
|
8b67ad |
+ if (mpp->action == ACT_RENAME || mpp->action == ACT_SWITCHPG_RENAME ||
|
|
|
8b67ad |
+ mpp->action == ACT_RELOAD_RENAME ||
|
|
|
8b67ad |
+ mpp->action == ACT_RESIZE_RENAME) {
|
|
|
8b67ad |
+ conf = get_multipath_config();
|
|
|
8b67ad |
+ pthread_cleanup_push(put_multipath_config, conf);
|
|
|
8b67ad |
+ r = dm_rename(mpp->alias_old, mpp->alias,
|
|
|
8b67ad |
+ conf->partition_delim, mpp->skip_kpartx);
|
|
|
8b67ad |
+ pthread_cleanup_pop(1);
|
|
|
8b67ad |
+ if (r == DOMAP_FAIL)
|
|
|
8b67ad |
+ return r;
|
|
|
8b67ad |
+ }
|
|
|
8b67ad |
switch (mpp->action) {
|
|
|
8b67ad |
case ACT_REJECT:
|
|
|
8b67ad |
case ACT_NOTHING:
|
|
|
8b67ad |
@@ -931,6 +951,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
|
|
|
8b67ad |
return DOMAP_EXIST;
|
|
|
8b67ad |
|
|
|
8b67ad |
case ACT_SWITCHPG:
|
|
|
8b67ad |
+ case ACT_SWITCHPG_RENAME:
|
|
|
8b67ad |
dm_switchgroup(mpp->alias, mpp->bestpg);
|
|
|
8b67ad |
/*
|
|
|
8b67ad |
* we may have avoided reinstating paths because there where in
|
|
|
8b67ad |
@@ -957,6 +978,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
|
|
|
8b67ad |
break;
|
|
|
8b67ad |
|
|
|
8b67ad |
case ACT_RELOAD:
|
|
|
8b67ad |
+ case ACT_RELOAD_RENAME:
|
|
|
8b67ad |
sysfs_set_max_sectors_kb(mpp, 1);
|
|
|
8b67ad |
if (mpp->ghost_delay_tick > 0 && pathcount(mpp, PATH_UP))
|
|
|
8b67ad |
mpp->ghost_delay_tick = 0;
|
|
|
8b67ad |
@@ -964,6 +986,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
|
|
|
8b67ad |
break;
|
|
|
8b67ad |
|
|
|
8b67ad |
case ACT_RESIZE:
|
|
|
8b67ad |
+ case ACT_RESIZE_RENAME:
|
|
|
8b67ad |
sysfs_set_max_sectors_kb(mpp, 1);
|
|
|
8b67ad |
if (mpp->ghost_delay_tick > 0 && pathcount(mpp, PATH_UP))
|
|
|
8b67ad |
mpp->ghost_delay_tick = 0;
|
|
|
8b67ad |
@@ -971,29 +994,10 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
|
|
|
8b67ad |
break;
|
|
|
8b67ad |
|
|
|
8b67ad |
case ACT_RENAME:
|
|
|
8b67ad |
- conf = get_multipath_config();
|
|
|
8b67ad |
- pthread_cleanup_push(put_multipath_config, conf);
|
|
|
8b67ad |
- r = dm_rename(mpp->alias_old, mpp->alias,
|
|
|
8b67ad |
- conf->partition_delim, mpp->skip_kpartx);
|
|
|
8b67ad |
- pthread_cleanup_pop(1);
|
|
|
8b67ad |
- break;
|
|
|
8b67ad |
-
|
|
|
8b67ad |
- case ACT_FORCERENAME:
|
|
|
8b67ad |
- conf = get_multipath_config();
|
|
|
8b67ad |
- pthread_cleanup_push(put_multipath_config, conf);
|
|
|
8b67ad |
- r = dm_rename(mpp->alias_old, mpp->alias,
|
|
|
8b67ad |
- conf->partition_delim, mpp->skip_kpartx);
|
|
|
8b67ad |
- pthread_cleanup_pop(1);
|
|
|
8b67ad |
- if (r) {
|
|
|
8b67ad |
- sysfs_set_max_sectors_kb(mpp, 1);
|
|
|
8b67ad |
- if (mpp->ghost_delay_tick > 0 &&
|
|
|
8b67ad |
- pathcount(mpp, PATH_UP))
|
|
|
8b67ad |
- mpp->ghost_delay_tick = 0;
|
|
|
8b67ad |
- r = dm_addmap_reload(mpp, params, 0);
|
|
|
8b67ad |
- }
|
|
|
8b67ad |
break;
|
|
|
8b67ad |
|
|
|
8b67ad |
default:
|
|
|
8b67ad |
+ r = DOMAP_FAIL;
|
|
|
8b67ad |
break;
|
|
|
8b67ad |
}
|
|
|
8b67ad |
|
|
|
8b67ad |
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
|
|
|
8b67ad |
index 5cf08d45..1a93f49d 100644
|
|
|
8b67ad |
--- a/libmultipath/configure.h
|
|
|
8b67ad |
+++ b/libmultipath/configure.h
|
|
|
8b67ad |
@@ -18,9 +18,11 @@ enum actions {
|
|
|
8b67ad |
ACT_RENAME,
|
|
|
8b67ad |
ACT_CREATE,
|
|
|
8b67ad |
ACT_RESIZE,
|
|
|
8b67ad |
- ACT_FORCERENAME,
|
|
|
8b67ad |
+ ACT_RELOAD_RENAME,
|
|
|
8b67ad |
ACT_DRY_RUN,
|
|
|
8b67ad |
ACT_IMPOSSIBLE,
|
|
|
8b67ad |
+ ACT_RESIZE_RENAME,
|
|
|
8b67ad |
+ ACT_SWITCHPG_RENAME,
|
|
|
8b67ad |
};
|
|
|
8b67ad |
|
|
|
8b67ad |
/*
|