New version

- Try to search for "RAID Level" in mdadm's output (vpodzime)
- Fix the number passed to LVM DBus as a job-creation timeout (vpodzime)
This commit is contained in:
Vratislav Podzimek 2016-10-03 17:38:12 +02:00
parent eb29bb48f7
commit bf9216eb2f
3 changed files with 162 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From ad4679efb8ae455d984aa78bb7e264af9646ea29 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Fri, 30 Sep 2016 12:18:01 +0200
Subject: [PATCH 1/2] Fix the number passed to LVM DBus as a job-creation
timeout
It's in seconds not milliseconds like the DBus method call timeout.
Resolves: rhbz#1378970
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/lvm-dbus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index 844e36e..9500dcb 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -58,7 +58,7 @@ static gchar *global_config_str = NULL;
#define DBUS_PROPS_IFACE "org.freedesktop.DBus.Properties"
#define DBUS_INTRO_IFACE "org.freedesktop.DBus.Introspectable"
#define DBUS_LONG_CALL_TIMEOUT 10000 /* msecs */
-#define METHOD_CALL_TIMEOUT (DBUS_LONG_CALL_TIMEOUT / 2)
+#define METHOD_CALL_TIMEOUT (DBUS_LONG_CALL_TIMEOUT / 2) / 1000 /* secs */
static GDBusConnection *bus = NULL;
--
2.7.4

View File

@ -1,12 +1,14 @@
Name: libblockdev
Version: 1.9
Release: 2%{?dist}
Release: 3%{?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: cast_numbers.patch
Patch1: dbus_job_creation_timeout.patch
Patch2: mdadm_raid_level_quirk.patch
BuildRequires: glib2-devel
BuildRequires: gobject-introspection-devel
@ -378,6 +380,8 @@ A meta-package that pulls all the libblockdev plugins as dependencies.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
%configure
@ -575,6 +579,12 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files plugins-all
%changelog
* 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
- Fix the number passed to LVM DBus as a job-creation timeout (vpodzime)
Resolves: rhbz#1378970
* Mon Aug 29 2016 Vratislav Podzimek <vpodzime@redhat.com> - 1.9-2
- Explicitly cast number constants for GVariants (vpodzime)

View File

@ -0,0 +1,121 @@
From dc98c0d0eaf06af42c6f9eb3ee5ade9e237c5f40 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Fri, 30 Sep 2016 13:47:24 +0200
Subject: [PATCH 2/2] Try to search for "RAID Level" in mdadm's output
(#1379865)
mdadm's API (CLI) is ambiguous and may provide the RAID level as either the
"RAID Level" or "Raid Level" item. Since we store these items in a hashtable,
let's try to lookup both if the first one fails. Another approach would be to
cannonicalize all the items keys when creating the hash table, but that seems
like an overkill for one weird quirk.
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/mdraid.c | 6 +++++
tests/md_test.py | 9 +++++++
tests/mdadm_fw_RAID_examine/mdadm | 53 +++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
create mode 100755 tests/mdadm_fw_RAID_examine/mdadm
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
index abd97da..723b756 100644
--- a/src/plugins/mdraid.c
+++ b/src/plugins/mdraid.c
@@ -184,8 +184,14 @@ static BDMDExamineData* get_examine_data_from_table (GHashTable *table, gboolean
char time_str[20];
data->level = g_strdup ((gchar*) g_hash_table_lookup (table, "Raid Level"));
+ if (!(data->level))
+ /* BUG: mdadm outputs "RAID Level" for some metadata formats (rhbz#1380034) */
+ data->level = g_strdup ((gchar*) g_hash_table_lookup (table, "RAID Level"));
value = (gchar*) g_hash_table_lookup (table, "Raid Devices");
+ if (!value)
+ /* BUG: mdadm outputs "RAID Devices" for some metadata formats (rhbz#1380034) */
+ value = (gchar*) g_hash_table_lookup (table, "RAID Devices");
if (value)
data->num_devices = g_ascii_strtoull (value, NULL, 0);
else
diff --git a/tests/md_test.py b/tests/md_test.py
index 6664e44..df90582 100644
--- a/tests/md_test.py
+++ b/tests/md_test.py
@@ -404,6 +404,15 @@ class FakeMDADMutilTest(unittest.TestCase):
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" """
+
+ 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.num_devices, 1)
+
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
new file mode 100755
index 0000000..c939860
--- /dev/null
+++ b/tests/mdadm_fw_RAID_examine/mdadm
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+echo "$@"|grep -- "--brief" &>/dev/null
+is_brief=$?
+
+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
+else
+ cat <<EOF
+/dev/sda:
+ Magic : Intel Raid ISM Cfg Sig.
+ Version : 1.0.00
+ Orig Family : e56dd6e1
+ Family : e56dd6e1
+ Generation : 0000000c
+ Attributes : All supported
+ UUID : b42756a2:37e43e47:674bd1dd:6e822145
+ Checksum : d4553058 correct
+ MPB Sectors : 1
+ Disks : 2
+ RAID Devices : 1
+
+ Disk00 Serial : 5QM2XY4V
+ State : active
+ Id : 00000000
+ Usable Size : 976768264 (465.76 GiB 500.11 GB)
+
+[Volume0]:
+ UUID : 8f0b5240:06168ed1:bbafeaf5:2a7b04fc
+ RAID Level : 0
+ Members : 2
+ Slots : [UU]
+ Failed disk : none
+ This Slot : 0
+ Array Size : 1953536000 (931.52 GiB 1000.21 GB)
+ Per Dev Size : 976768264 (465.76 GiB 500.11 GB)
+ Sector Offset : 0
+ Num Stripes : 3815500
+ Chunk Size : 128 KiB
+ Reserved : 0
+ Migrate State : idle
+ Map State : normal
+ Dirty State : clean
+
+ Disk01 Serial : 9VM1BT6B
+ State : active
+ Id : 00010000
+ Usable Size : 976768264 (465.76 GiB 500.11 GB)
+EOF
+fi
--
2.7.4