|
|
aa2a27 |
From 2bb371937c7ef73f26717e57a5eb78cafe90a9f7 Mon Sep 17 00:00:00 2001
|
|
|
aa2a27 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
aa2a27 |
Date: Fri, 20 Sep 2019 09:58:01 +0200
|
|
|
aa2a27 |
Subject: [PATCH 1/5] Mark all GIR file constants as guint64
|
|
|
aa2a27 |
|
|
|
aa2a27 |
See 9676585e65f69ec1c309f45ba139035408d59b8e for more information.
|
|
|
aa2a27 |
---
|
|
|
aa2a27 |
src/lib/plugin_apis/btrfs.api | 2 +-
|
|
|
aa2a27 |
src/lib/plugin_apis/crypto.api | 2 +-
|
|
|
aa2a27 |
src/lib/plugin_apis/lvm.api | 20 ++++++++++----------
|
|
|
aa2a27 |
src/lib/plugin_apis/mdraid.api | 4 ++--
|
|
|
aa2a27 |
4 files changed, 14 insertions(+), 14 deletions(-)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
diff --git a/src/lib/plugin_apis/btrfs.api b/src/lib/plugin_apis/btrfs.api
|
|
|
aa2a27 |
index b52fb4ce..ef0f6c28 100644
|
|
|
aa2a27 |
--- a/src/lib/plugin_apis/btrfs.api
|
|
|
aa2a27 |
+++ b/src/lib/plugin_apis/btrfs.api
|
|
|
aa2a27 |
@@ -3,7 +3,7 @@
|
|
|
aa2a27 |
#include <blockdev/utils.h>
|
|
|
aa2a27 |
|
|
|
aa2a27 |
#define BD_BTRFS_MAIN_VOLUME_ID 5
|
|
|
aa2a27 |
-#define BD_BTRFS_MIN_MEMBER_SIZE (128 MiB)
|
|
|
aa2a27 |
+#define BD_BTRFS_MIN_MEMBER_SIZE G_GUINT64_CONSTANT (134217728ULL) // 128 MiB
|
|
|
aa2a27 |
|
|
|
aa2a27 |
GQuark bd_btrfs_error_quark (void) {
|
|
|
aa2a27 |
return g_quark_from_static_string ("g-bd-btrfs-error-quark");
|
|
|
aa2a27 |
diff --git a/src/lib/plugin_apis/crypto.api b/src/lib/plugin_apis/crypto.api
|
|
|
aa2a27 |
index e3d69986..ef0217fe 100644
|
|
|
aa2a27 |
--- a/src/lib/plugin_apis/crypto.api
|
|
|
aa2a27 |
+++ b/src/lib/plugin_apis/crypto.api
|
|
|
aa2a27 |
@@ -1,7 +1,7 @@
|
|
|
aa2a27 |
#include <glib.h>
|
|
|
aa2a27 |
#include <blockdev/utils.h>
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-#define BD_CRYPTO_LUKS_METADATA_SIZE (2 MiB)
|
|
|
aa2a27 |
+#define BD_CRYPTO_LUKS_METADATA_SIZE G_GUINT64_CONSTANT (2097152ULL) // 2 MiB
|
|
|
aa2a27 |
|
|
|
aa2a27 |
GQuark bd_crypto_error_quark (void) {
|
|
|
aa2a27 |
return g_quark_from_static_string ("g-bd-crypto-error-quark");
|
|
|
aa2a27 |
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
index 21c8f74d..ea52263b 100644
|
|
|
aa2a27 |
--- a/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
+++ b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
@@ -15,18 +15,18 @@
|
|
|
aa2a27 |
#define BD_LVM_MAX_LV_SIZE G_GUINT64_CONSTANT (9223372036854775808ULL)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-#define BD_LVM_DEFAULT_PE_START (1 MiB)
|
|
|
aa2a27 |
-#define BD_LVM_DEFAULT_PE_SIZE (4 MiB)
|
|
|
aa2a27 |
-#define BD_LVM_MIN_PE_SIZE (1 KiB)
|
|
|
aa2a27 |
-#define BD_LVM_MAX_PE_SIZE (16 GiB)
|
|
|
aa2a27 |
-#define BD_LVM_MIN_THPOOL_MD_SIZE (2 MiB)
|
|
|
aa2a27 |
-#define BD_LVM_MAX_THPOOL_MD_SIZE (16 GiB)
|
|
|
aa2a27 |
-#define BD_LVM_MIN_THPOOL_CHUNK_SIZE (64 KiB)
|
|
|
aa2a27 |
-#define BD_LVM_MAX_THPOOL_CHUNK_SIZE (1 GiB)
|
|
|
aa2a27 |
-#define BD_LVM_DEFAULT_CHUNK_SIZE (64 KiB)
|
|
|
aa2a27 |
+#define BD_LVM_DEFAULT_PE_START G_GUINT64_CONSTANT (1048576ULL) // 1 MiB
|
|
|
aa2a27 |
+#define BD_LVM_DEFAULT_PE_SIZE G_GUINT64_CONSTANT (4194304ULL) // 4 MiB
|
|
|
aa2a27 |
+#define BD_LVM_MIN_PE_SIZE G_GUINT64_CONSTANT (1024ULL) // 1 KiB
|
|
|
aa2a27 |
+#define BD_LVM_MAX_PE_SIZE G_GUINT64_CONSTANT (17179869184ULL) // 16 GiB
|
|
|
aa2a27 |
+#define BD_LVM_MIN_THPOOL_MD_SIZE G_GUINT64_CONSTANT (2097152ULL) // 2 MiB
|
|
|
aa2a27 |
+#define BD_LVM_MAX_THPOOL_MD_SIZE G_GUINT64_CONSTANT (17179869184ULL) // 16 GiB
|
|
|
aa2a27 |
+#define BD_LVM_MIN_THPOOL_CHUNK_SIZE G_GUINT64_CONSTANT (65536ULL) // 64 KiB
|
|
|
aa2a27 |
+#define BD_LVM_MAX_THPOOL_CHUNK_SIZE G_GUINT64_CONSTANT (1073741824ULL) // 1 GiB
|
|
|
aa2a27 |
+#define BD_LVM_DEFAULT_CHUNK_SIZE G_GUINT64_CONSTANT (65536ULL) // 64 KiB
|
|
|
aa2a27 |
|
|
|
aa2a27 |
/* according to lvmcache (7) */
|
|
|
aa2a27 |
-#define BD_LVM_MIN_CACHE_MD_SIZE (8 MiB)
|
|
|
aa2a27 |
+#define BD_LVM_MIN_CACHE_MD_SIZE (8388608ULL) // 8 MiB
|
|
|
aa2a27 |
|
|
|
aa2a27 |
GQuark bd_lvm_error_quark (void) {
|
|
|
aa2a27 |
return g_quark_from_static_string ("g-bd-lvm-error-quark");
|
|
|
aa2a27 |
diff --git a/src/lib/plugin_apis/mdraid.api b/src/lib/plugin_apis/mdraid.api
|
|
|
aa2a27 |
index 3bd9eaf2..02ca9530 100644
|
|
|
aa2a27 |
--- a/src/lib/plugin_apis/mdraid.api
|
|
|
aa2a27 |
+++ b/src/lib/plugin_apis/mdraid.api
|
|
|
aa2a27 |
@@ -7,8 +7,8 @@
|
|
|
aa2a27 |
|
|
|
aa2a27 |
/* taken from blivet */
|
|
|
aa2a27 |
// these defaults were determined empirically
|
|
|
aa2a27 |
-#define BD_MD_SUPERBLOCK_SIZE (2 MiB)
|
|
|
aa2a27 |
-#define BD_MD_CHUNK_SIZE (512 KiB)
|
|
|
aa2a27 |
+#define BD_MD_SUPERBLOCK_SIZE G_GUINT64_CONSTANT (2097152ULL) // 2 MiB
|
|
|
aa2a27 |
+#define BD_MD_CHUNK_SIZE G_GUINT64_CONSTANT (524288ULL) // 512 KiB
|
|
|
aa2a27 |
|
|
|
aa2a27 |
GQuark bd_md_error_quark (void) {
|
|
|
aa2a27 |
return g_quark_from_static_string ("g-bd-md-error-quark");
|
|
|
aa2a27 |
|
|
|
aa2a27 |
From aeedce3bcaa8182c9878cc51d3f85a6c6eb6a01f Mon Sep 17 00:00:00 2001
|
|
|
aa2a27 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
aa2a27 |
Date: Thu, 3 Dec 2020 14:41:25 +0100
|
|
|
aa2a27 |
Subject: [PATCH 2/5] lvm: Set thin metadata limits to match limits LVM uses in
|
|
|
aa2a27 |
lvcreate
|
|
|
aa2a27 |
|
|
|
aa2a27 |
---
|
|
|
aa2a27 |
src/lib/plugin_apis/lvm.api | 4 ++--
|
|
|
aa2a27 |
src/plugins/lvm.h | 9 +++++++--
|
|
|
aa2a27 |
tests/lvm_dbus_tests.py | 7 ++++---
|
|
|
aa2a27 |
tests/lvm_test.py | 7 ++++---
|
|
|
aa2a27 |
4 files changed, 17 insertions(+), 10 deletions(-)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
index ea52263b..e843c916 100644
|
|
|
aa2a27 |
--- a/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
+++ b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
@@ -19,8 +19,8 @@
|
|
|
aa2a27 |
#define BD_LVM_DEFAULT_PE_SIZE G_GUINT64_CONSTANT (4194304ULL) // 4 MiB
|
|
|
aa2a27 |
#define BD_LVM_MIN_PE_SIZE G_GUINT64_CONSTANT (1024ULL) // 1 KiB
|
|
|
aa2a27 |
#define BD_LVM_MAX_PE_SIZE G_GUINT64_CONSTANT (17179869184ULL) // 16 GiB
|
|
|
aa2a27 |
-#define BD_LVM_MIN_THPOOL_MD_SIZE G_GUINT64_CONSTANT (2097152ULL) // 2 MiB
|
|
|
aa2a27 |
-#define BD_LVM_MAX_THPOOL_MD_SIZE G_GUINT64_CONSTANT (17179869184ULL) // 16 GiB
|
|
|
aa2a27 |
+#define BD_LVM_MIN_THPOOL_MD_SIZE G_GUINT64_CONSTANT (4194304ULL) // 4 MiB
|
|
|
aa2a27 |
+#define BD_LVM_MAX_THPOOL_MD_SIZE G_GUINT64_CONSTANT (33957085184ULL) // 31.62 GiB
|
|
|
aa2a27 |
#define BD_LVM_MIN_THPOOL_CHUNK_SIZE G_GUINT64_CONSTANT (65536ULL) // 64 KiB
|
|
|
aa2a27 |
#define BD_LVM_MAX_THPOOL_CHUNK_SIZE G_GUINT64_CONSTANT (1073741824ULL) // 1 GiB
|
|
|
aa2a27 |
#define BD_LVM_DEFAULT_CHUNK_SIZE G_GUINT64_CONSTANT (65536ULL) // 64 KiB
|
|
|
aa2a27 |
diff --git a/src/plugins/lvm.h b/src/plugins/lvm.h
|
|
|
aa2a27 |
index 4b970f2e..01c06ca4 100644
|
|
|
aa2a27 |
--- a/src/plugins/lvm.h
|
|
|
aa2a27 |
+++ b/src/plugins/lvm.h
|
|
|
aa2a27 |
@@ -1,5 +1,6 @@
|
|
|
aa2a27 |
#include <glib.h>
|
|
|
aa2a27 |
#include <blockdev/utils.h>
|
|
|
aa2a27 |
+#include <libdevmapper.h>
|
|
|
aa2a27 |
|
|
|
aa2a27 |
#ifndef BD_LVM
|
|
|
aa2a27 |
#define BD_LVM
|
|
|
aa2a27 |
@@ -21,8 +22,12 @@
|
|
|
aa2a27 |
#define USE_DEFAULT_PE_SIZE 0
|
|
|
aa2a27 |
#define RESOLVE_PE_SIZE(size) ((size) == USE_DEFAULT_PE_SIZE ? BD_LVM_DEFAULT_PE_SIZE : (size))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-#define BD_LVM_MIN_THPOOL_MD_SIZE (2 MiB)
|
|
|
aa2a27 |
-#define BD_LVM_MAX_THPOOL_MD_SIZE (16 GiB)
|
|
|
aa2a27 |
+/* lvm constants for thin pool metadata size are actually half of these
|
|
|
aa2a27 |
+ but when they calculate the actual metadata size they double the limits
|
|
|
aa2a27 |
+ so lets just double the limits here too */
|
|
|
aa2a27 |
+#define BD_LVM_MIN_THPOOL_MD_SIZE (4 MiB)
|
|
|
aa2a27 |
+#define BD_LVM_MAX_THPOOL_MD_SIZE (DM_THIN_MAX_METADATA_SIZE KiB)
|
|
|
aa2a27 |
+
|
|
|
aa2a27 |
#define BD_LVM_MIN_THPOOL_CHUNK_SIZE (64 KiB)
|
|
|
aa2a27 |
#define BD_LVM_MAX_THPOOL_CHUNK_SIZE (1 GiB)
|
|
|
aa2a27 |
#define BD_LVM_DEFAULT_CHUNK_SIZE (64 KiB)
|
|
|
aa2a27 |
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
index 47402fc3..b517aae9 100644
|
|
|
aa2a27 |
--- a/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
+++ b/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
@@ -160,12 +160,13 @@ def test_get_thpool_meta_size(self):
|
|
|
aa2a27 |
def test_is_valid_thpool_md_size(self):
|
|
|
aa2a27 |
"""Verify that is_valid_thpool_md_size works as expected"""
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(2 * 1024**2))
|
|
|
aa2a27 |
- self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(3 * 1024**2))
|
|
|
aa2a27 |
+ self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(4 * 1024**2))
|
|
|
aa2a27 |
+ self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(5 * 1024**2))
|
|
|
aa2a27 |
self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(16 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(1 * 1024**2))
|
|
|
aa2a27 |
- self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(17 * 1024**3))
|
|
|
aa2a27 |
+ self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(3 * 1024**2))
|
|
|
aa2a27 |
+ self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(32 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@tag_test(TestTags.NOSTORAGE)
|
|
|
aa2a27 |
def test_is_valid_thpool_chunk_size(self):
|
|
|
aa2a27 |
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
|
|
|
aa2a27 |
index 149cf54a..d0085651 100644
|
|
|
aa2a27 |
--- a/tests/lvm_test.py
|
|
|
aa2a27 |
+++ b/tests/lvm_test.py
|
|
|
aa2a27 |
@@ -153,12 +153,13 @@ def test_get_thpool_meta_size(self):
|
|
|
aa2a27 |
def test_is_valid_thpool_md_size(self):
|
|
|
aa2a27 |
"""Verify that is_valid_thpool_md_size works as expected"""
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(2 * 1024**2))
|
|
|
aa2a27 |
- self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(3 * 1024**2))
|
|
|
aa2a27 |
+ self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(4 * 1024**2))
|
|
|
aa2a27 |
+ self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(5 * 1024**2))
|
|
|
aa2a27 |
self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(16 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(1 * 1024**2))
|
|
|
aa2a27 |
- self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(17 * 1024**3))
|
|
|
aa2a27 |
+ self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(3 * 1024**2))
|
|
|
aa2a27 |
+ self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(32 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@tag_test(TestTags.NOSTORAGE)
|
|
|
aa2a27 |
def test_is_valid_thpool_chunk_size(self):
|
|
|
aa2a27 |
|
|
|
aa2a27 |
From 15fcf1bb62865083a3483fc51f45e11cdc2d7386 Mon Sep 17 00:00:00 2001
|
|
|
aa2a27 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
aa2a27 |
Date: Thu, 3 Dec 2020 14:46:00 +0100
|
|
|
aa2a27 |
Subject: [PATCH 3/5] lvm: Do not use thin_metadata_size to recommend thin
|
|
|
aa2a27 |
metadata size
|
|
|
aa2a27 |
|
|
|
aa2a27 |
thin_metadata_size calculates the metadata size differently and
|
|
|
aa2a27 |
recommends smaller metadata than lvcreate so we should use the
|
|
|
aa2a27 |
lvcreate formula instead.
|
|
|
aa2a27 |
|
|
|
aa2a27 |
Resolves: rhbz#1898668
|
|
|
aa2a27 |
---
|
|
|
aa2a27 |
dist/libblockdev.spec.in | 4 --
|
|
|
aa2a27 |
src/lib/plugin_apis/lvm.api | 8 +--
|
|
|
aa2a27 |
src/plugins/lvm-dbus.c | 78 ++++++-----------------------
|
|
|
aa2a27 |
src/plugins/lvm.c | 66 +++++++-----------------
|
|
|
aa2a27 |
src/python/gi/overrides/BlockDev.py | 6 +++
|
|
|
aa2a27 |
tests/library_test.py | 6 +--
|
|
|
aa2a27 |
tests/lvm_dbus_tests.py | 20 ++++----
|
|
|
aa2a27 |
tests/lvm_test.py | 15 ++----
|
|
|
aa2a27 |
tests/utils.py | 2 +-
|
|
|
aa2a27 |
9 files changed, 61 insertions(+), 144 deletions(-)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
diff --git a/dist/libblockdev.spec.in b/dist/libblockdev.spec.in
|
|
|
aa2a27 |
index 7c775174..3e0a53c6 100644
|
|
|
aa2a27 |
--- a/dist/libblockdev.spec.in
|
|
|
aa2a27 |
+++ b/dist/libblockdev.spec.in
|
|
|
aa2a27 |
@@ -387,8 +387,6 @@ BuildRequires: device-mapper-devel
|
|
|
aa2a27 |
Summary: The LVM plugin for the libblockdev library
|
|
|
aa2a27 |
Requires: %{name}-utils%{?_isa} >= 0.11
|
|
|
aa2a27 |
Requires: lvm2
|
|
|
aa2a27 |
-# for thin_metadata_size
|
|
|
aa2a27 |
-Requires: device-mapper-persistent-data
|
|
|
aa2a27 |
|
|
|
aa2a27 |
%description lvm
|
|
|
aa2a27 |
The libblockdev library plugin (and in the same time a standalone library)
|
|
|
aa2a27 |
@@ -411,8 +409,6 @@ BuildRequires: device-mapper-devel
|
|
|
aa2a27 |
Summary: The LVM plugin for the libblockdev library
|
|
|
aa2a27 |
Requires: %{name}-utils%{?_isa} >= 1.4
|
|
|
aa2a27 |
Requires: lvm2-dbusd >= 2.02.156
|
|
|
aa2a27 |
-# for thin_metadata_size
|
|
|
aa2a27 |
-Requires: device-mapper-persistent-data
|
|
|
aa2a27 |
|
|
|
aa2a27 |
%description lvm-dbus
|
|
|
aa2a27 |
The libblockdev library plugin (and in the same time a standalone library)
|
|
|
aa2a27 |
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
index e843c916..9f25c1ed 100644
|
|
|
aa2a27 |
--- a/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
+++ b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
@@ -704,11 +704,13 @@ guint64 bd_lvm_get_thpool_padding (guint64 size, guint64 pe_size, gboolean inclu
|
|
|
aa2a27 |
* bd_lvm_get_thpool_meta_size:
|
|
|
aa2a27 |
* @size: size of the thin pool
|
|
|
aa2a27 |
* @chunk_size: chunk size of the thin pool or 0 to use the default (%BD_LVM_DEFAULT_CHUNK_SIZE)
|
|
|
aa2a27 |
- * @n_snapshots: number of snapshots that will be created in the pool
|
|
|
aa2a27 |
+ * @n_snapshots: ignored
|
|
|
aa2a27 |
* @error: (out): place to store error (if any)
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
- * Returns: recommended size of the metadata space for the specified pool or 0
|
|
|
aa2a27 |
- * in case of error
|
|
|
aa2a27 |
+ * Note: This function will be changed in 3.0: the @n_snapshots parameter
|
|
|
aa2a27 |
+ * is currently not used and will be removed.
|
|
|
aa2a27 |
+ *
|
|
|
aa2a27 |
+ * Returns: recommended size of the metadata space for the specified pool
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
|
|
|
aa2a27 |
index 9f821a99..24d54426 100644
|
|
|
aa2a27 |
--- a/src/plugins/lvm-dbus.c
|
|
|
aa2a27 |
+++ b/src/plugins/lvm-dbus.c
|
|
|
aa2a27 |
@@ -20,7 +20,6 @@
|
|
|
aa2a27 |
#include <glib.h>
|
|
|
aa2a27 |
#include <math.h>
|
|
|
aa2a27 |
#include <string.h>
|
|
|
aa2a27 |
-#include <libdevmapper.h>
|
|
|
aa2a27 |
#include <unistd.h>
|
|
|
aa2a27 |
#include <blockdev/utils.h>
|
|
|
aa2a27 |
#include <gio/gio.h>
|
|
|
aa2a27 |
@@ -248,14 +247,6 @@ static volatile guint avail_features = 0;
|
|
|
aa2a27 |
static volatile guint avail_module_deps = 0;
|
|
|
aa2a27 |
static GMutex deps_check_lock;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-#define DEPS_THMS 0
|
|
|
aa2a27 |
-#define DEPS_THMS_MASK (1 << DEPS_THMS)
|
|
|
aa2a27 |
-#define DEPS_LAST 1
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
-static const UtilDep deps[DEPS_LAST] = {
|
|
|
aa2a27 |
- {"thin_metadata_size", NULL, NULL, NULL},
|
|
|
aa2a27 |
-};
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
#define DBUS_DEPS_LVMDBUSD 0
|
|
|
aa2a27 |
#define DBUS_DEPS_LVMDBUSD_MASK (1 << DBUS_DEPS_LVMDBUSD)
|
|
|
aa2a27 |
#define DBUS_DEPS_LAST 1
|
|
|
aa2a27 |
@@ -301,17 +292,6 @@ gboolean bd_lvm_check_deps (void) {
|
|
|
aa2a27 |
check_ret = check_ret && success;
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- for (i=0; i < DEPS_LAST; i++) {
|
|
|
aa2a27 |
- success = bd_utils_check_util_version (deps[i].name, deps[i].version,
|
|
|
aa2a27 |
- deps[i].ver_arg, deps[i].ver_regexp, &error);
|
|
|
aa2a27 |
- if (!success)
|
|
|
aa2a27 |
- g_warning ("%s", error->message);
|
|
|
aa2a27 |
- else
|
|
|
aa2a27 |
- g_atomic_int_or (&avail_deps, 1 << i);
|
|
|
aa2a27 |
- g_clear_error (&error);
|
|
|
aa2a27 |
- check_ret = check_ret && success;
|
|
|
aa2a27 |
- }
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
if (!check_ret)
|
|
|
aa2a27 |
g_warning("Cannot load the LVM plugin");
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -386,10 +366,7 @@ gboolean bd_lvm_is_tech_avail (BDLVMTech tech, guint64 mode, GError **error) {
|
|
|
aa2a27 |
g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_TECH_UNAVAIL,
|
|
|
aa2a27 |
"Only 'query' supported for thin calculations");
|
|
|
aa2a27 |
return FALSE;
|
|
|
aa2a27 |
- } else if ((mode & BD_LVM_TECH_MODE_QUERY) &&
|
|
|
aa2a27 |
- !check_deps (&avail_deps, DEPS_THMS_MASK, deps, DEPS_LAST, &deps_check_lock, error))
|
|
|
aa2a27 |
- return FALSE;
|
|
|
aa2a27 |
- else
|
|
|
aa2a27 |
+ } else
|
|
|
aa2a27 |
return TRUE;
|
|
|
aa2a27 |
case BD_LVM_TECH_CALCS:
|
|
|
aa2a27 |
if (mode & ~BD_LVM_TECH_MODE_QUERY) {
|
|
|
aa2a27 |
@@ -1303,53 +1280,28 @@ guint64 bd_lvm_get_thpool_padding (guint64 size, guint64 pe_size, gboolean inclu
|
|
|
aa2a27 |
* bd_lvm_get_thpool_meta_size:
|
|
|
aa2a27 |
* @size: size of the thin pool
|
|
|
aa2a27 |
* @chunk_size: chunk size of the thin pool or 0 to use the default (%BD_LVM_DEFAULT_CHUNK_SIZE)
|
|
|
aa2a27 |
- * @n_snapshots: number of snapshots that will be created in the pool
|
|
|
aa2a27 |
+ * @n_snapshots: ignored
|
|
|
aa2a27 |
* @error: (out): place to store error (if any)
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
- * Returns: recommended size of the metadata space for the specified pool or 0
|
|
|
aa2a27 |
- * in case of error
|
|
|
aa2a27 |
+ * Note: This function will be changed in 3.0: the @n_snapshots parameter
|
|
|
aa2a27 |
+ * is currently not used and will be removed.
|
|
|
aa2a27 |
+ *
|
|
|
aa2a27 |
+ * Returns: recommended size of the metadata space for the specified pool
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n_snapshots, GError **error) {
|
|
|
aa2a27 |
- /* ub - output in bytes, n - output just the number */
|
|
|
aa2a27 |
- const gchar* args[7] = {"thin_metadata_size", "-ub", "-n", NULL, NULL, NULL, NULL};
|
|
|
aa2a27 |
- gchar *output = NULL;
|
|
|
aa2a27 |
- gboolean success = FALSE;
|
|
|
aa2a27 |
- guint64 ret = 0;
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- if (!check_deps (&avail_deps, DEPS_THMS_MASK, deps, DEPS_LAST, &deps_check_lock, error))
|
|
|
aa2a27 |
- return 0;
|
|
|
aa2a27 |
+guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n_snapshots UNUSED, GError **error UNUSED) {
|
|
|
aa2a27 |
+ guint64 md_size = 0;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- /* s - total size, b - chunk size, m - number of snapshots */
|
|
|
aa2a27 |
- args[3] = g_strdup_printf ("-s%"G_GUINT64_FORMAT, size);
|
|
|
aa2a27 |
- args[4] = g_strdup_printf ("-b%"G_GUINT64_FORMAT,
|
|
|
aa2a27 |
- chunk_size != 0 ? chunk_size : (guint64) BD_LVM_DEFAULT_CHUNK_SIZE);
|
|
|
aa2a27 |
- args[5] = g_strdup_printf ("-m%"G_GUINT64_FORMAT, n_snapshots);
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- success = bd_utils_exec_and_capture_output (args, NULL, &output, error);
|
|
|
aa2a27 |
- g_free ((gchar*) args[3]);
|
|
|
aa2a27 |
- g_free ((gchar*) args[4]);
|
|
|
aa2a27 |
- g_free ((gchar*) args[5]);
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- if (!success) {
|
|
|
aa2a27 |
- /* error is already set */
|
|
|
aa2a27 |
- g_free (output);
|
|
|
aa2a27 |
- return 0;
|
|
|
aa2a27 |
- }
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- ret = g_ascii_strtoull (output, NULL, 0);
|
|
|
aa2a27 |
- if (ret == 0) {
|
|
|
aa2a27 |
- g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
|
|
|
aa2a27 |
- "Failed to parse number from thin_metadata_size's output: '%s'",
|
|
|
aa2a27 |
- output);
|
|
|
aa2a27 |
- g_free (output);
|
|
|
aa2a27 |
- return 0;
|
|
|
aa2a27 |
- }
|
|
|
aa2a27 |
+ /* based on lvcreate metadata size calculation */
|
|
|
aa2a27 |
+ md_size = UINT64_C(64) * size / (chunk_size ? chunk_size : BD_LVM_DEFAULT_CHUNK_SIZE);
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- g_free (output);
|
|
|
aa2a27 |
+ if (md_size > BD_LVM_MAX_THPOOL_MD_SIZE)
|
|
|
aa2a27 |
+ md_size = BD_LVM_MAX_THPOOL_MD_SIZE;
|
|
|
aa2a27 |
+ else if (md_size < BD_LVM_MIN_THPOOL_MD_SIZE)
|
|
|
aa2a27 |
+ md_size = BD_LVM_MIN_THPOOL_MD_SIZE;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- return MAX (ret, BD_LVM_MIN_THPOOL_MD_SIZE);
|
|
|
aa2a27 |
+ return md_size;
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
/**
|
|
|
aa2a27 |
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
|
|
|
aa2a27 |
index 6bfaa338..74493feb 100644
|
|
|
aa2a27 |
--- a/src/plugins/lvm.c
|
|
|
aa2a27 |
+++ b/src/plugins/lvm.c
|
|
|
aa2a27 |
@@ -20,7 +20,6 @@
|
|
|
aa2a27 |
#include <glib.h>
|
|
|
aa2a27 |
#include <math.h>
|
|
|
aa2a27 |
#include <string.h>
|
|
|
aa2a27 |
-#include <libdevmapper.h>
|
|
|
aa2a27 |
#include <unistd.h>
|
|
|
aa2a27 |
#include <blockdev/utils.h>
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -213,13 +212,10 @@ static GMutex deps_check_lock;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
#define DEPS_LVM 0
|
|
|
aa2a27 |
#define DEPS_LVM_MASK (1 << DEPS_LVM)
|
|
|
aa2a27 |
-#define DEPS_THMS 1
|
|
|
aa2a27 |
-#define DEPS_THMS_MASK (1 << DEPS_THMS)
|
|
|
aa2a27 |
-#define DEPS_LAST 2
|
|
|
aa2a27 |
+#define DEPS_LAST 1
|
|
|
aa2a27 |
|
|
|
aa2a27 |
static const UtilDep deps[DEPS_LAST] = {
|
|
|
aa2a27 |
{"lvm", LVM_MIN_VERSION, "version", "LVM version:\\s+([\\d\\.]+)"},
|
|
|
aa2a27 |
- {"thin_metadata_size", NULL, NULL, NULL},
|
|
|
aa2a27 |
};
|
|
|
aa2a27 |
|
|
|
aa2a27 |
#define FEATURES_VDO 0
|
|
|
aa2a27 |
@@ -236,6 +232,8 @@ static const UtilFeatureDep features[FEATURES_LAST] = {
|
|
|
aa2a27 |
|
|
|
aa2a27 |
static const gchar*const module_deps[MODULE_DEPS_LAST] = { "kvdo" };
|
|
|
aa2a27 |
|
|
|
aa2a27 |
+#define UNUSED __attribute__((unused))
|
|
|
aa2a27 |
+
|
|
|
aa2a27 |
/**
|
|
|
aa2a27 |
* bd_lvm_check_deps:
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
@@ -317,10 +315,7 @@ gboolean bd_lvm_is_tech_avail (BDLVMTech tech, guint64 mode, GError **error) {
|
|
|
aa2a27 |
g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_TECH_UNAVAIL,
|
|
|
aa2a27 |
"Only 'query' supported for thin calculations");
|
|
|
aa2a27 |
return FALSE;
|
|
|
aa2a27 |
- } else if ((mode & BD_LVM_TECH_MODE_QUERY) &&
|
|
|
aa2a27 |
- !check_deps (&avail_deps, DEPS_THMS_MASK, deps, DEPS_LAST, &deps_check_lock, error))
|
|
|
aa2a27 |
- return FALSE;
|
|
|
aa2a27 |
- else
|
|
|
aa2a27 |
+ } else
|
|
|
aa2a27 |
return TRUE;
|
|
|
aa2a27 |
case BD_LVM_TECH_CALCS:
|
|
|
aa2a27 |
if (mode & ~BD_LVM_TECH_MODE_QUERY) {
|
|
|
aa2a27 |
@@ -820,53 +815,28 @@ guint64 bd_lvm_get_thpool_padding (guint64 size, guint64 pe_size, gboolean inclu
|
|
|
aa2a27 |
* bd_lvm_get_thpool_meta_size:
|
|
|
aa2a27 |
* @size: size of the thin pool
|
|
|
aa2a27 |
* @chunk_size: chunk size of the thin pool or 0 to use the default (%BD_LVM_DEFAULT_CHUNK_SIZE)
|
|
|
aa2a27 |
- * @n_snapshots: number of snapshots that will be created in the pool
|
|
|
aa2a27 |
+ * @n_snapshots: ignored
|
|
|
aa2a27 |
* @error: (out): place to store error (if any)
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
- * Returns: recommended size of the metadata space for the specified pool or 0
|
|
|
aa2a27 |
- * in case of error
|
|
|
aa2a27 |
+ * Note: This function will be changed in 3.0: the @n_snapshots parameter
|
|
|
aa2a27 |
+ * is currently not used and will be removed.
|
|
|
aa2a27 |
+ *
|
|
|
aa2a27 |
+ * Returns: recommended size of the metadata space for the specified pool
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n_snapshots, GError **error) {
|
|
|
aa2a27 |
- /* ub - output in bytes, n - output just the number */
|
|
|
aa2a27 |
- const gchar* args[7] = {"thin_metadata_size", "-ub", "-n", NULL, NULL, NULL, NULL};
|
|
|
aa2a27 |
- gchar *output = NULL;
|
|
|
aa2a27 |
- gboolean success = FALSE;
|
|
|
aa2a27 |
- guint64 ret = 0;
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- if (!check_deps (&avail_deps, DEPS_THMS_MASK, deps, DEPS_LAST, &deps_check_lock, error))
|
|
|
aa2a27 |
- return 0;
|
|
|
aa2a27 |
+guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n_snapshots UNUSED, GError **error UNUSED) {
|
|
|
aa2a27 |
+ guint64 md_size = 0;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- /* s - total size, b - chunk size, m - number of snapshots */
|
|
|
aa2a27 |
- args[3] = g_strdup_printf ("-s%"G_GUINT64_FORMAT, size);
|
|
|
aa2a27 |
- args[4] = g_strdup_printf ("-b%"G_GUINT64_FORMAT,
|
|
|
aa2a27 |
- chunk_size != 0 ? chunk_size : (guint64) BD_LVM_DEFAULT_CHUNK_SIZE);
|
|
|
aa2a27 |
- args[5] = g_strdup_printf ("-m%"G_GUINT64_FORMAT, n_snapshots);
|
|
|
aa2a27 |
+ /* based on lvcreate metadata size calculation */
|
|
|
aa2a27 |
+ md_size = UINT64_C(64) * size / (chunk_size ? chunk_size : BD_LVM_DEFAULT_CHUNK_SIZE);
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- success = bd_utils_exec_and_capture_output (args, NULL, &output, error);
|
|
|
aa2a27 |
- g_free ((gchar*) args[3]);
|
|
|
aa2a27 |
- g_free ((gchar*) args[4]);
|
|
|
aa2a27 |
- g_free ((gchar*) args[5]);
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- if (!success) {
|
|
|
aa2a27 |
- /* error is already set */
|
|
|
aa2a27 |
- g_free (output);
|
|
|
aa2a27 |
- return 0;
|
|
|
aa2a27 |
- }
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- ret = g_ascii_strtoull (output, NULL, 0);
|
|
|
aa2a27 |
- if (ret == 0) {
|
|
|
aa2a27 |
- g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
|
|
|
aa2a27 |
- "Failed to parse number from thin_metadata_size's output: '%s'",
|
|
|
aa2a27 |
- output);
|
|
|
aa2a27 |
- g_free (output);
|
|
|
aa2a27 |
- return 0;
|
|
|
aa2a27 |
- }
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- g_free (output);
|
|
|
aa2a27 |
+ if (md_size > BD_LVM_MAX_THPOOL_MD_SIZE)
|
|
|
aa2a27 |
+ md_size = BD_LVM_MAX_THPOOL_MD_SIZE;
|
|
|
aa2a27 |
+ else if (md_size < BD_LVM_MIN_THPOOL_MD_SIZE)
|
|
|
aa2a27 |
+ md_size = BD_LVM_MIN_THPOOL_MD_SIZE;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- return MAX (ret, BD_LVM_MIN_THPOOL_MD_SIZE);
|
|
|
aa2a27 |
+ return md_size;
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
/**
|
|
|
aa2a27 |
diff --git a/src/python/gi/overrides/BlockDev.py b/src/python/gi/overrides/BlockDev.py
|
|
|
aa2a27 |
index d78bfaab..f768c8bd 100644
|
|
|
aa2a27 |
--- a/src/python/gi/overrides/BlockDev.py
|
|
|
aa2a27 |
+++ b/src/python/gi/overrides/BlockDev.py
|
|
|
aa2a27 |
@@ -462,6 +462,12 @@ def lvm_get_thpool_padding(size, pe_size=0, included=False):
|
|
|
aa2a27 |
return _lvm_get_thpool_padding(size, pe_size, included)
|
|
|
aa2a27 |
__all__.append("lvm_get_thpool_padding")
|
|
|
aa2a27 |
|
|
|
aa2a27 |
+_lvm_get_thpool_meta_size = BlockDev.lvm_get_thpool_meta_size
|
|
|
aa2a27 |
+@override(BlockDev.lvm_get_thpool_meta_size)
|
|
|
aa2a27 |
+def lvm_get_thpool_meta_size(size, chunk_size=0, n_snapshots=0):
|
|
|
aa2a27 |
+ return _lvm_get_thpool_meta_size(size, chunk_size, n_snapshots)
|
|
|
aa2a27 |
+__all__.append("lvm_get_thpool_meta_size")
|
|
|
aa2a27 |
+
|
|
|
aa2a27 |
_lvm_pvcreate = BlockDev.lvm_pvcreate
|
|
|
aa2a27 |
@override(BlockDev.lvm_pvcreate)
|
|
|
aa2a27 |
def lvm_pvcreate(device, data_alignment=0, metadata_size=0, extra=None, **kwargs):
|
|
|
aa2a27 |
diff --git a/tests/library_test.py b/tests/library_test.py
|
|
|
aa2a27 |
index e8bb175a..08e44fdc 100644
|
|
|
aa2a27 |
--- a/tests/library_test.py
|
|
|
aa2a27 |
+++ b/tests/library_test.py
|
|
|
aa2a27 |
@@ -349,8 +349,7 @@ def test_try_reinit(self):
|
|
|
aa2a27 |
|
|
|
aa2a27 |
# try reinitializing with only some utilities being available and thus
|
|
|
aa2a27 |
# only some plugins able to load
|
|
|
aa2a27 |
- with fake_path("tests/lib_missing_utils", keep_utils=["swapon", "swapoff", "mkswap", "lvm",
|
|
|
aa2a27 |
- "thin_metadata_size", "swaplabel"]):
|
|
|
aa2a27 |
+ with fake_path("tests/lib_missing_utils", keep_utils=["swapon", "swapoff", "mkswap", "lvm", "swaplabel"]):
|
|
|
aa2a27 |
succ, loaded = BlockDev.try_reinit(self.requested_plugins, True, None)
|
|
|
aa2a27 |
self.assertFalse(succ)
|
|
|
aa2a27 |
for plug_name in ("swap", "lvm", "crypto"):
|
|
|
aa2a27 |
@@ -361,8 +360,7 @@ def test_try_reinit(self):
|
|
|
aa2a27 |
|
|
|
aa2a27 |
# now the same with a subset of plugins requested
|
|
|
aa2a27 |
plugins = BlockDev.plugin_specs_from_names(["lvm", "swap", "crypto"])
|
|
|
aa2a27 |
- with fake_path("tests/lib_missing_utils", keep_utils=["swapon", "swapoff", "mkswap", "lvm",
|
|
|
aa2a27 |
- "thin_metadata_size", "swaplabel"]):
|
|
|
aa2a27 |
+ with fake_path("tests/lib_missing_utils", keep_utils=["swapon", "swapoff", "mkswap", "lvm","swaplabel"]):
|
|
|
aa2a27 |
succ, loaded = BlockDev.try_reinit(plugins, True, None)
|
|
|
aa2a27 |
self.assertTrue(succ)
|
|
|
aa2a27 |
self.assertEqual(set(loaded), set(["swap", "lvm", "crypto"]))
|
|
|
aa2a27 |
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
index b517aae9..c06a480c 100644
|
|
|
aa2a27 |
--- a/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
+++ b/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
@@ -141,21 +141,19 @@ def test_get_thpool_padding(self):
|
|
|
aa2a27 |
def test_get_thpool_meta_size(self):
|
|
|
aa2a27 |
"""Verify that getting recommended thin pool metadata size works as expected"""
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- # no idea how thin_metadata_size works, but let's at least check that
|
|
|
aa2a27 |
- # the function works and returns what thin_metadata_size says
|
|
|
aa2a27 |
- out1 = subprocess.check_output(["thin_metadata_size", "-ub", "-n", "-b64k", "-s1t", "-m100"])
|
|
|
aa2a27 |
- self.assertEqual(int(out1), BlockDev.lvm_get_thpool_meta_size (1 * 1024**4, 64 * 1024, 100))
|
|
|
aa2a27 |
+ # metadata size is calculated as 64 * pool_size / chunk_size
|
|
|
aa2a27 |
+ self.assertEqual(BlockDev.lvm_get_thpool_meta_size(1 * 1024**4, 64 * 1024), 1 * 1024**3)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- out2 = subprocess.check_output(["thin_metadata_size", "-ub", "-n", "-b128k", "-s1t", "-m100"])
|
|
|
aa2a27 |
- self.assertEqual(int(out2), BlockDev.lvm_get_thpool_meta_size (1 * 1024**4, 128 * 1024, 100))
|
|
|
aa2a27 |
+ self.assertEqual(BlockDev.lvm_get_thpool_meta_size(1 * 1024**4, 128 * 1024), 512 * 1024**2)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- # twice the chunk_size -> roughly half the metadata needed
|
|
|
aa2a27 |
- self.assertAlmostEqual(float(out1) / float(out2), 2, places=2)
|
|
|
aa2a27 |
-
|
|
|
aa2a27 |
- # unless thin_metadata_size gives a value that is not valid (too small)
|
|
|
aa2a27 |
- self.assertEqual(BlockDev.lvm_get_thpool_meta_size (100 * 1024**2, 128 * 1024, 100),
|
|
|
aa2a27 |
+ # lower limit is 4 MiB
|
|
|
aa2a27 |
+ self.assertEqual(BlockDev.lvm_get_thpool_meta_size(100 * 1024**2, 128 * 1024),
|
|
|
aa2a27 |
BlockDev.LVM_MIN_THPOOL_MD_SIZE)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
+ # upper limit is 31.62 GiB
|
|
|
aa2a27 |
+ self.assertEqual(BlockDev.lvm_get_thpool_meta_size(100 * 1024**4, 64 * 1024),
|
|
|
aa2a27 |
+ BlockDev.LVM_MAX_THPOOL_MD_SIZE)
|
|
|
aa2a27 |
+
|
|
|
aa2a27 |
@tag_test(TestTags.NOSTORAGE)
|
|
|
aa2a27 |
def test_is_valid_thpool_md_size(self):
|
|
|
aa2a27 |
"""Verify that is_valid_thpool_md_size works as expected"""
|
|
|
aa2a27 |
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
|
|
|
aa2a27 |
index d0085651..b84adece 100644
|
|
|
aa2a27 |
--- a/tests/lvm_test.py
|
|
|
aa2a27 |
+++ b/tests/lvm_test.py
|
|
|
aa2a27 |
@@ -134,19 +134,14 @@ def test_get_thpool_padding(self):
|
|
|
aa2a27 |
def test_get_thpool_meta_size(self):
|
|
|
aa2a27 |
"""Verify that getting recommended thin pool metadata size works as expected"""
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- # no idea how thin_metadata_size works, but let's at least check that
|
|
|
aa2a27 |
- # the function works and returns what thin_metadata_size says
|
|
|
aa2a27 |
- out1 = subprocess.check_output(["thin_metadata_size", "-ub", "-n", "-b64k", "-s1t", "-m100"])
|
|
|
aa2a27 |
- self.assertEqual(int(out1), BlockDev.lvm_get_thpool_meta_size (1 * 1024**4, 64 * 1024, 100))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- out2 = subprocess.check_output(["thin_metadata_size", "-ub", "-n", "-b128k", "-s1t", "-m100"])
|
|
|
aa2a27 |
- self.assertEqual(int(out2), BlockDev.lvm_get_thpool_meta_size (1 * 1024**4, 128 * 1024, 100))
|
|
|
aa2a27 |
+ self.assertEqual(BlockDev.lvm_get_thpool_meta_size(1 * 1024**4, 64 * 1024),
|
|
|
aa2a27 |
+ 1 * 1024**3)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- # twice the chunk_size -> roughly half the metadata needed
|
|
|
aa2a27 |
- self.assertAlmostEqual(float(out1) / float(out2), 2, places=2)
|
|
|
aa2a27 |
+ self.assertEqual(BlockDev.lvm_get_thpool_meta_size(1 * 1024**4, 128 * 1024),
|
|
|
aa2a27 |
+ 512 * 1024**2)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
- # unless thin_metadata_size gives a value that is not valid (too small)
|
|
|
aa2a27 |
- self.assertEqual(BlockDev.lvm_get_thpool_meta_size (100 * 1024**2, 128 * 1024, 100),
|
|
|
aa2a27 |
+ self.assertEqual(BlockDev.lvm_get_thpool_meta_size(100 * 1024**2, 128 * 1024),
|
|
|
aa2a27 |
BlockDev.LVM_MIN_THPOOL_MD_SIZE)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@tag_test(TestTags.NOSTORAGE)
|
|
|
aa2a27 |
diff --git a/tests/utils.py b/tests/utils.py
|
|
|
aa2a27 |
index 182eda6a..584fde5c 100644
|
|
|
aa2a27 |
--- a/tests/utils.py
|
|
|
aa2a27 |
+++ b/tests/utils.py
|
|
|
aa2a27 |
@@ -70,7 +70,7 @@ def fake_utils(path="."):
|
|
|
aa2a27 |
finally:
|
|
|
aa2a27 |
os.environ["PATH"] = old_path
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-ALL_UTILS = {"lvm", "thin_metadata_size", "btrfs", "mkswap", "swaplabel", "multipath", "mpathconf", "dmsetup", "mdadm", "make-bcache", "sgdisk", "sfdisk"}
|
|
|
aa2a27 |
+ALL_UTILS = {"lvm", "btrfs", "mkswap", "swaplabel", "multipath", "mpathconf", "dmsetup", "mdadm", "make-bcache", "sgdisk", "sfdisk"}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@contextmanager
|
|
|
aa2a27 |
def fake_path(path=None, keep_utils=None, all_but=None):
|
|
|
aa2a27 |
|
|
|
aa2a27 |
From 27961a3fcb205ea51f40668d68765dd8d388777b Mon Sep 17 00:00:00 2001
|
|
|
aa2a27 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
aa2a27 |
Date: Thu, 3 Dec 2020 14:48:08 +0100
|
|
|
aa2a27 |
Subject: [PATCH 4/5] lvm: Use the UNUSED macro instead of
|
|
|
aa2a27 |
__attribute__((unused))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
for unused attributes. It makes the function definition a little
|
|
|
aa2a27 |
bit more readable.
|
|
|
aa2a27 |
---
|
|
|
aa2a27 |
src/plugins/lvm-dbus.c | 24 ++++++++++++------------
|
|
|
aa2a27 |
src/plugins/lvm.c | 20 ++++++++++----------
|
|
|
aa2a27 |
2 files changed, 22 insertions(+), 22 deletions(-)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
|
|
|
aa2a27 |
index 24d54426..b7b4480e 100644
|
|
|
aa2a27 |
--- a/src/plugins/lvm-dbus.c
|
|
|
aa2a27 |
+++ b/src/plugins/lvm-dbus.c
|
|
|
aa2a27 |
@@ -959,7 +959,7 @@ static BDLVMPVdata* get_pv_data_from_props (GVariant *props, GError **error) {
|
|
|
aa2a27 |
return data;
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-static BDLVMVGdata* get_vg_data_from_props (GVariant *props, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+static BDLVMVGdata* get_vg_data_from_props (GVariant *props, GError **error UNUSED) {
|
|
|
aa2a27 |
BDLVMVGdata *data = g_new0 (BDLVMVGdata, 1);
|
|
|
aa2a27 |
GVariantDict dict;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -1061,7 +1061,7 @@ static BDLVMLVdata* get_lv_data_from_props (GVariant *props, GError **error) {
|
|
|
aa2a27 |
return data;
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-static BDLVMVDOPooldata* get_vdo_data_from_props (GVariant *props, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+static BDLVMVDOPooldata* get_vdo_data_from_props (GVariant *props, GError **error UNUSED) {
|
|
|
aa2a27 |
BDLVMVDOPooldata *data = g_new0 (BDLVMVDOPooldata, 1);
|
|
|
aa2a27 |
GVariantDict dict;
|
|
|
aa2a27 |
gchar *value = NULL;
|
|
|
aa2a27 |
@@ -1165,7 +1165,7 @@ static GVariant* create_size_str_param (guint64 size, const gchar *unit) {
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error UNUSED) {
|
|
|
aa2a27 |
return (((size % 2) == 0) && (size >= (BD_LVM_MIN_PE_SIZE)) && (size <= (BD_LVM_MAX_PE_SIZE)));
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -1177,7 +1177,7 @@ gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error __attribute__
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 *bd_lvm_get_supported_pe_sizes (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 *bd_lvm_get_supported_pe_sizes (GError **error UNUSED) {
|
|
|
aa2a27 |
guint8 i;
|
|
|
aa2a27 |
guint64 val = BD_LVM_MIN_PE_SIZE;
|
|
|
aa2a27 |
guint8 num_items = ((guint8) round (log2 ((double) BD_LVM_MAX_PE_SIZE))) - ((guint8) round (log2 ((double) BD_LVM_MIN_PE_SIZE))) + 2;
|
|
|
aa2a27 |
@@ -1199,7 +1199,7 @@ guint64 *bd_lvm_get_supported_pe_sizes (GError **error __attribute__((unused)))
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_get_max_lv_size (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 bd_lvm_get_max_lv_size (GError **error UNUSED) {
|
|
|
aa2a27 |
return BD_LVM_MAX_LV_SIZE;
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -1219,7 +1219,7 @@ guint64 bd_lvm_get_max_lv_size (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_round_size_to_pe (guint64 size, guint64 pe_size, gboolean roundup, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 bd_lvm_round_size_to_pe (guint64 size, guint64 pe_size, gboolean roundup, GError **error UNUSED) {
|
|
|
aa2a27 |
pe_size = RESOLVE_PE_SIZE(pe_size);
|
|
|
aa2a27 |
guint64 delta = size % pe_size;
|
|
|
aa2a27 |
if (delta == 0)
|
|
|
aa2a27 |
@@ -1313,7 +1313,7 @@ guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error UNUSED) {
|
|
|
aa2a27 |
return ((BD_LVM_MIN_THPOOL_MD_SIZE <= size) && (size <= BD_LVM_MAX_THPOOL_MD_SIZE));
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -1327,7 +1327,7 @@ gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error __attribut
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_is_valid_thpool_chunk_size (guint64 size, gboolean discard, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_is_valid_thpool_chunk_size (guint64 size, gboolean discard, GError **error UNUSED) {
|
|
|
aa2a27 |
gdouble size_log2 = 0.0;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
if ((size < BD_LVM_MIN_THPOOL_CHUNK_SIZE) || (size > BD_LVM_MAX_THPOOL_CHUNK_SIZE))
|
|
|
aa2a27 |
@@ -2616,7 +2616,7 @@ gboolean bd_lvm_thsnapshotcreate (const gchar *vg_name, const gchar *origin_name
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error UNUSED) {
|
|
|
aa2a27 |
/* XXX: the error attribute will likely be used in the future when
|
|
|
aa2a27 |
some validation comes into the game */
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -2641,7 +2641,7 @@ gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error __att
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gchar* bd_lvm_get_global_config (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gchar* bd_lvm_get_global_config (GError **error UNUSED) {
|
|
|
aa2a27 |
gchar *ret = NULL;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
g_mutex_lock (&global_config_lock);
|
|
|
aa2a27 |
@@ -2660,7 +2660,7 @@ gchar* bd_lvm_get_global_config (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CACHE_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error UNUSED) {
|
|
|
aa2a27 |
return MAX ((guint64) cache_size / 1000, BD_LVM_MIN_CACHE_MD_SIZE);
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -2670,7 +2670,7 @@ guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error __a
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Get LV type string from flags.
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-static const gchar* get_lv_type_from_flags (BDLVMCachePoolFlags flags, gboolean meta, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+static const gchar* get_lv_type_from_flags (BDLVMCachePoolFlags flags, gboolean meta, GError **error UNUSED) {
|
|
|
aa2a27 |
if (!meta) {
|
|
|
aa2a27 |
if (flags & BD_LVM_CACHE_POOL_STRIPED)
|
|
|
aa2a27 |
return "striped";
|
|
|
aa2a27 |
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
|
|
|
aa2a27 |
index 74493feb..2be1dbdb 100644
|
|
|
aa2a27 |
--- a/src/plugins/lvm.c
|
|
|
aa2a27 |
+++ b/src/plugins/lvm.c
|
|
|
aa2a27 |
@@ -700,7 +700,7 @@ static BDLVMVDOPooldata* get_vdo_data_from_table (GHashTable *table, gboolean fr
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error UNUSED) {
|
|
|
aa2a27 |
return (((size % 2) == 0) && (size >= (BD_LVM_MIN_PE_SIZE)) && (size <= (BD_LVM_MAX_PE_SIZE)));
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -712,7 +712,7 @@ gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error __attribute__
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 *bd_lvm_get_supported_pe_sizes (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 *bd_lvm_get_supported_pe_sizes (GError **error UNUSED) {
|
|
|
aa2a27 |
guint8 i;
|
|
|
aa2a27 |
guint64 val = BD_LVM_MIN_PE_SIZE;
|
|
|
aa2a27 |
guint8 num_items = ((guint8) round (log2 ((double) BD_LVM_MAX_PE_SIZE))) - ((guint8) round (log2 ((double) BD_LVM_MIN_PE_SIZE))) + 2;
|
|
|
aa2a27 |
@@ -734,7 +734,7 @@ guint64 *bd_lvm_get_supported_pe_sizes (GError **error __attribute__((unused)))
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_get_max_lv_size (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 bd_lvm_get_max_lv_size (GError **error UNUSED) {
|
|
|
aa2a27 |
return BD_LVM_MAX_LV_SIZE;
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -754,7 +754,7 @@ guint64 bd_lvm_get_max_lv_size (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_round_size_to_pe (guint64 size, guint64 pe_size, gboolean roundup, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 bd_lvm_round_size_to_pe (guint64 size, guint64 pe_size, gboolean roundup, GError **error UNUSED) {
|
|
|
aa2a27 |
pe_size = RESOLVE_PE_SIZE(pe_size);
|
|
|
aa2a27 |
guint64 delta = size % pe_size;
|
|
|
aa2a27 |
if (delta == 0)
|
|
|
aa2a27 |
@@ -848,7 +848,7 @@ guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error UNUSED) {
|
|
|
aa2a27 |
return ((BD_LVM_MIN_THPOOL_MD_SIZE <= size) && (size <= BD_LVM_MAX_THPOOL_MD_SIZE));
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -862,7 +862,7 @@ gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error __attribut
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_is_valid_thpool_chunk_size (guint64 size, gboolean discard, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_is_valid_thpool_chunk_size (guint64 size, gboolean discard, GError **error UNUSED) {
|
|
|
aa2a27 |
gdouble size_log2 = 0.0;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
if ((size < BD_LVM_MIN_THPOOL_CHUNK_SIZE) || (size > BD_LVM_MAX_THPOOL_CHUNK_SIZE))
|
|
|
aa2a27 |
@@ -1983,7 +1983,7 @@ gboolean bd_lvm_thsnapshotcreate (const gchar *vg_name, const gchar *origin_name
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error UNUSED) {
|
|
|
aa2a27 |
/* XXX: the error attribute will likely be used in the future when
|
|
|
aa2a27 |
some validation comes into the game */
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -2008,7 +2008,7 @@ gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error __att
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-gchar* bd_lvm_get_global_config (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+gchar* bd_lvm_get_global_config (GError **error UNUSED) {
|
|
|
aa2a27 |
gchar *ret = NULL;
|
|
|
aa2a27 |
|
|
|
aa2a27 |
g_mutex_lock (&global_config_lock);
|
|
|
aa2a27 |
@@ -2027,7 +2027,7 @@ gchar* bd_lvm_get_global_config (GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Tech category: %BD_LVM_TECH_CACHE_CALCS no mode (it is ignored)
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error UNUSED) {
|
|
|
aa2a27 |
return MAX ((guint64) cache_size / 1000, BD_LVM_MIN_CACHE_MD_SIZE);
|
|
|
aa2a27 |
}
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@@ -2037,7 +2037,7 @@ guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error __a
|
|
|
aa2a27 |
*
|
|
|
aa2a27 |
* Get LV type string from flags.
|
|
|
aa2a27 |
*/
|
|
|
aa2a27 |
-static const gchar* get_lv_type_from_flags (BDLVMCachePoolFlags flags, gboolean meta, GError **error __attribute__((unused))) {
|
|
|
aa2a27 |
+static const gchar* get_lv_type_from_flags (BDLVMCachePoolFlags flags, gboolean meta, GError **error UNUSED) {
|
|
|
aa2a27 |
if (!meta) {
|
|
|
aa2a27 |
if (flags & BD_LVM_CACHE_POOL_STRIPED)
|
|
|
aa2a27 |
return "striped";
|
|
|
aa2a27 |
|
|
|
aa2a27 |
From f106e775d3c73e5f97512dd109627e00539b703a Mon Sep 17 00:00:00 2001
|
|
|
aa2a27 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
aa2a27 |
Date: Tue, 15 Dec 2020 14:53:13 +0100
|
|
|
aa2a27 |
Subject: [PATCH 5/5] Fix max size limit for LVM thinpool metadata
|
|
|
aa2a27 |
|
|
|
aa2a27 |
DM_THIN_MAX_METADATA_SIZE is in 512 sectors, not in KiB so the
|
|
|
aa2a27 |
upper limit is 15.81 GiB not 31.62 GiB
|
|
|
aa2a27 |
---
|
|
|
aa2a27 |
src/lib/plugin_apis/lvm.api | 2 +-
|
|
|
aa2a27 |
src/plugins/lvm.h | 10 ++++++----
|
|
|
aa2a27 |
tests/lvm_dbus_tests.py | 3 ++-
|
|
|
aa2a27 |
tests/lvm_test.py | 3 ++-
|
|
|
aa2a27 |
4 files changed, 11 insertions(+), 7 deletions(-)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
index 9f25c1ed..563c1041 100644
|
|
|
aa2a27 |
--- a/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
+++ b/src/lib/plugin_apis/lvm.api
|
|
|
aa2a27 |
@@ -20,7 +20,7 @@
|
|
|
aa2a27 |
#define BD_LVM_MIN_PE_SIZE G_GUINT64_CONSTANT (1024ULL) // 1 KiB
|
|
|
aa2a27 |
#define BD_LVM_MAX_PE_SIZE G_GUINT64_CONSTANT (17179869184ULL) // 16 GiB
|
|
|
aa2a27 |
#define BD_LVM_MIN_THPOOL_MD_SIZE G_GUINT64_CONSTANT (4194304ULL) // 4 MiB
|
|
|
aa2a27 |
-#define BD_LVM_MAX_THPOOL_MD_SIZE G_GUINT64_CONSTANT (33957085184ULL) // 31.62 GiB
|
|
|
aa2a27 |
+#define BD_LVM_MAX_THPOOL_MD_SIZE G_GUINT64_CONSTANT (16978542592ULL) // 15.81 GiB
|
|
|
aa2a27 |
#define BD_LVM_MIN_THPOOL_CHUNK_SIZE G_GUINT64_CONSTANT (65536ULL) // 64 KiB
|
|
|
aa2a27 |
#define BD_LVM_MAX_THPOOL_CHUNK_SIZE G_GUINT64_CONSTANT (1073741824ULL) // 1 GiB
|
|
|
aa2a27 |
#define BD_LVM_DEFAULT_CHUNK_SIZE G_GUINT64_CONSTANT (65536ULL) // 64 KiB
|
|
|
aa2a27 |
diff --git a/src/plugins/lvm.h b/src/plugins/lvm.h
|
|
|
aa2a27 |
index 01c06ca4..2162d769 100644
|
|
|
aa2a27 |
--- a/src/plugins/lvm.h
|
|
|
aa2a27 |
+++ b/src/plugins/lvm.h
|
|
|
aa2a27 |
@@ -22,11 +22,13 @@
|
|
|
aa2a27 |
#define USE_DEFAULT_PE_SIZE 0
|
|
|
aa2a27 |
#define RESOLVE_PE_SIZE(size) ((size) == USE_DEFAULT_PE_SIZE ? BD_LVM_DEFAULT_PE_SIZE : (size))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
-/* lvm constants for thin pool metadata size are actually half of these
|
|
|
aa2a27 |
- but when they calculate the actual metadata size they double the limits
|
|
|
aa2a27 |
- so lets just double the limits here too */
|
|
|
aa2a27 |
+/* lvm constant for thin pool metadata size is actually half of this
|
|
|
aa2a27 |
+ but when they calculate the actual metadata size they double the limit
|
|
|
aa2a27 |
+ so lets just double the limit here too */
|
|
|
aa2a27 |
#define BD_LVM_MIN_THPOOL_MD_SIZE (4 MiB)
|
|
|
aa2a27 |
-#define BD_LVM_MAX_THPOOL_MD_SIZE (DM_THIN_MAX_METADATA_SIZE KiB)
|
|
|
aa2a27 |
+
|
|
|
aa2a27 |
+/* DM_THIN_MAX_METADATA_SIZE is in 512 sectors */
|
|
|
aa2a27 |
+#define BD_LVM_MAX_THPOOL_MD_SIZE (DM_THIN_MAX_METADATA_SIZE * 512)
|
|
|
aa2a27 |
|
|
|
aa2a27 |
#define BD_LVM_MIN_THPOOL_CHUNK_SIZE (64 KiB)
|
|
|
aa2a27 |
#define BD_LVM_MAX_THPOOL_CHUNK_SIZE (1 GiB)
|
|
|
aa2a27 |
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
index c06a480c..8f2bb95d 100644
|
|
|
aa2a27 |
--- a/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
+++ b/tests/lvm_dbus_tests.py
|
|
|
aa2a27 |
@@ -160,10 +160,11 @@ def test_is_valid_thpool_md_size(self):
|
|
|
aa2a27 |
|
|
|
aa2a27 |
self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(4 * 1024**2))
|
|
|
aa2a27 |
self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(5 * 1024**2))
|
|
|
aa2a27 |
- self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(16 * 1024**3))
|
|
|
aa2a27 |
+ self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(15 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(1 * 1024**2))
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(3 * 1024**2))
|
|
|
aa2a27 |
+ self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(16 * 1024**3))
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(32 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@tag_test(TestTags.NOSTORAGE)
|
|
|
aa2a27 |
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
|
|
|
aa2a27 |
index b84adece..6f80a3ba 100644
|
|
|
aa2a27 |
--- a/tests/lvm_test.py
|
|
|
aa2a27 |
+++ b/tests/lvm_test.py
|
|
|
aa2a27 |
@@ -150,10 +150,11 @@ def test_is_valid_thpool_md_size(self):
|
|
|
aa2a27 |
|
|
|
aa2a27 |
self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(4 * 1024**2))
|
|
|
aa2a27 |
self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(5 * 1024**2))
|
|
|
aa2a27 |
- self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(16 * 1024**3))
|
|
|
aa2a27 |
+ self.assertTrue(BlockDev.lvm_is_valid_thpool_md_size(15 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(1 * 1024**2))
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(3 * 1024**2))
|
|
|
aa2a27 |
+ self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(16 * 1024**3))
|
|
|
aa2a27 |
self.assertFalse(BlockDev.lvm_is_valid_thpool_md_size(32 * 1024**3))
|
|
|
aa2a27 |
|
|
|
aa2a27 |
@tag_test(TestTags.NOSTORAGE)
|