|
|
6871a2 |
From 9bcaddbe97067f10e643a7d99fa13716126f6e60 Mon Sep 17 00:00:00 2001
|
|
|
6871a2 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
6871a2 |
Date: Tue, 25 Aug 2020 14:09:18 +0200
|
|
|
6871a2 |
Subject: [PATCH 1/4] mdraid: Do not ignore errors from bd_md_canonicalize_uuid
|
|
|
6871a2 |
in bd_md_examine
|
|
|
6871a2 |
|
|
|
6871a2 |
---
|
|
|
6871a2 |
src/plugins/mdraid.c | 12 ++++++++++++
|
|
|
6871a2 |
1 file changed, 12 insertions(+)
|
|
|
6871a2 |
|
|
|
6871a2 |
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
|
|
|
6871a2 |
index b97bc641..d41b6372 100644
|
|
|
6871a2 |
--- a/src/plugins/mdraid.c
|
|
|
6871a2 |
+++ b/src/plugins/mdraid.c
|
|
|
6871a2 |
@@ -983,12 +983,24 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) {
|
|
|
6871a2 |
orig_data = ret->uuid;
|
|
|
6871a2 |
if (orig_data) {
|
|
|
6871a2 |
ret->uuid = bd_md_canonicalize_uuid (orig_data, error);
|
|
|
6871a2 |
+ if (!ret->uuid) {
|
|
|
6871a2 |
+ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data);
|
|
|
6871a2 |
+ g_free (orig_data);
|
|
|
6871a2 |
+ bd_md_examine_data_free (ret);
|
|
|
6871a2 |
+ return NULL;
|
|
|
6871a2 |
+ }
|
|
|
6871a2 |
g_free (orig_data);
|
|
|
6871a2 |
}
|
|
|
6871a2 |
|
|
|
6871a2 |
orig_data = ret->dev_uuid;
|
|
|
6871a2 |
if (orig_data) {
|
|
|
6871a2 |
ret->dev_uuid = bd_md_canonicalize_uuid (orig_data, error);
|
|
|
6871a2 |
+ if (!ret->uuid) {
|
|
|
6871a2 |
+ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data);
|
|
|
6871a2 |
+ g_free (orig_data);
|
|
|
6871a2 |
+ bd_md_examine_data_free (ret);
|
|
|
6871a2 |
+ return NULL;
|
|
|
6871a2 |
+ }
|
|
|
6871a2 |
g_free (orig_data);
|
|
|
6871a2 |
}
|
|
|
6871a2 |
|
|
|
6871a2 |
--
|
|
|
6871a2 |
2.37.1
|
|
|
6871a2 |
|
|
|
6871a2 |
|
|
|
6871a2 |
From 1805734e8315d5fb73f036dae043312c88f3c3ec Mon Sep 17 00:00:00 2001
|
|
|
6871a2 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
6871a2 |
Date: Tue, 25 Aug 2020 14:12:52 +0200
|
|
|
6871a2 |
Subject: [PATCH 2/4] mdraid: Try harder to get container UUID in bd_md_examine
|
|
|
6871a2 |
|
|
|
6871a2 |
For containers UUID is not printed in 'mdadm --examine' but it is
|
|
|
6871a2 |
printed when using the '--export' option.
|
|
|
6871a2 |
---
|
|
|
6871a2 |
src/plugins/mdraid.c | 11 +++++++++++
|
|
|
6871a2 |
1 file changed, 11 insertions(+)
|
|
|
6871a2 |
|
|
|
6871a2 |
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
|
|
|
6871a2 |
index d41b6372..3a23cf2e 100644
|
|
|
6871a2 |
--- a/src/plugins/mdraid.c
|
|
|
6871a2 |
+++ b/src/plugins/mdraid.c
|
|
|
6871a2 |
@@ -1023,6 +1023,17 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) {
|
|
|
6871a2 |
value++;
|
|
|
6871a2 |
g_free (ret->level);
|
|
|
6871a2 |
ret->level = g_strdup (value);
|
|
|
6871a2 |
+ } else if (!ret->uuid && g_str_has_prefix (output_fields[i], "MD_UUID=")) {
|
|
|
6871a2 |
+ value = strchr (output_fields[i], '=');
|
|
|
6871a2 |
+ value++;
|
|
|
6871a2 |
+ ret->uuid = bd_md_canonicalize_uuid (value, error);
|
|
|
6871a2 |
+ if (!ret->uuid) {
|
|
|
6871a2 |
+ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data);
|
|
|
6871a2 |
+ g_free (orig_data);
|
|
|
6871a2 |
+ bd_md_examine_data_free (ret);
|
|
|
6871a2 |
+ g_strfreev (output_fields);
|
|
|
6871a2 |
+ return NULL;
|
|
|
6871a2 |
+ }
|
|
|
6871a2 |
}
|
|
|
6871a2 |
g_strfreev (output_fields);
|
|
|
6871a2 |
|
|
|
6871a2 |
--
|
|
|
6871a2 |
2.37.1
|
|
|
6871a2 |
|
|
|
6871a2 |
|
|
|
6871a2 |
From 166756338f90d90b32ae0989db706dd52f7df234 Mon Sep 17 00:00:00 2001
|
|
|
6871a2 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
6871a2 |
Date: Thu, 4 Aug 2022 12:47:53 +0200
|
|
|
6871a2 |
Subject: [PATCH 3/4] mdraid: Try harder to get container UUID in bd_md_detail
|
|
|
6871a2 |
|
|
|
6871a2 |
Similarly to bd_md_examine (see a10ad4e0), "mdadm --detail"
|
|
|
6871a2 |
doesn't contain container UUID, we need to need "--export" for
|
|
|
6871a2 |
that.
|
|
|
6871a2 |
---
|
|
|
6871a2 |
src/plugins/mdraid.c | 43 +++++++++++++++++++++++++++++++++++--------
|
|
|
6871a2 |
1 file changed, 35 insertions(+), 8 deletions(-)
|
|
|
6871a2 |
|
|
|
6871a2 |
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
|
|
|
6871a2 |
index 3a23cf2e..67bdc1f9 100644
|
|
|
6871a2 |
--- a/src/plugins/mdraid.c
|
|
|
6871a2 |
+++ b/src/plugins/mdraid.c
|
|
|
6871a2 |
@@ -1093,13 +1093,16 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) {
|
|
|
6871a2 |
* Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY
|
|
|
6871a2 |
*/
|
|
|
6871a2 |
BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) {
|
|
|
6871a2 |
- const gchar *argv[] = {"mdadm", "--detail", NULL, NULL};
|
|
|
6871a2 |
+ const gchar *argv[] = {"mdadm", "--detail", NULL, NULL, NULL};
|
|
|
6871a2 |
gchar *output = NULL;
|
|
|
6871a2 |
gboolean success = FALSE;
|
|
|
6871a2 |
GHashTable *table = NULL;
|
|
|
6871a2 |
guint num_items = 0;
|
|
|
6871a2 |
gchar *orig_uuid = NULL;
|
|
|
6871a2 |
- gchar *mdadm_spec = NULL;
|
|
|
6871a2 |
+ g_autofree gchar *mdadm_spec = NULL;
|
|
|
6871a2 |
+ gchar *value = NULL;
|
|
|
6871a2 |
+ gchar **output_fields = NULL;
|
|
|
6871a2 |
+ guint i = 0;
|
|
|
6871a2 |
BDMDDetailData *ret = NULL;
|
|
|
6871a2 |
|
|
|
6871a2 |
if (!check_deps (&avail_deps, DEPS_MDADM_MASK, deps, DEPS_LAST, &deps_check_lock, error))
|
|
|
6871a2 |
@@ -1113,16 +1116,13 @@ BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) {
|
|
|
6871a2 |
argv[2] = mdadm_spec;
|
|
|
6871a2 |
|
|
|
6871a2 |
success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
|
|
|
6871a2 |
- if (!success) {
|
|
|
6871a2 |
- g_free (mdadm_spec);
|
|
|
6871a2 |
+ if (!success)
|
|
|
6871a2 |
/* error is already populated */
|
|
|
6871a2 |
return NULL;
|
|
|
6871a2 |
- }
|
|
|
6871a2 |
|
|
|
6871a2 |
table = parse_mdadm_vars (output, "\n", ":", &num_items);
|
|
|
6871a2 |
g_free (output);
|
|
|
6871a2 |
if (!table || (num_items == 0)) {
|
|
|
6871a2 |
- g_free (mdadm_spec);
|
|
|
6871a2 |
/* something bad happened or some expected items were missing */
|
|
|
6871a2 |
g_set_error (error, BD_MD_ERROR, BD_MD_ERROR_PARSE, "Failed to parse mddetail data");
|
|
|
6871a2 |
if (table)
|
|
|
6871a2 |
@@ -1132,7 +1132,6 @@ BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) {
|
|
|
6871a2 |
|
|
|
6871a2 |
ret = get_detail_data_from_table (table, TRUE);
|
|
|
6871a2 |
if (!ret) {
|
|
|
6871a2 |
- g_free (mdadm_spec);
|
|
|
6871a2 |
g_set_error (error, BD_MD_ERROR, BD_MD_ERROR_PARSE, "Failed to get mddetail data");
|
|
|
6871a2 |
return NULL;
|
|
|
6871a2 |
}
|
|
|
6871a2 |
@@ -1145,7 +1144,35 @@ BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) {
|
|
|
6871a2 |
g_free (orig_uuid);
|
|
|
6871a2 |
}
|
|
|
6871a2 |
|
|
|
6871a2 |
- g_free (mdadm_spec);
|
|
|
6871a2 |
+ if (!ret->uuid) {
|
|
|
6871a2 |
+ argv[2] = "--export";
|
|
|
6871a2 |
+ argv[3] = mdadm_spec;
|
|
|
6871a2 |
+ success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
|
|
|
6871a2 |
+ if (!success) {
|
|
|
6871a2 |
+ /* error is already populated */
|
|
|
6871a2 |
+ bd_md_detail_data_free (ret);
|
|
|
6871a2 |
+ return NULL;
|
|
|
6871a2 |
+ }
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ /* try to get a better information about RAID level because it may be
|
|
|
6871a2 |
+ missing in the output without --export */
|
|
|
6871a2 |
+ output_fields = g_strsplit (output, "\n", 0);
|
|
|
6871a2 |
+ g_free (output);
|
|
|
6871a2 |
+ output = NULL;
|
|
|
6871a2 |
+ for (i = 0; (i < g_strv_length (output_fields) - 1); i++)
|
|
|
6871a2 |
+ if (g_str_has_prefix (output_fields[i], "MD_UUID=")) {
|
|
|
6871a2 |
+ value = strchr (output_fields[i], '=');
|
|
|
6871a2 |
+ value++;
|
|
|
6871a2 |
+ ret->uuid = bd_md_canonicalize_uuid (value, error);
|
|
|
6871a2 |
+ if (!ret->uuid) {
|
|
|
6871a2 |
+ g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", value);
|
|
|
6871a2 |
+ bd_md_detail_data_free (ret);
|
|
|
6871a2 |
+ g_strfreev (output_fields);
|
|
|
6871a2 |
+ return NULL;
|
|
|
6871a2 |
+ }
|
|
|
6871a2 |
+ }
|
|
|
6871a2 |
+ g_strfreev (output_fields);
|
|
|
6871a2 |
+ }
|
|
|
6871a2 |
|
|
|
6871a2 |
return ret;
|
|
|
6871a2 |
}
|
|
|
6871a2 |
--
|
|
|
6871a2 |
2.37.1
|
|
|
6871a2 |
|
|
|
6871a2 |
|
|
|
6871a2 |
From 25dd2f8c7cc3cf540902fc40e808faabda3c691a Mon Sep 17 00:00:00 2001
|
|
|
6871a2 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
6871a2 |
Date: Thu, 4 Aug 2022 12:51:48 +0200
|
|
|
6871a2 |
Subject: [PATCH 4/4] Add a test case for DDF arrays/containers
|
|
|
6871a2 |
|
|
|
6871a2 |
---
|
|
|
6871a2 |
tests/mdraid_test.py | 51 ++++++++++++++++++++++++++++++++++++++++----
|
|
|
6871a2 |
1 file changed, 47 insertions(+), 4 deletions(-)
|
|
|
6871a2 |
|
|
|
6871a2 |
diff --git a/tests/mdraid_test.py b/tests/mdraid_test.py
|
|
|
6871a2 |
index 0b2bdc9b..38f43a0d 100644
|
|
|
6871a2 |
--- a/tests/mdraid_test.py
|
|
|
6871a2 |
+++ b/tests/mdraid_test.py
|
|
|
6871a2 |
@@ -6,7 +6,7 @@ from contextlib import contextmanager
|
|
|
6871a2 |
import overrides_hack
|
|
|
6871a2 |
import six
|
|
|
6871a2 |
|
|
|
6871a2 |
-from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test
|
|
|
6871a2 |
+from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, run_command
|
|
|
6871a2 |
from gi.repository import BlockDev, GLib
|
|
|
6871a2 |
|
|
|
6871a2 |
|
|
|
6871a2 |
@@ -90,14 +90,16 @@ class MDNoDevTestCase(MDTest):
|
|
|
6871a2 |
|
|
|
6871a2 |
class MDTestCase(MDTest):
|
|
|
6871a2 |
|
|
|
6871a2 |
+ _sparse_size = 10 * 1024**2
|
|
|
6871a2 |
+
|
|
|
6871a2 |
def setUp(self):
|
|
|
6871a2 |
if os.uname()[-1] == "i686":
|
|
|
6871a2 |
self.skipTest("Skipping hanging MD RAID tests on i686")
|
|
|
6871a2 |
|
|
|
6871a2 |
self.addCleanup(self._clean_up)
|
|
|
6871a2 |
- self.dev_file = create_sparse_tempfile("md_test", 10 * 1024**2)
|
|
|
6871a2 |
- self.dev_file2 = create_sparse_tempfile("md_test", 10 * 1024**2)
|
|
|
6871a2 |
- self.dev_file3 = create_sparse_tempfile("md_test", 10 * 1024**2)
|
|
|
6871a2 |
+ self.dev_file = create_sparse_tempfile("md_test", self._sparse_size)
|
|
|
6871a2 |
+ self.dev_file2 = create_sparse_tempfile("md_test", self._sparse_size)
|
|
|
6871a2 |
+ self.dev_file3 = create_sparse_tempfile("md_test", self._sparse_size)
|
|
|
6871a2 |
|
|
|
6871a2 |
try:
|
|
|
6871a2 |
self.loop_dev = create_lio_device(self.dev_file)
|
|
|
6871a2 |
@@ -586,6 +588,47 @@ class MDTestRequestSyncAction(MDTestCase):
|
|
|
6871a2 |
action = f.read().strip()
|
|
|
6871a2 |
self.assertEqual(action, "check")
|
|
|
6871a2 |
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+class MDTestDDFRAID(MDTestCase):
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ _sparse_size = 50 * 1024**2
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ def _clean_up(self):
|
|
|
6871a2 |
+ try:
|
|
|
6871a2 |
+ BlockDev.md_deactivate("bd_test_ddf")
|
|
|
6871a2 |
+ except:
|
|
|
6871a2 |
+ pass
|
|
|
6871a2 |
+ try:
|
|
|
6871a2 |
+ BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_ddf"))
|
|
|
6871a2 |
+ except:
|
|
|
6871a2 |
+ pass
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ super(MDTestDDFRAID, self)._clean_up()
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ def test_examine_ddf_container(self):
|
|
|
6871a2 |
+ succ = BlockDev.md_create("bd_test_md", "container",
|
|
|
6871a2 |
+ [self.loop_dev, self.loop_dev2],
|
|
|
6871a2 |
+ 0, "ddf", False)
|
|
|
6871a2 |
+ self.assertTrue(succ)
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ # we cannot create the array with libblockdev because we cannot pass the --raid-devices option
|
|
|
6871a2 |
+ ret, _out, err = run_command("mdadm --create /dev/md/bd_test_ddf --run --level=raid0 --raid-devices=2 /dev/md/bd_test_md")
|
|
|
6871a2 |
+ self.assertEqual(ret, 0, msg="Failed to create RAID for DDF test: %s" % err)
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ edata = BlockDev.md_examine(self.loop_dev)
|
|
|
6871a2 |
+ self.assertIsNotNone(edata)
|
|
|
6871a2 |
+ self.assertIsNotNone(edata.uuid)
|
|
|
6871a2 |
+ self.assertEqual(edata.level, "container")
|
|
|
6871a2 |
+ self.assertEqual(edata.metadata, "ddf")
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+ ddata = BlockDev.md_detail("bd_test_md")
|
|
|
6871a2 |
+ self.assertIsNotNone(ddata)
|
|
|
6871a2 |
+ self.assertIsNotNone(ddata.uuid)
|
|
|
6871a2 |
+ self.assertEqual(ddata.uuid, edata.uuid)
|
|
|
6871a2 |
+ self.assertEqual(ddata.level, "container")
|
|
|
6871a2 |
+ self.assertEqual(ddata.metadata, "ddf")
|
|
|
6871a2 |
+
|
|
|
6871a2 |
+
|
|
|
6871a2 |
class FakeMDADMutilTest(MDTest):
|
|
|
6871a2 |
# no setUp nor tearDown needed, we are gonna use fake utils
|
|
|
6871a2 |
@tag_test(TestTags.NOSTORAGE)
|
|
|
6871a2 |
--
|
|
|
6871a2 |
2.37.1
|
|
|
6871a2 |
|