diff --git a/SOURCES/0012-tests-Lower-expected-free-space-on-newly-created-Ext-filesystems.patch b/SOURCES/0012-tests-Lower-expected-free-space-on-newly-created-Ext-filesystems.patch new file mode 100644 index 0000000..66b5999 --- /dev/null +++ b/SOURCES/0012-tests-Lower-expected-free-space-on-newly-created-Ext-filesystems.patch @@ -0,0 +1,71 @@ +From 8978b7e6913f904bea887b0c542f9f82c969c2cf Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 1 Sep 2021 11:36:29 +0200 +Subject: [PATCH] tests: Lower expected free space on newly created Ext + filesystems + +With e2fsprogs 1.46.4 we now see less than 90 % of free blocks on +newly created devices in our tests. +--- + tests/fs_test.py | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/tests/fs_test.py b/tests/fs_test.py +index 551b6a7b..6b0134bf 100644 +--- a/tests/fs_test.py ++++ b/tests/fs_test.py +@@ -425,8 +425,8 @@ def _test_ext_get_info(self, mkfs_function, info_function): + self.assertTrue(fi) + self.assertEqual(fi.block_size, 1024) + self.assertEqual(fi.block_count, 100 * 1024**2 / 1024) +- # at least 90 % should be available, so it should be reported +- self.assertGreater(fi.free_blocks, 0.90 * 100 * 1024**2 / 1024) ++ # at least 80 % should be available, so it should be reported ++ self.assertGreater(fi.free_blocks, 0.80 * 100 * 1024**2 / 1024) + self.assertEqual(fi.label, "") + # should be an non-empty string + self.assertTrue(fi.uuid) +@@ -436,8 +436,8 @@ def _test_ext_get_info(self, mkfs_function, info_function): + fi = BlockDev.fs_ext4_get_info(self.loop_dev) + self.assertEqual(fi.block_size, 1024) + self.assertEqual(fi.block_count, 100 * 1024**2 / 1024) +- # at least 90 % should be available, so it should be reported +- self.assertGreater(fi.free_blocks, 0.90 * 100 * 1024**2 / 1024) ++ # at least 80 % should be available, so it should be reported ++ self.assertGreater(fi.free_blocks, 0.80 * 100 * 1024**2 / 1024) + self.assertEqual(fi.label, "") + # should be an non-empty string + self.assertTrue(fi.uuid) +@@ -515,8 +515,8 @@ def _test_ext_resize(self, mkfs_function, info_function, resize_function): + self.assertTrue(fi) + self.assertEqual(fi.block_size, 1024) + self.assertEqual(fi.block_count, 100 * 1024**2 / 1024) +- # at least 90 % should be available, so it should be reported +- self.assertGreater(fi.free_blocks, 0.90 * 100 * 1024**2 / 1024) ++ # at least 80 % should be available, so it should be reported ++ self.assertGreater(fi.free_blocks, 0.80 * 100 * 1024**2 / 1024) + + succ = resize_function(self.loop_dev, 50 * 1024**2, None) + self.assertTrue(succ) +@@ -532,8 +532,8 @@ def _test_ext_resize(self, mkfs_function, info_function, resize_function): + self.assertTrue(fi) + self.assertEqual(fi.block_size, 1024) + self.assertEqual(fi.block_count, 100 * 1024**2 / 1024) +- # at least 90 % should be available, so it should be reported +- self.assertGreater(fi.free_blocks, 0.90 * 100 * 1024**2 / 1024) ++ # at least 80 % should be available, so it should be reported ++ self.assertGreater(fi.free_blocks, 0.80 * 100 * 1024**2 / 1024) + + # resize again + succ = resize_function(self.loop_dev, 50 * 1024**2, None) +@@ -550,8 +550,8 @@ def _test_ext_resize(self, mkfs_function, info_function, resize_function): + self.assertTrue(fi) + self.assertEqual(fi.block_size, 1024) + self.assertEqual(fi.block_count, 100 * 1024**2 / 1024) +- # at least 90 % should be available, so it should be reported +- self.assertGreater(fi.free_blocks, 0.90 * 100 * 1024**2 / 1024) ++ # at least 80 % should be available, so it should be reported ++ self.assertGreater(fi.free_blocks, 0.80 * 100 * 1024**2 / 1024) + + def test_ext2_resize(self): + """Verify that it is possible to resize an ext2 file system""" diff --git a/SOURCES/0013-ddf-mdadm-uuid-parse-fix.patch b/SOURCES/0013-ddf-mdadm-uuid-parse-fix.patch new file mode 100644 index 0000000..7206cee --- /dev/null +++ b/SOURCES/0013-ddf-mdadm-uuid-parse-fix.patch @@ -0,0 +1,275 @@ +From 9bcaddbe97067f10e643a7d99fa13716126f6e60 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 25 Aug 2020 14:09:18 +0200 +Subject: [PATCH 1/4] mdraid: Do not ignore errors from bd_md_canonicalize_uuid + in bd_md_examine + +--- + src/plugins/mdraid.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index b97bc641..d41b6372 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -983,12 +983,24 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) { + orig_data = ret->uuid; + if (orig_data) { + ret->uuid = bd_md_canonicalize_uuid (orig_data, error); ++ if (!ret->uuid) { ++ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data); ++ g_free (orig_data); ++ bd_md_examine_data_free (ret); ++ return NULL; ++ } + g_free (orig_data); + } + + orig_data = ret->dev_uuid; + if (orig_data) { + ret->dev_uuid = bd_md_canonicalize_uuid (orig_data, error); ++ if (!ret->uuid) { ++ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data); ++ g_free (orig_data); ++ bd_md_examine_data_free (ret); ++ return NULL; ++ } + g_free (orig_data); + } + +-- +2.37.1 + + +From 1805734e8315d5fb73f036dae043312c88f3c3ec Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 25 Aug 2020 14:12:52 +0200 +Subject: [PATCH 2/4] mdraid: Try harder to get container UUID in bd_md_examine + +For containers UUID is not printed in 'mdadm --examine' but it is +printed when using the '--export' option. +--- + src/plugins/mdraid.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index d41b6372..3a23cf2e 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -1023,6 +1023,17 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) { + value++; + g_free (ret->level); + ret->level = g_strdup (value); ++ } else if (!ret->uuid && g_str_has_prefix (output_fields[i], "MD_UUID=")) { ++ value = strchr (output_fields[i], '='); ++ value++; ++ ret->uuid = bd_md_canonicalize_uuid (value, error); ++ if (!ret->uuid) { ++ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data); ++ g_free (orig_data); ++ bd_md_examine_data_free (ret); ++ g_strfreev (output_fields); ++ return NULL; ++ } + } + g_strfreev (output_fields); + +-- +2.37.1 + + +From 166756338f90d90b32ae0989db706dd52f7df234 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 4 Aug 2022 12:47:53 +0200 +Subject: [PATCH 3/4] mdraid: Try harder to get container UUID in bd_md_detail + +Similarly to bd_md_examine (see a10ad4e0), "mdadm --detail" +doesn't contain container UUID, we need to need "--export" for +that. +--- + src/plugins/mdraid.c | 43 +++++++++++++++++++++++++++++++++++-------- + 1 file changed, 35 insertions(+), 8 deletions(-) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index 3a23cf2e..67bdc1f9 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -1093,13 +1093,16 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) { + * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY + */ + BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) { +- const gchar *argv[] = {"mdadm", "--detail", NULL, NULL}; ++ const gchar *argv[] = {"mdadm", "--detail", NULL, NULL, NULL}; + gchar *output = NULL; + gboolean success = FALSE; + GHashTable *table = NULL; + guint num_items = 0; + gchar *orig_uuid = NULL; +- gchar *mdadm_spec = NULL; ++ g_autofree gchar *mdadm_spec = NULL; ++ gchar *value = NULL; ++ gchar **output_fields = NULL; ++ guint i = 0; + BDMDDetailData *ret = NULL; + + if (!check_deps (&avail_deps, DEPS_MDADM_MASK, deps, DEPS_LAST, &deps_check_lock, error)) +@@ -1113,16 +1116,13 @@ BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) { + argv[2] = mdadm_spec; + + success = bd_utils_exec_and_capture_output (argv, NULL, &output, error); +- if (!success) { +- g_free (mdadm_spec); ++ if (!success) + /* error is already populated */ + return NULL; +- } + + table = parse_mdadm_vars (output, "\n", ":", &num_items); + g_free (output); + if (!table || (num_items == 0)) { +- g_free (mdadm_spec); + /* something bad happened or some expected items were missing */ + g_set_error (error, BD_MD_ERROR, BD_MD_ERROR_PARSE, "Failed to parse mddetail data"); + if (table) +@@ -1132,7 +1132,6 @@ BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) { + + ret = get_detail_data_from_table (table, TRUE); + if (!ret) { +- g_free (mdadm_spec); + g_set_error (error, BD_MD_ERROR, BD_MD_ERROR_PARSE, "Failed to get mddetail data"); + return NULL; + } +@@ -1145,7 +1144,35 @@ BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) { + g_free (orig_uuid); + } + +- g_free (mdadm_spec); ++ if (!ret->uuid) { ++ argv[2] = "--export"; ++ argv[3] = mdadm_spec; ++ success = bd_utils_exec_and_capture_output (argv, NULL, &output, error); ++ if (!success) { ++ /* error is already populated */ ++ bd_md_detail_data_free (ret); ++ return NULL; ++ } ++ ++ /* try to get a better information about RAID level because it may be ++ missing in the output without --export */ ++ output_fields = g_strsplit (output, "\n", 0); ++ g_free (output); ++ output = NULL; ++ for (i = 0; (i < g_strv_length (output_fields) - 1); i++) ++ if (g_str_has_prefix (output_fields[i], "MD_UUID=")) { ++ value = strchr (output_fields[i], '='); ++ value++; ++ ret->uuid = bd_md_canonicalize_uuid (value, error); ++ if (!ret->uuid) { ++ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", value); ++ bd_md_detail_data_free (ret); ++ g_strfreev (output_fields); ++ return NULL; ++ } ++ } ++ g_strfreev (output_fields); ++ } + + return ret; + } +-- +2.37.1 + + +From 25dd2f8c7cc3cf540902fc40e808faabda3c691a Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 4 Aug 2022 12:51:48 +0200 +Subject: [PATCH 4/4] Add a test case for DDF arrays/containers + +--- + tests/mdraid_test.py | 51 ++++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 47 insertions(+), 4 deletions(-) + +diff --git a/tests/mdraid_test.py b/tests/mdraid_test.py +index 0b2bdc9b..38f43a0d 100644 +--- a/tests/mdraid_test.py ++++ b/tests/mdraid_test.py +@@ -6,7 +6,7 @@ from contextlib import contextmanager + import overrides_hack + import six + +-from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test ++from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, run_command + from gi.repository import BlockDev, GLib + + +@@ -90,14 +90,16 @@ class MDNoDevTestCase(MDTest): + + class MDTestCase(MDTest): + ++ _sparse_size = 10 * 1024**2 ++ + def setUp(self): + if os.uname()[-1] == "i686": + self.skipTest("Skipping hanging MD RAID tests on i686") + + self.addCleanup(self._clean_up) +- self.dev_file = create_sparse_tempfile("md_test", 10 * 1024**2) +- self.dev_file2 = create_sparse_tempfile("md_test", 10 * 1024**2) +- self.dev_file3 = create_sparse_tempfile("md_test", 10 * 1024**2) ++ self.dev_file = create_sparse_tempfile("md_test", self._sparse_size) ++ self.dev_file2 = create_sparse_tempfile("md_test", self._sparse_size) ++ self.dev_file3 = create_sparse_tempfile("md_test", self._sparse_size) + + try: + self.loop_dev = create_lio_device(self.dev_file) +@@ -586,6 +588,47 @@ class MDTestRequestSyncAction(MDTestCase): + action = f.read().strip() + self.assertEqual(action, "check") + ++ ++class MDTestDDFRAID(MDTestCase): ++ ++ _sparse_size = 50 * 1024**2 ++ ++ def _clean_up(self): ++ try: ++ BlockDev.md_deactivate("bd_test_ddf") ++ except: ++ pass ++ try: ++ BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_ddf")) ++ except: ++ pass ++ ++ super(MDTestDDFRAID, self)._clean_up() ++ ++ def test_examine_ddf_container(self): ++ succ = BlockDev.md_create("bd_test_md", "container", ++ [self.loop_dev, self.loop_dev2], ++ 0, "ddf", False) ++ self.assertTrue(succ) ++ ++ # we cannot create the array with libblockdev because we cannot pass the --raid-devices option ++ ret, _out, err = run_command("mdadm --create /dev/md/bd_test_ddf --run --level=raid0 --raid-devices=2 /dev/md/bd_test_md") ++ self.assertEqual(ret, 0, msg="Failed to create RAID for DDF test: %s" % err) ++ ++ edata = BlockDev.md_examine(self.loop_dev) ++ self.assertIsNotNone(edata) ++ self.assertIsNotNone(edata.uuid) ++ self.assertEqual(edata.level, "container") ++ self.assertEqual(edata.metadata, "ddf") ++ ++ ddata = BlockDev.md_detail("bd_test_md") ++ self.assertIsNotNone(ddata) ++ self.assertIsNotNone(ddata.uuid) ++ self.assertEqual(ddata.uuid, edata.uuid) ++ self.assertEqual(ddata.level, "container") ++ self.assertEqual(ddata.metadata, "ddf") ++ ++ + class FakeMDADMutilTest(MDTest): + # no setUp nor tearDown needed, we are gonna use fake utils + @tag_test(TestTags.NOSTORAGE) +-- +2.37.1 + diff --git a/SOURCES/0014-mdraid-Fix-copy-paste-error-when-checking-return-val.patch b/SOURCES/0014-mdraid-Fix-copy-paste-error-when-checking-return-val.patch new file mode 100644 index 0000000..5ff61dc --- /dev/null +++ b/SOURCES/0014-mdraid-Fix-copy-paste-error-when-checking-return-val.patch @@ -0,0 +1,53 @@ +From 04a8baf87820d8a13926e0b8db5cfa55f9f04420 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:26:57 +0200 +Subject: [PATCH 1/2] mdraid: Fix copy-paste error when checking return value + +--- + src/plugins/mdraid.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index 67bdc1f9..48abb72f 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -995,7 +995,7 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) { + orig_data = ret->dev_uuid; + if (orig_data) { + ret->dev_uuid = bd_md_canonicalize_uuid (orig_data, error); +- if (!ret->uuid) { ++ if (!ret->dev_uuid) { + g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data); + g_free (orig_data); + bd_md_examine_data_free (ret); +-- +2.37.1 + + +From 16a34bc5ddb19bc6dd1a845d87e8b748cbaedd2c Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:41:20 +0200 +Subject: [PATCH 2/2] mdraid: Fix use after free + +Another copy-paste error. +--- + src/plugins/mdraid.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index 48abb72f..75143ea7 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -1028,8 +1028,7 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) { + value++; + ret->uuid = bd_md_canonicalize_uuid (value, error); + if (!ret->uuid) { +- g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data); +- g_free (orig_data); ++ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", value); + bd_md_examine_data_free (ret); + g_strfreev (output_fields); + return NULL; +-- +2.37.1 + diff --git a/SOURCES/0015-tests-Fix-expected-extended-partition-flags-with-new.patch b/SOURCES/0015-tests-Fix-expected-extended-partition-flags-with-new.patch new file mode 100644 index 0000000..6acdd26 --- /dev/null +++ b/SOURCES/0015-tests-Fix-expected-extended-partition-flags-with-new.patch @@ -0,0 +1,45 @@ +From 33b1cda56fdc76fdf96fe409f0308e1913965d16 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 26 May 2022 12:44:47 +0200 +Subject: [PATCH] tests: Fix expected extended partition flags with new parted + +Latest libparted now creates all extended partitions as +PARTITION_EXT_LBA with the lba flag enabled by default. +--- + tests/part_test.py | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tests/part_test.py b/tests/part_test.py +index 7408b479..762dc534 100644 +--- a/tests/part_test.py ++++ b/tests/part_test.py +@@ -356,7 +356,7 @@ class PartCreatePartFullCase(PartTestCase): + # as is the start of the first part from the start of the disk + self.assertTrue(abs(ps4.start - (ps3.start + ps3.size + 1)) < ps.start) + self.assertEqual(ps4.size, 10 * 1024**2) +- self.assertEqual(ps4.flags, 0) # no flags (combination of bit flags) ++ self.assertIn(ps4.flags, [0, 128]) # no flags or extended+lba (combination of bit flags) + + # no more primary partitions allowed in the MSDOS table + with self.assertRaises(GLib.GError): +@@ -404,7 +404,7 @@ class PartCreatePartFullCase(PartTestCase): + # as is the start of the first part from the start of the disk + self.assertTrue(abs(ps3.start - (ps2.start + ps2.size + 1)) < ps.start) + self.assertEqual(ps3.size, 30 * 1024**2) +- self.assertEqual(ps3.flags, 0) # no flags (combination of bit flags) ++ self.assertIn(ps3.flags, [0, 128]) # no flags or extended+lba (combination of bit flags) + + # the logical partition has number 5 even though the extended partition + # has number 3 +@@ -871,7 +871,7 @@ class PartGetPartByPos(PartTestCase): + # as is the start of the first part from the start of the disk + self.assertTrue(abs(ps3.start - (ps2.start + ps2.size + 1)) < ps.start) + self.assertEqual(ps3.size, 35 * 1024**2) +- self.assertEqual(ps3.flags, 0) # no flags (combination of bit flags) ++ self.assertIn(ps3.flags, [0, 128]) # no flags or extended+lba (combination of bit flags) + + # the logical partition has number 5 even though the extended partition + # has number 3 +-- +2.37.1 + diff --git a/SPECS/libblockdev.spec b/SPECS/libblockdev.spec index 9dd4ed4..328f592 100644 --- a/SPECS/libblockdev.spec +++ b/SPECS/libblockdev.spec @@ -125,7 +125,7 @@ Name: libblockdev Version: 2.25 -Release: 11%{?dist} +Release: 14%{?dist} Summary: A library for low-level manipulation with block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev @@ -142,6 +142,10 @@ Patch8: 0008-lvm-Fix-reading-statistics-for-VDO-pools-with-VDO-8.patch Patch9: 0009-vdo_stats-Default-to-100-savings-for-invalid-savings.patch Patch10: 0010-Add-support-for-creating-and-activating-integrity-de.patch Patch11: 0011-tests-Wait-for-raid-and-mirrored-LVs-to-be-synced-be.patch +Patch12: 0012-tests-Lower-expected-free-space-on-newly-created-Ext-filesystems.patch +Patch13: 0013-ddf-mdadm-uuid-parse-fix.patch +Patch14: 0014-mdraid-Fix-copy-paste-error-when-checking-return-val.patch +Patch15: 0015-tests-Fix-expected-extended-partition-flags-with-new.patch BuildRequires: make BuildRequires: glib2-devel @@ -705,6 +709,10 @@ A meta-package that pulls all the libblockdev plugins as dependencies. %patch9 -p1 %patch10 -p1 %patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 %build autoreconf -ivf @@ -1008,6 +1016,20 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %files plugins-all %changelog +* Mon Aug 08 2022 Vojtech Trefny - 2.25-14 +- tests: Fix expected extended partition flags with new parted + Related: rhbz#2109026 +- mdraid: Fix copy-paste error when checking return value + Related: rhbz#2109026 + +* Mon Aug 08 2022 Vojtech Trefny - 2.25-13 +- Fix getting UUID for DDF containers + Resolves: rhbz#2109026 + +* Wed May 11 2022 Vojtech Trefny - 2.25-12 +- tests: Lower expected free space on newly created Ext filesystems + Resolves: rhbz#2065943 + * Mon Jan 10 2022 Vojtech Trefny - 2.25-11 - tests: Wait for raid and mirrored LVs to be synced before removing Resolves: rhbz#2030647