diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index dafffcc40..e7dbfde69 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -510,7 +510,7 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource) DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s, critical_section = %d\n", resource, decode_locking_cmd(command), decode_flags(lock_flags), critical_section()); - if (!cmd->config_initialized || config_files_changed(cmd)) { + if (!cmd->initialized.config || config_files_changed(cmd)) { /* Reinitialise various settings inc. logging, filters */ if (do_refresh_cache()) { log_error("Updated config file invalid. Aborting."); diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 3fe2bb2ec..da0ca221b 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -1851,9 +1851,9 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived, cmd->default_settings.cache_vgmetadata = 1; cmd->current_settings = cmd->default_settings; - cmd->config_initialized = 1; + cmd->initialized.config = 1; out: - if (!cmd->config_initialized) { + if (!cmd->initialized.config) { destroy_toolcontext(cmd); cmd = NULL; } @@ -1979,7 +1979,7 @@ int refresh_toolcontext(struct cmd_context *cmd) _destroy_config(cmd); - cmd->config_initialized = 0; + cmd->initialized.config = 0; cmd->hosttags = 0; @@ -2057,7 +2057,7 @@ int refresh_toolcontext(struct cmd_context *cmd) if (!_init_backup(cmd)) return_0; - cmd->config_initialized = 1; + cmd->initialized.config = 1; reset_lvm_errno(1); return 1; diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h index 4e8998dc6..c59024b3b 100644 --- a/lib/commands/toolcontext.h +++ b/lib/commands/toolcontext.h @@ -60,6 +60,10 @@ struct config_tree_list { struct dm_config_tree *cft; }; +struct cmd_context_initialized_parts { + unsigned config:1; /* used to reinitialize config if previous init was not successful */ +}; + /* FIXME Split into tool & library contexts */ /* command-instance-related variables needed by library */ struct cmd_context { @@ -82,6 +86,9 @@ struct cmd_context { char **argv; struct arg_values *arg_values; struct dm_list arg_value_groups; + + struct cmd_context_initialized_parts initialized; + unsigned is_long_lived:1; /* Optimises persistent_filter handling */ unsigned handles_missing_pvs:1; unsigned handles_unknown_segments:1; @@ -132,7 +139,6 @@ struct cmd_context { struct dm_list config_files; /* master lvm config + any existing tag configs */ struct profile_params *profile_params; /* profile handling params including loaded profile configs */ struct dm_config_tree *cft; /* the whole cascade: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_FILE/CONFIG_MERGED_FILES */ - int config_initialized; /* used to reinitialize config if previous init was not successful */ struct dm_hash_table *cft_def_hash; /* config definition hash used for validity check (item type + item recognized) */ diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 9e0d0299d..98a2c3070 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -1541,7 +1541,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) goto_out; } - if (arg_count(cmd, config_ARG) || !cmd->config_initialized || config_files_changed(cmd)) { + if (arg_count(cmd, config_ARG) || !cmd->initialized.config || config_files_changed(cmd)) { /* Reinitialise various settings inc. logging, filters */ if (!refresh_toolcontext(cmd)) { if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING)))