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