New version
- Do not report volume name for FW RAID container device (vpodzime) - Search for just "UUID" in mdadm --examine output (vpodzime) - Use 'mdadm --examine --export' to get MD RAID level (vpodzime)
This commit is contained in:
parent
bf9216eb2f
commit
420d803e2d
@ -1,6 +1,6 @@
|
||||
Name: libblockdev
|
||||
Version: 1.9
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
Summary: A library for low-level manipulation with block devices
|
||||
License: LGPLv2+
|
||||
URL: https://github.com/rhinstaller/libblockdev
|
||||
@ -9,6 +9,9 @@ Source0: https://github.com/rhinstaller/libblockdev/archive/%{name}-%{versio
|
||||
Patch0: cast_numbers.patch
|
||||
Patch1: dbus_job_creation_timeout.patch
|
||||
Patch2: mdadm_raid_level_quirk.patch
|
||||
Patch3: mdadm_examine_export.patch
|
||||
Patch4: mdadm_examine_uuid.patch
|
||||
Patch5: mdadm_fw_raid_device.patch
|
||||
|
||||
BuildRequires: glib2-devel
|
||||
BuildRequires: gobject-introspection-devel
|
||||
@ -382,6 +385,9 @@ A meta-package that pulls all the libblockdev plugins as dependencies.
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
|
||||
%build
|
||||
%configure
|
||||
@ -579,6 +585,14 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
|
||||
%files plugins-all
|
||||
|
||||
%changelog
|
||||
* Tue Oct 4 2016 Vratislav Podzimek <vpodzime@redhat.com> - 1.9-4
|
||||
- Do not report volume name for FW RAID container device (vpodzime)
|
||||
Related: rhbz#1379865
|
||||
- Search for just "UUID" in mdadm --examine output (vpodzime)
|
||||
Related: rhbz#1379865
|
||||
- Use 'mdadm --examine --export' to get MD RAID level (vpodzime)
|
||||
Related: rhbz#1379865
|
||||
|
||||
* Mon Oct 3 2016 Vratislav Podzimek <vpodzime@redhat.com> - 1.9-3
|
||||
- Try to search for "RAID Level" in mdadm's output (vpodzime)
|
||||
Resolves: rhbz#1379865
|
||||
|
92
mdadm_examine_export.patch
Normal file
92
mdadm_examine_export.patch
Normal file
@ -0,0 +1,92 @@
|
||||
From 0773e654b2eb446518692535bb349f8abcd17af0 Mon Sep 17 00:00:00 2001
|
||||
From: Vratislav Podzimek <vpodzime@redhat.com>
|
||||
Date: Tue, 4 Oct 2016 19:08:06 +0200
|
||||
Subject: [PATCH 1/3] Use 'mdadm --examine --export' to get MD RAID level
|
||||
|
||||
It may not be reported properly in the 'mdadm --examine' output (e.g. for IMSM
|
||||
FW RAID).
|
||||
|
||||
Related: rhbz#1379865
|
||||
|
||||
(cherry-picked from commit 075c21c6a474674c1370472b2cf74f93dff28c38)
|
||||
|
||||
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
|
||||
---
|
||||
src/plugins/mdraid.c | 20 ++++++++++++++++++++
|
||||
tests/md_test.py | 2 +-
|
||||
tests/mdadm_fw_RAID_examine/mdadm | 10 ++++++++++
|
||||
3 files changed, 31 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
|
||||
index 723b756..7e6b2da 100644
|
||||
--- a/src/plugins/mdraid.c
|
||||
+++ b/src/plugins/mdraid.c
|
||||
@@ -798,6 +798,26 @@ BDMDExamineData* bd_md_examine (gchar *device, GError **error) {
|
||||
g_free (orig_data);
|
||||
}
|
||||
|
||||
+ argv[2] = "--export";
|
||||
+ success = bd_utils_exec_and_capture_output (argv, &output, error);
|
||||
+ if (!success)
|
||||
+ /* error is already populated */
|
||||
+ return FALSE;
|
||||
+
|
||||
+ /* try to get a better information about RAID level because it may be
|
||||
+ misleading 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_LEVEL=")) {
|
||||
+ value = strchr (output_fields[i], '=');
|
||||
+ value++;
|
||||
+ g_free (ret->level);
|
||||
+ ret->level = g_strdup (value);
|
||||
+ }
|
||||
+ g_strfreev (output_fields);
|
||||
+
|
||||
argv[2] = "--brief";
|
||||
success = bd_utils_exec_and_capture_output (argv, &output, error);
|
||||
if (!success)
|
||||
diff --git a/tests/md_test.py b/tests/md_test.py
|
||||
index df90582..4b4d898 100644
|
||||
--- a/tests/md_test.py
|
||||
+++ b/tests/md_test.py
|
||||
@@ -410,7 +410,7 @@ class FakeMDADMutilTest(unittest.TestCase):
|
||||
with fake_utils("tests/mdadm_fw_RAID_examine"):
|
||||
ex_data = BlockDev.md_examine("fake_dev")
|
||||
|
||||
- self.assertEqual(ex_data.level, "0")
|
||||
+ self.assertEqual(ex_data.level, "container")
|
||||
self.assertEqual(ex_data.num_devices, 1)
|
||||
|
||||
def test_no_metadata_examine(self):
|
||||
diff --git a/tests/mdadm_fw_RAID_examine/mdadm b/tests/mdadm_fw_RAID_examine/mdadm
|
||||
index c939860..6fe7f64 100755
|
||||
--- a/tests/mdadm_fw_RAID_examine/mdadm
|
||||
+++ b/tests/mdadm_fw_RAID_examine/mdadm
|
||||
@@ -3,11 +3,21 @@
|
||||
echo "$@"|grep -- "--brief" &>/dev/null
|
||||
is_brief=$?
|
||||
|
||||
+echo "$@"|grep -- "--export" &>/dev/null
|
||||
+is_export=$?
|
||||
+
|
||||
if [ $is_brief -eq 0 ]; then
|
||||
cat <<EOF
|
||||
ARRAY metadata=imsm UUID=b42756a2:37e43e47:674bd1dd:6e822145
|
||||
ARRAY /dev/md/Volume0 container=b42756a2:37e43e47:674bd1dd:6e822145 member=0 UUID=8f0b5240:06168ed1:bbafeaf5:2a7b04fc
|
||||
EOF
|
||||
+elif [ $is_export -eq 0 ]; then
|
||||
+ cat <<EOF
|
||||
+MD_METADATA=imsm
|
||||
+MD_LEVEL=container
|
||||
+MD_UUID=b42756a2:37e43e47:674bd1dd:6e822145
|
||||
+MD_DEVICES=2
|
||||
+EOF
|
||||
else
|
||||
cat <<EOF
|
||||
/dev/sda:
|
||||
--
|
||||
2.7.4
|
||||
|
59
mdadm_examine_uuid.patch
Normal file
59
mdadm_examine_uuid.patch
Normal file
@ -0,0 +1,59 @@
|
||||
From 15d5cb5679d69bb016edd8659362bb4c23b3573d Mon Sep 17 00:00:00 2001
|
||||
From: Vratislav Podzimek <vpodzime@redhat.com>
|
||||
Date: Tue, 4 Oct 2016 21:12:06 +0200
|
||||
Subject: [PATCH 2/3] Search for just "UUID" in mdadm --examine output
|
||||
|
||||
IMSM raid arrays don't have the "Array UUID" key reported, it's just "UUID". And
|
||||
as a bonus, the volume UUID is reported as well as the container's UUID (we care
|
||||
about), both using just "UUID".
|
||||
|
||||
Related: rhbz#1379865
|
||||
|
||||
(cherry-picked from commit 0fb4e778b8a30200ed6e4272e9427d109f993eb2)
|
||||
|
||||
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
|
||||
---
|
||||
src/plugins/mdraid.c | 7 ++++++-
|
||||
tests/md_test.py | 1 +
|
||||
2 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
|
||||
index 7e6b2da..5bfbfb8 100644
|
||||
--- a/src/plugins/mdraid.c
|
||||
+++ b/src/plugins/mdraid.c
|
||||
@@ -164,7 +164,9 @@ static GHashTable* parse_mdadm_vars (gchar *str, gchar *item_sep, gchar *key_val
|
||||
key_val = g_strsplit (*item_p, key_val_sep, 2);
|
||||
if (g_strv_length (key_val) == 2) {
|
||||
/* we only want to process valid lines (with the separator) */
|
||||
- g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1]));
|
||||
+ /* only use the first value for the given key */
|
||||
+ if (!g_hash_table_contains (table, g_strstrip (key_val[0])))
|
||||
+ g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1]));
|
||||
(*num_items)++;
|
||||
} else
|
||||
/* invalid line, just free key_val */
|
||||
@@ -211,6 +213,9 @@ static BDMDExamineData* get_examine_data_from_table (GHashTable *table, gboolean
|
||||
data->size = 0;
|
||||
|
||||
data->uuid = g_strdup ((gchar*) g_hash_table_lookup (table, "Array UUID"));
|
||||
+ if (!data->uuid)
|
||||
+ /* also try just "UUID" which may be reported e.g for IMSM FW RAID */
|
||||
+ data->uuid = g_strdup ((gchar*) g_hash_table_lookup (table, "UUID"));
|
||||
|
||||
value = (gchar*) g_hash_table_lookup (table, "Update Time");
|
||||
if (value) {
|
||||
diff --git a/tests/md_test.py b/tests/md_test.py
|
||||
index 4b4d898..2fab378 100644
|
||||
--- a/tests/md_test.py
|
||||
+++ b/tests/md_test.py
|
||||
@@ -412,6 +412,7 @@ class FakeMDADMutilTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(ex_data.level, "container")
|
||||
self.assertEqual(ex_data.num_devices, 1)
|
||||
+ self.assertEqual(ex_data.uuid, "b42756a2-37e4-3e47-674b-d1dd6e822145")
|
||||
|
||||
def test_no_metadata_examine(self):
|
||||
"""Verify that md_examine works as expected with no metadata spec"""
|
||||
--
|
||||
2.7.4
|
||||
|
112
mdadm_fw_raid_device.patch
Normal file
112
mdadm_fw_raid_device.patch
Normal file
@ -0,0 +1,112 @@
|
||||
From 8123db9319a26c59996d4c42e84100ebe5822b82 Mon Sep 17 00:00:00 2001
|
||||
From: Vratislav Podzimek <vpodzime@redhat.com>
|
||||
Date: Tue, 4 Oct 2016 21:19:22 +0200
|
||||
Subject: [PATCH 3/3] Do not report volume name for FW RAID container device
|
||||
|
||||
This may be confusing for tools/libraries using our API because they need info
|
||||
about the immediate descendant device which is the container.
|
||||
|
||||
Related: rhbz#1379865
|
||||
|
||||
(cherry-picked from commit ad6eb3d47c57171cea7abbae0f5d0c1f5ee2c357)
|
||||
|
||||
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
|
||||
---
|
||||
src/plugins/mdraid.c | 13 ++++++++-----
|
||||
tests/md_test.py | 12 ++----------
|
||||
tests/mdadm_fw_raid_examine/mdadm | 18 ------------------
|
||||
3 files changed, 10 insertions(+), 33 deletions(-)
|
||||
delete mode 100755 tests/mdadm_fw_raid_examine/mdadm
|
||||
|
||||
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
|
||||
index 5bfbfb8..9cb0cc7 100644
|
||||
--- a/src/plugins/mdraid.c
|
||||
+++ b/src/plugins/mdraid.c
|
||||
@@ -768,7 +768,7 @@ BDMDExamineData* bd_md_examine (gchar *device, GError **error) {
|
||||
gchar **output_fields = NULL;
|
||||
gchar *orig_data = NULL;
|
||||
guint i = 0;
|
||||
- gboolean found_dev_name = FALSE;
|
||||
+ gboolean found_array_line = FALSE;
|
||||
|
||||
success = bd_utils_exec_and_capture_output (argv, &output, error);
|
||||
if (!success)
|
||||
@@ -831,13 +831,16 @@ BDMDExamineData* bd_md_examine (gchar *device, GError **error) {
|
||||
|
||||
/* try to find the "ARRAY /dev/md/something" pair in the output */
|
||||
output_fields = g_strsplit_set (output, " \n", 0);
|
||||
- for (i=0; !found_dev_name && (i < g_strv_length (output_fields) - 1); i++)
|
||||
- if (g_strcmp0 (output_fields[i], "ARRAY") == 0)
|
||||
+ for (i=0; !found_array_line && (i < g_strv_length (output_fields) - 1); i++)
|
||||
+ if (g_strcmp0 (output_fields[i], "ARRAY") == 0) {
|
||||
+ found_array_line = TRUE;
|
||||
if (g_str_has_prefix (output_fields[i+1], "/dev/md/")) {
|
||||
ret->device = g_strdup (output_fields[i+1]);
|
||||
- found_dev_name = TRUE;
|
||||
+ } else {
|
||||
+ ret->device = NULL;
|
||||
}
|
||||
- if (!found_dev_name)
|
||||
+ }
|
||||
+ if (!found_array_line)
|
||||
ret->device = NULL;
|
||||
g_strfreev (output_fields);
|
||||
|
||||
diff --git a/tests/md_test.py b/tests/md_test.py
|
||||
index 2fab378..d7e007a 100644
|
||||
--- a/tests/md_test.py
|
||||
+++ b/tests/md_test.py
|
||||
@@ -395,17 +395,8 @@ class MDTestNameNodeBijection(MDTestCase):
|
||||
|
||||
class FakeMDADMutilTest(unittest.TestCase):
|
||||
# no setUp nor tearDown needed, we are gonna use fake utils
|
||||
-
|
||||
- def test_fw_raid_examine(self):
|
||||
- """Verify that md_examine works as expected on FW RAID data"""
|
||||
-
|
||||
- with fake_utils("tests/mdadm_fw_raid_examine"):
|
||||
- ex_data = BlockDev.md_examine("fake_dev")
|
||||
-
|
||||
- self.assertEqual(ex_data.device, "/dev/md/Volume0")
|
||||
-
|
||||
def test_fw_raid_uppercase_examine(self):
|
||||
- """Verify that md_examine works with output using "RAID" instead of "Raid" """
|
||||
+ """Verify that md_examine works with output using "RAID" instead of "Raid" and other quirks """
|
||||
|
||||
with fake_utils("tests/mdadm_fw_RAID_examine"):
|
||||
ex_data = BlockDev.md_examine("fake_dev")
|
||||
@@ -413,6 +404,7 @@ class FakeMDADMutilTest(unittest.TestCase):
|
||||
self.assertEqual(ex_data.level, "container")
|
||||
self.assertEqual(ex_data.num_devices, 1)
|
||||
self.assertEqual(ex_data.uuid, "b42756a2-37e4-3e47-674b-d1dd6e822145")
|
||||
+ self.assertEqual(ex_data.device, None)
|
||||
|
||||
def test_no_metadata_examine(self):
|
||||
"""Verify that md_examine works as expected with no metadata spec"""
|
||||
diff --git a/tests/mdadm_fw_raid_examine/mdadm b/tests/mdadm_fw_raid_examine/mdadm
|
||||
deleted file mode 100755
|
||||
index 54ec4ed..0000000
|
||||
--- a/tests/mdadm_fw_raid_examine/mdadm
|
||||
+++ /dev/null
|
||||
@@ -1,18 +0,0 @@
|
||||
-#!/bin/bash
|
||||
-
|
||||
-echo "$@"|grep -- "--brief" &>/dev/null
|
||||
-is_brief=$?
|
||||
-
|
||||
-if [ $is_brief -eq 0 ]; then
|
||||
- cat <<EOF
|
||||
-ARRAY metadata=imsm UUID=e0fb362e:9865d1c0:cdb0f5e3:27c9a085
|
||||
-ARRAY /dev/md/Volume0 container=e0fb362e:9865d1c0:cdb0f5e3:27c9a085 member=0 UUID=1d1335e9:79d4be6a:e16b7fa7:fe8c41f6
|
||||
-EOF
|
||||
-else
|
||||
- cat <<EOF
|
||||
-MD_METADATA=imsm
|
||||
-MD_LEVEL=container
|
||||
-MD_UUID=e0fb362e:9865d1c0:cdb0f5e3:27c9a085
|
||||
-MD_DEVICES=2
|
||||
-EOF
|
||||
-fi
|
||||
--
|
||||
2.7.4
|
||||
|
Loading…
Reference in New Issue
Block a user