1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

segtype: check for activation

Before setting static variable with check passed state,
detect if we are allowed to talk to driver.
This commit is contained in:
Zdenek Kabelac 2015-12-17 12:23:33 +01:00
parent 43897239b3
commit 8857b22764
10 changed files with 68 additions and 43 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.140 -
===================================
Correct checking of target presence when driver access is disabled.
Eval poolmetadatasize arg earlier in lvresize.
Fix vgcfgrestore to respect allocatable attribute of PVs.
Add report/mark_hidden_devices to lvm.conf.

View File

@ -224,20 +224,22 @@ static int _target_present(struct cmd_context *cmd,
const struct dm_config_value *cv;
const char *str;
if (!_cache_checked) {
_cache_present = target_present(cmd, "cache", 1);
if (!target_version("cache", &maj, &min, &patchlevel)) {
log_error("Failed to determine version of cache kernel module");
if (!activation())
return 0;
}
if (!_cache_checked) {
_cache_checked = 1;
if (!(_cache_present = target_present(cmd, "cache", 1)))
return 0;
if (!target_version("cache", &maj, &min, &patchlevel))
return_0;
if ((maj < 1) ||
((maj == 1) && (min < 3))) {
_cache_present = 0;
log_error("The cache kernel module is version %u.%u.%u. "
log_warn("WARNING: The cache kernel module is version %u.%u.%u. "
"Version 1.3.0+ is required.",
maj, min, patchlevel);
return 0;

View File

@ -49,13 +49,16 @@ static int _errseg_target_present(struct cmd_context *cmd,
static int _errseg_checked = 0;
static int _errseg_present = 0;
/* Reported truncated in older kernels */
if (!_errseg_checked &&
(target_present(cmd, "error", 0) ||
target_present(cmd, "erro", 0)))
_errseg_present = 1;
if (!activation())
return 0;
/* Reported truncated in older kernels */
if (!_errseg_checked) {
_errseg_checked = 1;
_errseg_present = target_present(cmd, "error", 0) ||
target_present(cmd, "erro", 0);
}
return _errseg_present;
}

View File

@ -398,9 +398,14 @@ static int _mirrored_target_present(struct cmd_context *cmd,
unsigned maj2, min2, patchlevel2;
char vsn[80];
if (!activation())
return 0;
if (!_mirrored_checked) {
_mirrored_checked = 1;
_mirrored_present = target_present(cmd, "mirror", 1);
if (!(_mirrored_present = target_present(cmd, "mirror", 1)))
return 0;
/*
* block_on_error available as "block_on_error" log

View File

@ -320,12 +320,13 @@ static int _raid_target_present(struct cmd_context *cmd,
unsigned i;
if (!_raid_checked) {
_raid_present = target_present(cmd, "raid", 1);
_raid_checked = 1;
if (!target_version("raid", &maj, &min, &patchlevel)) {
log_error("Cannot read target version of RAID kernel module.");
if (!(_raid_present = target_present(cmd, "raid", 1)))
return 0;
}
if (!target_version("raid", &maj, &min, &patchlevel))
return_0;
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
if ((maj > _features[i].maj) ||
@ -334,8 +335,6 @@ static int _raid_target_present(struct cmd_context *cmd,
else
log_very_verbose("Target raid does not support %s.",
_features[i].feature);
_raid_checked = 1;
}
if (attributes)

View File

@ -377,9 +377,12 @@ static int _replicator_target_present(struct cmd_context *cmd,
static int _checked = 0;
static int _present = 0;
if (!activation())
return 0;
if (!_checked) {
_present = target_present(cmd, REPLICATOR_MODULE, 1);
_checked = 1;
_present = target_present(cmd, REPLICATOR_MODULE, 1);
}
return _present;

View File

@ -145,13 +145,17 @@ static int _snap_target_present(struct cmd_context *cmd,
static unsigned _snap_attrs = 0;
uint32_t maj, min, patchlevel;
if (!activation())
return 0;
if (!_snap_checked) {
_snap_checked = 1;
_snap_present = target_present(cmd, "snapshot", 1) &&
target_present(cmd, "snapshot-origin", 0);
if (_snap_present &&
target_version("snapshot", &maj, &min, &patchlevel) &&
if (!(_snap_present = target_present(cmd, "snapshot", 1) &&
target_present(cmd, "snapshot-origin", 0)))
return 0;
if (target_version("snapshot", &maj, &min, &patchlevel) &&
(maj > 1 ||
(maj == 1 && (min >= 12 || (min == 10 && patchlevel >= 2)))))
_snap_attrs |= SNAPSHOT_FEATURE_FIXED_LEAK;
@ -163,12 +167,12 @@ static int _snap_target_present(struct cmd_context *cmd,
*attributes = _snap_attrs;
/* TODO: test everything at once */
if (seg && (seg->status & MERGING)) {
if (_snap_present && seg && (seg->status & MERGING)) {
if (!_snap_merge_checked) {
_snap_merge_present = target_present(cmd, "snapshot-merge", 0);
_snap_merge_checked = 1;
}
return _snap_present && _snap_merge_present;
return _snap_merge_present;
}
return _snap_present;

View File

@ -192,11 +192,14 @@ static int _striped_target_present(struct cmd_context *cmd,
static int _striped_checked = 0;
static int _striped_present = 0;
if (!_striped_checked)
if (!activation())
return 0;
if (!_striped_checked) {
_striped_checked = 1;
_striped_present = target_present(cmd, "linear", 0) &&
target_present(cmd, "striped", 0);
_striped_checked = 1;
}
return _striped_present;
}

View File

@ -678,13 +678,17 @@ static int _thin_target_present(struct cmd_context *cmd,
const struct dm_config_value *cv;
const char *str;
if (!_checked) {
_present = target_present(cmd, _thin_pool_module, 1);
if (!target_version(_thin_pool_module, &maj, &min, &patchlevel)) {
log_error("Cannot read %s target version.", _thin_pool_module);
if (!activation())
return 0;
}
if (!_checked) {
_checked = 1;
if (!(_present = target_present(cmd, _thin_pool_module, 1)))
return 0;
if (!target_version(_thin_pool_module, &maj, &min, &patchlevel))
return_0;
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
if ((maj > _features[i].maj) ||
@ -694,8 +698,6 @@ static int _thin_target_present(struct cmd_context *cmd,
log_very_verbose("Target %s does not support %s.",
_thin_pool_module,
_features[i].feature);
_checked = 1;
}
if (attributes) {
@ -704,7 +706,7 @@ static int _thin_target_present(struct cmd_context *cmd,
if ((cn = find_config_tree_array(cmd, global_thin_disabled_features_CFG, NULL))) {
for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Ignoring invalid string in config file %s.",
log_warn("WARNING: Ignoring invalid string in config file %s.",
_lvmconf);
continue;
}

View File

@ -45,10 +45,13 @@ static int _zero_target_present(struct cmd_context *cmd,
static int _zero_checked = 0;
static int _zero_present = 0;
if (!_zero_checked)
_zero_present = target_present(cmd, "zero", 1);
if (!activation())
return 0;
if (!_zero_checked) {
_zero_checked = 1;
_zero_present = target_present(cmd, "zero", 1);
}
return _zero_present;
}