diff --git a/libblockdev.spec b/libblockdev.spec index c4bc329..31541b6 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -64,12 +64,14 @@ Name: libblockdev Version: 2.6 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A library for low-level manipulation with block devices License: LGPLv2+ URL: https://github.com/rhinstaller/libblockdev Source0: https://github.com/rhinstaller/libblockdev/archive/%{name}-%{version}.tar.gz +Patch0: valid_thpool_md_size.patch + BuildRequires: glib2-devel BuildRequires: gobject-introspection-devel BuildRequires: python-devel @@ -517,6 +519,7 @@ A meta-package that pulls all the libblockdev plugins as dependencies. %prep %setup -q -n %{name}-%{version} +%patch0 -p1 %build %configure %{?configure_opts} @@ -786,6 +789,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %files plugins-all %changelog +* Tue Apr 11 2017 Vratislav Podzimek - 2.6-2 +- Make sure the returned thpool MD size is valid (vpodzime) + * Wed Mar 15 2017 Vratislav Podzimek - 2.6-1 - Move the part_err library before part and fs (vtrefny) - Fix BuildRequires for crypto and dm packages (vtrefny) diff --git a/valid_thpool_md_size.patch b/valid_thpool_md_size.patch new file mode 100644 index 0000000..9f59b64 --- /dev/null +++ b/valid_thpool_md_size.patch @@ -0,0 +1,75 @@ +From 2b510a862dfc120e9e5592ba15112385b6c8c371 Mon Sep 17 00:00:00 2001 +From: Vratislav Podzimek +Date: Mon, 3 Apr 2017 13:54:52 +0200 +Subject: [PATCH] Make sure the returned thpool MD size is valid + +It may be too small as given by the thin_metadata_size tool which +obviously doesn't guard for too small values. + +Signed-off-by: Vratislav Podzimek +--- + src/plugins/lvm-dbus.c | 2 +- + src/plugins/lvm.c | 2 +- + tests/lvm_dbus_tests.py | 4 ++++ + tests/lvm_test.py | 4 ++++ + 4 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index 25cb82a..86a5383 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -1097,7 +1097,7 @@ guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n + return 0; + } + +- return ret; ++ return MAX (ret, BD_LVM_MIN_THPOOL_MD_SIZE); + } + + /** +diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c +index a8acc69..21a20ba 100644 +--- a/src/plugins/lvm.c ++++ b/src/plugins/lvm.c +@@ -615,7 +615,7 @@ guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n + return 0; + } + +- return ret; ++ return MAX (ret, BD_LVM_MIN_THPOOL_MD_SIZE); + } + + /** +diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py +index 4ba93e9..998f97c 100644 +--- a/tests/lvm_dbus_tests.py ++++ b/tests/lvm_dbus_tests.py +@@ -130,6 +130,10 @@ class LvmNoDevTestCase(unittest.TestCase): + # twice the chunk_size -> roughly half the metadata needed + self.assertAlmostEqual(float(out1) / float(out2), 2, places=2) + ++ # unless thin_metadata_size gives a value that is not valid (too small) ++ self.assertEqual(BlockDev.lvm_get_thpool_meta_size (100 * 1024**2, 128 * 1024, 100), ++ BlockDev.LVM_MIN_THPOOL_MD_SIZE) ++ + def test_is_valid_thpool_md_size(self): + """Verify that is_valid_thpool_md_size works as expected""" + +diff --git a/tests/lvm_test.py b/tests/lvm_test.py +index 4879808..c7fedbd 100644 +--- a/tests/lvm_test.py ++++ b/tests/lvm_test.py +@@ -114,6 +114,10 @@ class LvmNoDevTestCase(unittest.TestCase): + # twice the chunk_size -> roughly half the metadata needed + self.assertAlmostEqual(float(out1) / float(out2), 2, places=2) + ++ # unless thin_metadata_size gives a value that is not valid (too small) ++ self.assertEqual(BlockDev.lvm_get_thpool_meta_size (100 * 1024**2, 128 * 1024, 100), ++ BlockDev.LVM_MIN_THPOOL_MD_SIZE) ++ + def test_is_valid_thpool_md_size(self): + """Verify that is_valid_thpool_md_size works as expected""" + +-- +2.9.3 +