1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

targets: use target_present_version

Skip duplicated  dm version   ioctl() on every startup.
This commit is contained in:
Zdenek Kabelac 2021-02-07 21:48:18 +01:00
parent 6373f39092
commit 9b173bb931
7 changed files with 15 additions and 27 deletions

View File

@ -240,9 +240,8 @@ static int _target_present(struct cmd_context *cmd,
if (!_integrity_checked) { if (!_integrity_checked) {
_integrity_checked = 1; _integrity_checked = 1;
_integrity_present = target_present(cmd, TARGET_NAME_INTEGRITY, 1); if (!(_integrity_present = target_present_version(cmd, TARGET_NAME_INTEGRITY, 1,
&maj, &min, &patchlevel)))
if (!target_version(TARGET_NAME_INTEGRITY, &maj, &min, &patchlevel))
return 0; return 0;
if (maj < 1 || min < 6) { if (maj < 1 || min < 6) {

View File

@ -405,7 +405,8 @@ static int _mirrored_target_present(struct cmd_context *cmd,
if (!_mirrored_checked) { if (!_mirrored_checked) {
_mirrored_checked = 1; _mirrored_checked = 1;
if (!(_mirrored_present = target_present(cmd, TARGET_NAME_MIRROR, 1))) if (!(_mirrored_present = target_present_version(cmd, TARGET_NAME_MIRROR, 1,
&maj, &min, &patchlevel)))
return 0; return 0;
/* /*

View File

@ -551,10 +551,8 @@ static int _raid_target_present(struct cmd_context *cmd,
if (!_raid_checked) { if (!_raid_checked) {
_raid_checked = 1; _raid_checked = 1;
if (!(_raid_present = target_present(cmd, TARGET_NAME_RAID, 1))) if (!(_raid_present = target_present_version(cmd, TARGET_NAME_RAID, 1,
return 0; &maj, &min, &patchlevel)))
if (!target_version("raid", &maj, &min, &patchlevel))
return_0; return_0;
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i) for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)

View File

@ -152,12 +152,12 @@ static int _snap_target_present(struct cmd_context *cmd,
if (!_snap_checked) { if (!_snap_checked) {
_snap_checked = 1; _snap_checked = 1;
if (!(_snap_present = target_present(cmd, TARGET_NAME_SNAPSHOT, 1) && if (!(_snap_present = (target_present_version(cmd, TARGET_NAME_SNAPSHOT, 1,
&maj, &min, &patchlevel) &&
target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0))) target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
return 0; return 0;
if (target_version(TARGET_NAME_SNAPSHOT, &maj, &min, &patchlevel) && if ((maj > 1 ||
(maj > 1 ||
(maj == 1 && (min >= 12 || (min == 10 && patchlevel >= 2))))) (maj == 1 && (min >= 12 || (min == 10 && patchlevel >= 2)))))
_snap_attrs |= SNAPSHOT_FEATURE_FIXED_LEAK; _snap_attrs |= SNAPSHOT_FEATURE_FIXED_LEAK;
else else

View File

@ -690,12 +690,10 @@ static int _thin_target_present(struct cmd_context *cmd,
if (!_checked) { if (!_checked) {
_checked = 1; _checked = 1;
if (!(_present = target_present(cmd, _thin_pool_module, 1))) if (!(_present = target_present_version(cmd, _thin_pool_module, 1,
&maj, &min, &patchlevel)))
return 0; return 0;
if (!target_version(_thin_pool_module, &maj, &min, &patchlevel))
return_0;
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i) for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
if ((maj > _features[i].maj) || if ((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min)) (maj == _features[i].maj && min >= _features[i].min))

View File

@ -419,7 +419,7 @@ static int _vdo_target_present(struct cmd_context *cmd,
/* Try to load kmod VDO module */ /* Try to load kmod VDO module */
if (!module_present(cmd, MODULE_NAME_VDO) || if (!module_present(cmd, MODULE_NAME_VDO) ||
!target_version(TARGET_NAME_VDO, &maj, &min, &patchlevel)) !target_version(TARGET_NAME_VDO, &maj, &min, &patchlevel))
return_0; return 0;
} }
if (maj < 6 || (maj == 6 && min < 2)) { if (maj < 6 || (maj == 6 && min < 2)) {

View File

@ -238,17 +238,9 @@ static int _target_present(struct cmd_context *cmd,
if (!_writecache_checked) { if (!_writecache_checked) {
_writecache_checked = 1; _writecache_checked = 1;
_writecache_present = target_present(cmd, TARGET_NAME_WRITECACHE, 1); if (!(_writecache_present = target_present_version(cmd, TARGET_NAME_WRITECACHE, 1.
&maj, &min, &patchlevel)))
if (!_writecache_present) {
log_error("dm-writecache module not found in kernel.");
return 0; return 0;
}
if (!target_version(TARGET_NAME_WRITECACHE, &maj, &min, &patchlevel)) {
log_error("dm-writecache module version not found.");
return_0;
}
if (maj < 1) { if (maj < 1) {
log_error("dm-writecache module version older than minimum 1.0.0"); log_error("dm-writecache module version older than minimum 1.0.0");