]> sourceware.org Git - lvm2.git/commitdiff
targets: use target_present_version
authorZdenek Kabelac <zkabelac@redhat.com>
Sun, 7 Feb 2021 20:48:18 +0000 (21:48 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 8 Feb 2021 22:43:38 +0000 (23:43 +0100)
Skip duplicated  dm version   ioctl() on every startup.

lib/integrity/integrity.c
lib/mirror/mirrored.c
lib/raid/raid.c
lib/snapshot/snapshot.c
lib/thin/thin.c
lib/vdo/vdo.c
lib/writecache/writecache.c

index d5ad86b6373f25f91903a3b1e0e1145f6ea0592f..7423e04aec92bc653d1744a6b3810a9fd52d21c9 100644 (file)
@@ -240,9 +240,8 @@ static int _target_present(struct cmd_context *cmd,
 
        if (!_integrity_checked) {
                _integrity_checked = 1;
-               _integrity_present =  target_present(cmd, TARGET_NAME_INTEGRITY, 1);
-
-               if (!target_version(TARGET_NAME_INTEGRITY, &maj, &min, &patchlevel))
+               if (!(_integrity_present = target_present_version(cmd, TARGET_NAME_INTEGRITY, 1,
+                                                                 &maj, &min, &patchlevel)))
                        return 0;
 
                if (maj < 1 || min < 6) {
index 75893a6f67c53d63c94b4f70f2d36d18bdbf2af3..64b470a988fc8502fdb4cabaae2ee64b087fa936 100644 (file)
@@ -405,7 +405,8 @@ static int _mirrored_target_present(struct cmd_context *cmd,
        if (!_mirrored_checked) {
                _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;
 
                /*
index 6344200f5d4fe67162ccb0b82de9f1a46c8f6903..a0f00637a2cff506a0627c08dedf8ed74d1910e8 100644 (file)
@@ -551,10 +551,8 @@ static int _raid_target_present(struct cmd_context *cmd,
        if (!_raid_checked) {
                _raid_checked = 1;
 
-               if (!(_raid_present = target_present(cmd, TARGET_NAME_RAID, 1)))
-                       return 0;
-
-               if (!target_version("raid", &maj, &min, &patchlevel))
+               if (!(_raid_present = target_present_version(cmd, TARGET_NAME_RAID, 1,
+                                                            &maj, &min, &patchlevel)))
                        return_0;
 
                for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
index 3c30b3576cdfc286656ca6151e823e18d9962b2c..b832f890dd01fe92572572c72544024668c2c538 100644 (file)
@@ -152,12 +152,12 @@ static int _snap_target_present(struct cmd_context *cmd,
        if (!_snap_checked) {
                _snap_checked = 1;
 
-               if (!(_snap_present = target_present(cmd, TARGET_NAME_SNAPSHOT, 1) &&
-                     target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
+               if (!(_snap_present = (target_present_version(cmd, TARGET_NAME_SNAPSHOT, 1,
+                                                             &maj, &min, &patchlevel) &&
+                                      target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
                        return 0;
 
-               if (target_version(TARGET_NAME_SNAPSHOT, &maj, &min, &patchlevel) &&
-                   (maj > 1 ||
+               if ((maj > 1 ||
                     (maj == 1 && (min >= 12 || (min == 10 && patchlevel >= 2)))))
                        _snap_attrs |= SNAPSHOT_FEATURE_FIXED_LEAK;
                else
index 51bc269ae081018374779a5a6eaf6c15908235b2..5f301502666f430fa21b21c6f6cbba098e9f2610 100644 (file)
@@ -690,12 +690,10 @@ static int _thin_target_present(struct cmd_context *cmd,
        if (!_checked) {
                _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;
 
-               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) ||
                            (maj == _features[i].maj && min >= _features[i].min))
index bb7c78449205fa0e17a40886edcc9cf0679f8277..f26874ce57c26456a32426c16e4167574cf2ba8b 100644 (file)
@@ -419,7 +419,7 @@ static int _vdo_target_present(struct cmd_context *cmd,
                        /* Try to load kmod VDO module */
                        if (!module_present(cmd, MODULE_NAME_VDO) ||
                            !target_version(TARGET_NAME_VDO, &maj, &min, &patchlevel))
-                               return_0;
+                               return 0;
                }
 
                if (maj < 6 || (maj == 6 && min < 2)) {
index 2cef9f26eb71573088de41eb43d2762f01db8628..d114d698c7bae0e4c56d9e9a9777fb52fdf8da4a 100644 (file)
@@ -238,17 +238,9 @@ static int _target_present(struct cmd_context *cmd,
 
        if (!_writecache_checked) {
                _writecache_checked = 1;
-               _writecache_present = target_present(cmd, TARGET_NAME_WRITECACHE, 1);
-
-               if (!_writecache_present) {
-                       log_error("dm-writecache module not found in kernel.");
+               if (!(_writecache_present = target_present_version(cmd, TARGET_NAME_WRITECACHE, 1.
+                                                                  &maj, &min, &patchlevel)))
                        return 0;
-               }
-
-               if (!target_version(TARGET_NAME_WRITECACHE, &maj, &min, &patchlevel)) {
-                       log_error("dm-writecache module version not found.");
-                       return_0;
-               }
 
                if (maj < 1) {
                        log_error("dm-writecache module version older than minimum 1.0.0");
This page took 0.042129 seconds and 5 git commands to generate.