mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-24 14:50:34 +03:00
config: introduce validate_metadata
Add lvm.conf config/validate_metadata configurable setting. Allows to disable validation of volume_group structure before writing to disk. Call of vg_validate() is supposed to catch any inconsistency of in-memory volume group structure and possibly early aborting commnand before making any more 'damage' in case the VG struct is found insistent after some metadata manipulation. This is almost always useful for devel - and also for normal user as for small metadata size this doesn't add too much overhead. However if the volume_group size is large and operations are just adding removing simple LVs - this validation time may add noticable to final command running time. So if the user seeks the highest perfomance of command and does not do any 'complex' metadata manipulation - it's reasonably safe to disable validation (with the use of setting "none") here.
This commit is contained in:
parent
7bf404db3b
commit
0e5beb92c5
@ -36,6 +36,19 @@ config {
|
||||
# This configuration option has an automatic default value.
|
||||
# checks = 1
|
||||
|
||||
# Configuration option config/validate_metadata.
|
||||
# Allows to select the level of validation after metadata transformation.
|
||||
# Validation takes extra CPU time to verify internal consistency.
|
||||
# Accepted values:
|
||||
# full
|
||||
# Do a full metadata validation before disk write.
|
||||
# none
|
||||
# Skip any checks (unrecommended, slightly faster).
|
||||
#
|
||||
# This configuration option is advanced.
|
||||
# This configuration option has an automatic default value.
|
||||
# validate_metadata = "full"
|
||||
|
||||
# Configuration option config/abort_on_errors.
|
||||
# Abort the LVM process if a configuration mismatch is found.
|
||||
# This configuration option has an automatic default value.
|
||||
|
@ -658,7 +658,7 @@ static int _process_config(struct cmd_context *cmd)
|
||||
{
|
||||
mode_t old_umask;
|
||||
const char *dev_ext_info_src = NULL;
|
||||
const char *read_ahead;
|
||||
const char *read_ahead, *validate_metadata;
|
||||
struct stat st;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
@ -744,6 +744,15 @@ static int _process_config(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmd->vg_write_validates_vg = 1;
|
||||
if ((validate_metadata = find_config_tree_str(cmd, config_validate_metadata_CFG, NULL))) {
|
||||
if (!strcasecmp(validate_metadata, "none"))
|
||||
cmd->vg_write_validates_vg = 0;
|
||||
else if (strcasecmp(validate_metadata, "full"))
|
||||
log_warn("WARNING: Ignoring unknown validate_metadata setting: %s.",
|
||||
validate_metadata);
|
||||
}
|
||||
|
||||
/*
|
||||
* If udev is disabled using DM_DISABLE_UDEV environment
|
||||
* variable, override existing config and hardcode these:
|
||||
|
@ -218,6 +218,7 @@ struct cmd_context {
|
||||
unsigned device_ids_invalid:1;
|
||||
unsigned device_ids_auto_import:1;
|
||||
unsigned get_vgname_from_options:1; /* used by lvconvert */
|
||||
unsigned vg_write_validates_vg:1;
|
||||
|
||||
/*
|
||||
* Devices and filtering.
|
||||
|
@ -214,6 +214,16 @@ cfg(config_checks_CFG, "checks", config_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_
|
||||
"without any warning (a message about the configuration key not being\n"
|
||||
"found is issued in verbose mode only).\n")
|
||||
|
||||
cfg(config_validate_metadata_CFG, "validate_metadata", config_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_VALIDATE_METADATA, vsn(2, 3, 28), NULL, 0, NULL,
|
||||
"Allows to select the level of validation after metadata transformation.\n"
|
||||
"Validation takes extra CPU time to verify internal consistency.\n"
|
||||
"Accepted values:\n"
|
||||
" full\n"
|
||||
" Do a full metadata validation before disk write.\n"
|
||||
" none\n"
|
||||
" Skip any checks (unrecommended, slightly faster).\n"
|
||||
"#\n")
|
||||
|
||||
cfg(config_abort_on_errors_CFG, "abort_on_errors", config_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(2,2,99), NULL, 0, NULL,
|
||||
"Abort the LVM process if a configuration mismatch is found.\n")
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#define DEFAULT_ARCHIVE_ENABLED 1
|
||||
#define DEFAULT_BACKUP_ENABLED 1
|
||||
#define DEFAULT_VALIDATE_METADATA "full" /* full | none */
|
||||
|
||||
#define DEFAULT_CACHE_FILE_PREFIX ""
|
||||
|
||||
|
@ -2951,8 +2951,13 @@ int vg_write(struct volume_group *vg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!vg_validate(vg))
|
||||
return_0;
|
||||
if (vg->cmd->vg_write_validates_vg) {
|
||||
log_debug_metadata("Validating volume group structure.");
|
||||
if (!vg_validate(vg))
|
||||
return_0;
|
||||
} else
|
||||
log_debug_metadata("Skipping validation of volume group structure.");
|
||||
|
||||
|
||||
if (vg->status & PARTIAL_VG) {
|
||||
log_error("Cannot update partial volume group %s.", vg->name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user