mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-04 09:18:36 +03:00
refactor: toolcontext: add struct cmd_context_initialized_parts
Add struct cmd_context_initialized_parts to wrap up information about which cmd context pieces are initialized and add variable of this struct type into struct cmd_context. Also, move existing "config_initialized" variable that was directly part of cmd_context into the new cmd_context.initialized wrapper. We'll be adding more items into the struct cmd_context_initialized_parts with subsequent patches...
This commit is contained in:
parent
9aabf441bd
commit
6b0c464a34
@ -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",
|
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());
|
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 */
|
/* Reinitialise various settings inc. logging, filters */
|
||||||
if (do_refresh_cache()) {
|
if (do_refresh_cache()) {
|
||||||
log_error("Updated config file invalid. Aborting.");
|
log_error("Updated config file invalid. Aborting.");
|
||||||
|
@ -1851,9 +1851,9 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
|
|||||||
cmd->default_settings.cache_vgmetadata = 1;
|
cmd->default_settings.cache_vgmetadata = 1;
|
||||||
cmd->current_settings = cmd->default_settings;
|
cmd->current_settings = cmd->default_settings;
|
||||||
|
|
||||||
cmd->config_initialized = 1;
|
cmd->initialized.config = 1;
|
||||||
out:
|
out:
|
||||||
if (!cmd->config_initialized) {
|
if (!cmd->initialized.config) {
|
||||||
destroy_toolcontext(cmd);
|
destroy_toolcontext(cmd);
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
}
|
}
|
||||||
@ -1979,7 +1979,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
|||||||
|
|
||||||
_destroy_config(cmd);
|
_destroy_config(cmd);
|
||||||
|
|
||||||
cmd->config_initialized = 0;
|
cmd->initialized.config = 0;
|
||||||
|
|
||||||
cmd->hosttags = 0;
|
cmd->hosttags = 0;
|
||||||
|
|
||||||
@ -2057,7 +2057,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
|||||||
if (!_init_backup(cmd))
|
if (!_init_backup(cmd))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
cmd->config_initialized = 1;
|
cmd->initialized.config = 1;
|
||||||
|
|
||||||
reset_lvm_errno(1);
|
reset_lvm_errno(1);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -60,6 +60,10 @@ struct config_tree_list {
|
|||||||
struct dm_config_tree *cft;
|
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 */
|
/* FIXME Split into tool & library contexts */
|
||||||
/* command-instance-related variables needed by library */
|
/* command-instance-related variables needed by library */
|
||||||
struct cmd_context {
|
struct cmd_context {
|
||||||
@ -82,6 +86,9 @@ struct cmd_context {
|
|||||||
char **argv;
|
char **argv;
|
||||||
struct arg_values *arg_values;
|
struct arg_values *arg_values;
|
||||||
struct dm_list arg_value_groups;
|
struct dm_list arg_value_groups;
|
||||||
|
|
||||||
|
struct cmd_context_initialized_parts initialized;
|
||||||
|
|
||||||
unsigned is_long_lived:1; /* Optimises persistent_filter handling */
|
unsigned is_long_lived:1; /* Optimises persistent_filter handling */
|
||||||
unsigned handles_missing_pvs:1;
|
unsigned handles_missing_pvs:1;
|
||||||
unsigned handles_unknown_segments: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 dm_list config_files; /* master lvm config + any existing tag configs */
|
||||||
struct profile_params *profile_params; /* profile handling params including loaded profile 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 */
|
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) */
|
struct dm_hash_table *cft_def_hash; /* config definition hash used for validity check (item type + item recognized) */
|
||||||
|
|
||||||
|
@ -1541,7 +1541,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
goto_out;
|
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 */
|
/* Reinitialise various settings inc. logging, filters */
|
||||||
if (!refresh_toolcontext(cmd)) {
|
if (!refresh_toolcontext(cmd)) {
|
||||||
if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING)))
|
if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING)))
|
||||||
|
Loading…
Reference in New Issue
Block a user