summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-07-27 16:56:20 -0500
committerDavid Teigland <teigland@redhat.com>2021-08-05 13:20:26 -0500
commit87714a1384def2ea107d7dbc264eff44c2025865 (patch)
treefabbe5d370ba2cc27b4f595883b14ff53f65fb21
parentd3d6a0e820ff930a5a7c137e7bbeb0225e251df7 (diff)
downloadlvm2-87714a1384def2ea107d7dbc264eff44c2025865.tar.gz
devices file: avoid updating entry dev names in some cases
Avoid thrashing changes to devices file device names by some commands that are run during startup when devnames are still being set up.
-rw-r--r--lib/commands/toolcontext.h1
-rw-r--r--lib/device/device_id.c9
-rw-r--r--tools/lvchange.c3
-rw-r--r--tools/pvscan.c2
-rw-r--r--tools/vgchange.c3
5 files changed, 18 insertions, 0 deletions
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 4dbc75cfc..0911b05f1 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -194,6 +194,7 @@ struct cmd_context {
unsigned sysinit:1; /* --sysinit is used */
unsigned check_devs_used:1; /* check devs used by LVs */
unsigned print_device_id_not_found; /* print devices file entries not found */
+ unsigned ignore_device_name_mismatch; /* skip updating devices file names */
/*
* Devices and filtering.
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 6ac646a16..6f61cf3f1 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1639,6 +1639,15 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
}
}
+ /*
+ * Avoid thrashing changes to the devices file during
+ * startup due to device names that are still being
+ * established. Commands that may run during startup
+ * should set this flag.
+ */
+ if (cmd->ignore_device_name_mismatch)
+ continue;
+
if (!du->devname || strcmp(dev_name(du->dev), du->devname)) {
log_warn("Device %s has updated name (devices file %s)",
dev_name(du->dev), du->devname ?: "none");
diff --git a/tools/lvchange.c b/tools/lvchange.c
index bfd464d5c..d4c40df47 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1535,6 +1535,7 @@ int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
cmd->lockd_vg_default_sh = 1;
+ cmd->ignore_device_name_mismatch = 1;
/*
* Include foreign VGs that contain active LVs.
@@ -1619,6 +1620,7 @@ int lvchange_refresh_cmd(struct cmd_context *cmd, int argc, char **argv)
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
cmd->lockd_vg_default_sh = 1;
+ cmd->ignore_device_name_mismatch = 1;
return process_each_lv(cmd, argc, argv, NULL, NULL, 0,
NULL, &_lvchange_refresh_check, &_lvchange_refresh_single);
@@ -1792,6 +1794,7 @@ int lvchange_monitor_poll_cmd(struct cmd_context *cmd, int argc, char **argv)
{
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
+ cmd->ignore_device_name_mismatch = 1;
return process_each_lv(cmd, argc, argv, NULL, NULL, 0,
NULL, &_lvchange_monitor_poll_check, &_lvchange_monitor_poll_single);
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 46d0786bc..1c84b8407 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1622,6 +1622,8 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
cmd->print_device_id_not_found = 0;
+ cmd->ignore_device_name_mismatch = 1;
+
event_activation = find_config_tree_bool(cmd, global_event_activation_CFG, NULL);
if (do_activate && !event_activation) {
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 22038ba9b..d2d5f9dd2 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -799,6 +799,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
if (!update || !update_partial_unsafe)
cmd->handles_missing_pvs = 1;
+ if (noupdate)
+ cmd->ignore_device_name_mismatch = 1;
+
/*
* Include foreign VGs that contain active LVs.
* That shouldn't happen in general, but if it does by some