New version

- Do not require an exclusive lock on the device to commit part stuff (vpodzime)
- Prevent failure if there are no btrfs subvolumes (vpodzime)
- Fix the test for getting version of a failing utility (vpodzime)
- Also run the utils tests (vpodzime)
- Bump the version of the pkgconfig module (vpodzime)
- Include utils.h in plugins that need it (vpodzime)
- Fix dependency check in fs plugin (vtrefny)
- Add support for setting part id (part type) on msdos part tables (vtrefny)
- Trim the extra info for MD RAID's name (vpodzime)
- Add xfsprogs and dosfstools as dependencies of the fs plugin (vpodzime)
- Fix md_name_from_node to work with the "/dev/" prefix (vpodzime)
- New upstream major version
This commit is contained in:
Vratislav Podzimek 2016-11-10 19:42:15 +01:00
parent f5e2c15206
commit 07ec7ae0f4
13 changed files with 26 additions and 923 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@
/libblockdev-1.7.tar.gz
/libblockdev-1.8.tar.gz
/libblockdev-1.9.tar.gz
/libblockdev-2.1.tar.gz

View File

@ -1,87 +0,0 @@
From 5e4095722244d989a6a594a933c314a633c4bfd2 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Thu, 25 Aug 2016 16:26:28 +0200
Subject: [PATCH] Explicitly cast number constants for GVariants
Otherwise they may become really weird numbers.
(cherry-picked from commit 4222a693a1b709aa8a243b6eeda376eb9d79d56a)
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/lvm-dbus.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index 8303fe1..844e36e 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -1156,9 +1156,9 @@ gboolean bd_lvm_pvmove (gchar *src, gchar *dest, GError **error) {
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&builder, g_variant_new ("s", src_path));
- g_variant_builder_add_value (&builder, g_variant_new ("(tt)", 0, 0));
+ g_variant_builder_add_value (&builder, g_variant_new ("(tt)", (guint64) 0, (guint64) 0));
if (dest) {
- dest_var = g_variant_new ("(ott)", dest_path, 0, 0);
+ dest_var = g_variant_new ("(ott)", dest_path, (guint64) 0, (guint64) 0);
g_variant_builder_add_value (&builder, g_variant_new_array (NULL, &dest_var, 1));
} else {
type = g_variant_type_new ("a(ott)");
@@ -1372,7 +1372,7 @@ gboolean bd_lvm_vgrename (gchar *old_vg_name, gchar *new_vg_name, GError **error
* Returns: whether the VG was successfully activated or not
*/
gboolean bd_lvm_vgactivate (gchar *vg_name, GError **error) {
- GVariant *params = g_variant_new ("(t)", 0);
+ GVariant *params = g_variant_new ("(t)", (guint64) 0);
call_lvm_obj_method_sync (vg_name, VG_INTF, "Activate", params, NULL, error);
return ((*error) == NULL);
}
@@ -1385,7 +1385,7 @@ gboolean bd_lvm_vgactivate (gchar *vg_name, GError **error) {
* Returns: whether the VG was successfully deactivated or not
*/
gboolean bd_lvm_vgdeactivate (gchar *vg_name, GError **error) {
- GVariant *params = g_variant_new ("(t)", 0);
+ GVariant *params = g_variant_new ("(t)", (guint64) 0);
call_lvm_obj_method_sync (vg_name, VG_INTF, "Deactivate", params, NULL, error);
return ((*error) == NULL);
}
@@ -1609,7 +1609,7 @@ gboolean bd_lvm_lvcreate (gchar *vg_name, gchar *lv_name, guint64 size, gchar *t
g_variant_builder_clear (&builder);
return FALSE;
}
- g_variant_builder_add_value (&builder, g_variant_new ("(ott)", path, 0, 0));
+ g_variant_builder_add_value (&builder, g_variant_new ("(ott)", path, (guint64) 0, (guint64) 0));
}
pvs = g_variant_builder_end (&builder);
g_variant_builder_clear (&builder);
@@ -1723,7 +1723,7 @@ gboolean bd_lvm_lvresize (gchar *vg_name, gchar *lv_name, guint64 size, GError *
* Returns: whether the @vg_name/@lv_name LV was successfully activated or not
*/
gboolean bd_lvm_lvactivate (gchar *vg_name, gchar *lv_name, gboolean ignore_skip, GError **error) {
- GVariant *params = g_variant_new ("(t)", 0);
+ GVariant *params = g_variant_new ("(t)", (guint64) 0);
GVariantBuilder builder;
GVariant *extra = NULL;
@@ -1747,7 +1747,7 @@ gboolean bd_lvm_lvactivate (gchar *vg_name, gchar *lv_name, gboolean ignore_skip
* Returns: whether the @vg_name/@lv_name LV was successfully deactivated or not
*/
gboolean bd_lvm_lvdeactivate (gchar *vg_name, gchar *lv_name, GError **error) {
- GVariant *params = g_variant_new ("(t)", 0);
+ GVariant *params = g_variant_new ("(t)", (guint64) 0);
call_lv_method_sync (vg_name, lv_name, "Deactivate", params, NULL, error);
return (*error == NULL);
}
@@ -2109,7 +2109,7 @@ gboolean bd_lvm_thsnapshotcreate (gchar *vg_name, gchar *origin_name, gchar *sna
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&builder, g_variant_new ("s", snapshot_name));
- g_variant_builder_add_value (&builder, g_variant_new ("t", 0));
+ g_variant_builder_add_value (&builder, g_variant_new ("t", (guint64) 0));
params = g_variant_builder_end (&builder);
g_variant_builder_clear (&builder);
--
2.7.4

View File

@ -1,30 +0,0 @@
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,20 +1,11 @@
Name: libblockdev
Version: 1.9
Release: 8%{?dist}
Version: 2.1
Release: 1%{?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
Patch3: mdadm_examine_export.patch
Patch4: mdadm_examine_uuid.patch
Patch5: mdadm_fw_raid_device.patch
Patch6: obj_path_signatures.patch
Patch7: md_examine_migrated.patch
BuildRequires: glib2-devel
BuildRequires: gobject-introspection-devel
BuildRequires: cryptsetup-devel
@ -174,6 +165,8 @@ Summary: Development files for the libblockdev-fs plugin/library
Requires: %{name}-fs%{?_isa} = %{version}-%{release}
Requires: %{name}-utils-devel%{?_isa}
Requires: glib2-devel
Requires: xfsprogs
Requires: dosfstools
%description fs-devel
This package contains header files and pkg-config files needed for development
@ -305,6 +298,7 @@ Summary: The partitioning plugin for the libblockdev library
Requires: %{name}-utils%{?_isa} >= 0.11
Requires: device-mapper-multipath
Requires: gdisk
Requires: util-linux
%description part
The libblockdev library plugin (and in the same time a standalone library)
@ -384,14 +378,6 @@ A meta-package that pulls all the libblockdev plugins as dependencies.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
%configure
@ -460,13 +446,16 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files utils
%{_libdir}/libbd_utils.so.*
%{_libdir}/libbd_part_err.so.*
%files utils-devel
%{_libdir}/libbd_utils.so
%{_libdir}/libbd_part_err.so
%dir %{_includedir}/blockdev
%{_includedir}/blockdev/utils.h
%{_includedir}/blockdev/sizes.h
%{_includedir}/blockdev/exec.h
%{_includedir}/blockdev/extra_arg.h
%files btrfs
@ -589,6 +578,22 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files plugins-all
%changelog
* Thu Nov 10 2016 Vratislav Podzimek <vpodzime@redhat.com> - 2.1-1
- Do not require an exclusive lock on the device to commit part stuff (vpodzime)
- Prevent failure if there are no btrfs subvolumes (vpodzime)
- Fix the test for getting version of a failing utility (vpodzime)
- Also run the utils tests (vpodzime)
- Bump the version of the pkgconfig module (vpodzime)
- Include utils.h in plugins that need it (vpodzime)
- Fix dependency check in fs plugin (vtrefny)
- Add support for setting part id (part type) on msdos part tables (vtrefny)
- Trim the extra info for MD RAID's name (vpodzime)
- Add xfsprogs and dosfstools as dependencies of the fs plugin (vpodzime)
- Fix md_name_from_node to work with the "/dev/" prefix (vpodzime)
* Wed Nov 2 2016 Vratislav Podzimek <vpodzime@redhat.com> - 2.0-1
- New major upstream release
* Wed Nov 9 2016 Vratislav Podzimek <vpodzime@redhat.com> - 1.9-8
- Revert "Prevent issues between libparted and udev" (vpodzime)
- Revert "Open the device file as RDWR when committing parts" (vpodzime)

View File

@ -1,160 +0,0 @@
From 673422da37ce9f96b44a182addd1aa922a9b047f Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Mon, 24 Oct 2016 14:41:47 -0700
Subject: [PATCH] Handle mdadm --examine output during migration
If a RAID set is undergoing any operation considered to be a
'migration' - which includes initialization of a new set at any
RAID level that includes redundancy - mdadm --examine will have
lines like this:
RAID Level : 5 <-- 5
Members : 3 <-- 3
Map State : normal <-- uninitialized
At present we don't understand this at all. This is a fairly
minimal fix which just has parse_mdadm_vars notice such lines,
split the 'value' on "<--", and stuff the first value (the one
being migrated *to*, which is usually what we care about, I
think) into the table. We could do something more elaborate
like store both values and make `get_examine_data_from_table`
understand that, but it's more complicated and this should be
all we truly need for now.
(cherry picked from commit 07aec87385e2fdbe3f0855d697facf04b9ea6521)
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/mdraid.c | 13 +++++-
tests/md_test.py | 8 ++++
tests/mdadm_fw_RAID_examine_migrate/mdadm | 69 +++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 2 deletions(-)
create mode 100755 tests/mdadm_fw_RAID_examine_migrate/mdadm
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
index 9cb0cc7..c4780eb 100644
--- a/src/plugins/mdraid.c
+++ b/src/plugins/mdraid.c
@@ -155,6 +155,7 @@ static GHashTable* parse_mdadm_vars (gchar *str, gchar *item_sep, gchar *key_val
gchar **items = NULL;
gchar **item_p = NULL;
gchar **key_val = NULL;
+ gchar **vals = NULL;
table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
*num_items = 0;
@@ -165,8 +166,16 @@ static GHashTable* parse_mdadm_vars (gchar *str, gchar *item_sep, gchar *key_val
if (g_strv_length (key_val) == 2) {
/* we only want to process valid lines (with the separator) */
/* 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]));
+ if (!g_hash_table_contains (table, g_strstrip (key_val[0]))) {
+ if (strstr (key_val[1], "<--")) {
+ /* mdadm --examine output for a set being migrated */
+ vals = g_strsplit (key_val[1], "<--", 2);
+ g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (vals[0]));
+ g_free (vals[1]);
+ } else {
+ g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1]));
+ }
+ }
(*num_items)++;
} else
/* invalid line, just free key_val */
diff --git a/tests/md_test.py b/tests/md_test.py
index d7e007a..926d0c5 100644
--- a/tests/md_test.py
+++ b/tests/md_test.py
@@ -415,6 +415,14 @@ class FakeMDADMutilTest(unittest.TestCase):
self.assertIs(ex_data.metadata, None)
+ def test_fw_raid_migrating(self):
+ """Verify that md_examine works when array is migrating ("foo <-- bar" values in output) """
+
+ with fake_utils("tests/mdadm_fw_RAID_examine_migrate"):
+ ex_data = BlockDev.md_examine("fake_dev")
+
+ self.assertEqual(ex_data.chunk_size, 128 * 1024)
+
class MDUnloadTest(unittest.TestCase):
def setUp(self):
diff --git a/tests/mdadm_fw_RAID_examine_migrate/mdadm b/tests/mdadm_fw_RAID_examine_migrate/mdadm
new file mode 100755
index 0000000..36ab0ca
--- /dev/null
+++ b/tests/mdadm_fw_RAID_examine_migrate/mdadm
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+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=83c77249:90fb26a2:882bfb52:87f71b59
+ARRAY /dev/md/Volume0 container=83c77249:90fb26a2:882bfb52:87f71b59 member=0 UUID=76508998:aea211a0:b4fa4eda:78e41fbb
+EOF
+elif [ $is_export -eq 0 ]; then
+ cat <<EOF
+MD_METADATA=imsm
+MD_LEVEL=container
+MD_UUID=83c77249:90fb26a2:882bfb52:87f71b59
+MD_DEVICES=3
+EOF
+else
+ cat <<EOF
+/dev/sda:
+ Magic : Intel Raid ISM Cfg Sig.
+ Version : 1.2.02
+ Orig Family : 56330de5
+ Family : 56330de5
+ Generation : 00000005
+ Attributes : All supported
+ UUID : 83c77249:90fb26a2:882bfb52:87f71b59
+ Checksum : 359f2642 correct
+ MPB Sectors : 2
+ Disks : 3
+ RAID Devices : 1
+
+ Disk00 Serial : 50026B723702E422
+ State : active
+ Id : 00000000
+ Usable Size : 234436872 (111.79 GiB 120.03 GB)
+
+[Volume0]:
+ UUID : 76508998:aea211a0:b4fa4eda:78e41fbb
+ RAID Level : 5 <-- 5
+ Members : 3 <-- 3
+ Slots : [UUU] <-- [UUU]
+ Failed disk : none
+ This Slot : 0
+ Array Size : 468873216 (223.58 GiB 240.06 GB)
+ Per Dev Size : 234436872 (111.79 GiB 120.03 GB)
+ Sector Offset : 0
+ Num Stripes : 915768
+ Chunk Size : 128 KiB <-- 128 KiB
+ Reserved : 0
+ Migrate State : initialize
+ Map State : normal <-- uninitialized
+ Checkpoint : 0 (768)
+ Dirty State : clean
+
+ Disk01 Serial : 2327B37FS
+ State : active
+ Id : 00000002
+ Usable Size : 976768392 (465.76 GiB 500.11 GB)
+
+ Disk02 Serial : 232K7DDFS
+ State : active
+ Id : 00000003
+ Usable Size : 976768392 (465.76 GiB 500.11 GB)
+EOF
+fi
--
2.7.4

View File

@ -1,92 +0,0 @@
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

View File

@ -1,59 +0,0 @@
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

View File

@ -1,112 +0,0 @@
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

View File

@ -1,121 +0,0 @@
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

View File

@ -1,80 +0,0 @@
From df13becf4eaaa541ba56f0a30dd31a54d7b00e9c Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Thu, 15 Sep 2016 14:56:10 +0200
Subject: [PATCH] Make sure all object paths are passed and extracted as such
The type signature for a DBus object path is "o". Now that the LVM DBus API
properly sets types of its accepted and returned values, we can finally safely
use the signature in all expected places.
(cherry picked from commit e8117786aad76773d96b9a8d977e53077535b9bc)
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/lvm-dbus.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index 9500dcb..1276548 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -711,7 +711,7 @@ static BDLVMPVdata* get_pv_data_from_props (GVariant *props, GError **error) {
g_variant_dict_lookup (&dict, "PeStart", "t", &(data->pe_start));
/* returns an object path for the VG */
- g_variant_dict_lookup (&dict, "Vg", "s", &value);
+ g_variant_dict_lookup (&dict, "Vg", "o", &value);
if (g_strcmp0 (value, "/") == 0) {
/* no VG, the PV is not part of any VG */
g_variant_dict_clear (&dict);
@@ -1152,10 +1152,10 @@ gboolean bd_lvm_pvmove (gchar *src, gchar *dest, GError **error) {
g_free (src_path);
return FALSE;
}
- g_variant_get (prop, "s", &vg_obj_path);
+ g_variant_get (prop, "o", &vg_obj_path);
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
- g_variant_builder_add_value (&builder, g_variant_new ("s", src_path));
+ g_variant_builder_add_value (&builder, g_variant_new ("o", src_path));
g_variant_builder_add_value (&builder, g_variant_new ("(tt)", (guint64) 0, (guint64) 0));
if (dest) {
dest_var = g_variant_new ("(ott)", dest_path, (guint64) 0, (guint64) 0);
@@ -2367,7 +2367,7 @@ gboolean bd_lvm_cache_attach (gchar *vg_name, gchar *data_lv, gchar *cache_pool_
if (!lv_obj_path)
return FALSE;
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
- g_variant_builder_add_value (&builder, g_variant_new ("s", lv_obj_path));
+ g_variant_builder_add_value (&builder, g_variant_new ("o", lv_obj_path));
params = g_variant_builder_end (&builder);
g_variant_builder_clear (&builder);
@@ -2476,7 +2476,7 @@ gchar* bd_lvm_cache_pool_name (gchar *vg_name, gchar *cached_lv, GError **error)
g_free (lv_spec);
if (!prop)
return NULL;
- g_variant_get (prop, "s", &pool_obj_path);
+ g_variant_get (prop, "o", &pool_obj_path);
prop = get_object_property (pool_obj_path, LV_CMN_INTF, "Name", error);
g_free (pool_obj_path);
if (!prop)
@@ -2650,7 +2650,7 @@ gchar* bd_lvm_data_lv_name (gchar *vg_name, gchar *lv_name, GError **error) {
g_clear_error (error);
return NULL;
}
- g_variant_get (prop, "s", &obj_path);
+ g_variant_get (prop, "o", &obj_path);
g_variant_unref (prop);
if (g_strcmp0 (obj_path, "/") == 0) {
@@ -2699,7 +2699,7 @@ gchar* bd_lvm_metadata_lv_name (gchar *vg_name, gchar *lv_name, GError **error)
g_clear_error (error);
return NULL;
}
- g_variant_get (prop, "s", &obj_path);
+ g_variant_get (prop, "o", &obj_path);
g_variant_unref (prop);
if (g_strcmp0 (obj_path, "/") == 0) {
--
2.7.4

View File

@ -1,86 +0,0 @@
From 1edbfcdb4a973120048b5c04e0eb92b05ad3cbd2 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Wed, 26 Oct 2016 16:13:58 +0200
Subject: [PATCH] Open the device file as RDWR when committing parts
We block udev from generating events for the device while we are between
committing changes to disk and informing kernel about the changes. If we close
the file descriptor later, no udev changes are generated either unless we open
is as RDWR. Here's the difference:
RDONLY:
# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[68221.911864] change /devices/virtual/block/loop0 (block)
KERNEL[68221.913442] change /devices/virtual/block/loop0 (block)
KERNEL[68221.913794] add /devices/virtual/block/loop0/loop0p1 (block)
KERNEL[68221.915019] change /devices/virtual/block/loop0 (block)
KERNEL[68221.915217] change /devices/virtual/block/loop0/loop0p1 (block)
UDEV [68221.941293] change /devices/virtual/block/loop0 (block)
UDEV [68221.954214] change /devices/virtual/block/loop0/loop0p1 (block)
RDWR:
# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[68161.533114] change /devices/virtual/block/loop0 (block)
KERNEL[68161.533165] change /devices/virtual/block/loop0 (block)
UDEV [68161.533219] change /devices/virtual/block/loop0 (block)
KERNEL[68161.533262] add /devices/virtual/block/loop0/loop0p1 (block)
KERNEL[68161.533292] change /devices/virtual/block/loop0 (block)
KERNEL[68161.533326] change /devices/virtual/block/loop0/loop0p1 (block)
UDEV [68161.539255] add /devices/virtual/block/loop0/loop0p1 (block)
UDEV [68161.560215] change /devices/virtual/block/loop0 (block)
UDEV [68161.572345] change /devices/virtual/block/loop0/loop0p1 (block)
As seen above, there's no 'add' udev event in case we open the device file as
RDONLY.
(cherry picked from commit 44fdb3953eb05ff4f43a576f15d508928dca3eb7)
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/part.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/plugins/part.c b/src/plugins/part.c
index d5239e3..0f8e678 100644
--- a/src/plugins/part.c
+++ b/src/plugins/part.c
@@ -157,7 +157,7 @@ static gboolean disk_commit (PedDisk *disk, gchar *path, GError **error) {
/* XXX: try to grab an exclusive lock for the device so that udev doesn't
trigger events for it in between the two operations we need to perform
(see below) */
- dev_fd = open (disk->dev->path, O_RDONLY|O_CLOEXEC);
+ dev_fd = open (disk->dev->path, O_RDWR|O_CLOEXEC);
if (dev_fd >= 0)
/* if this fails, we can do no better anyway, so just ignore the return
value */
@@ -167,6 +167,7 @@ static gboolean disk_commit (PedDisk *disk, gchar *path, GError **error) {
if (ret == 0) {
set_parted_error (error, BD_PART_ERROR_FAIL);
g_prefix_error (error, "Failed to commit changes to device '%s'", path);
+ flock (dev_fd, LOCK_UN);
close (dev_fd);
return FALSE;
}
@@ -175,10 +176,12 @@ static gboolean disk_commit (PedDisk *disk, gchar *path, GError **error) {
if (ret == 0) {
set_parted_error (error, BD_PART_ERROR_FAIL);
g_prefix_error (error, "Failed to inform OS about changes on the '%s' device", path);
+ flock (dev_fd, LOCK_UN);
close (dev_fd);
return FALSE;
}
+ flock (dev_fd, LOCK_UN);
close (dev_fd);
return TRUE;
}
--
2.7.4

View File

@ -1,76 +0,0 @@
From 66ceb82b6d51707a74174dfb7a74b943ea571a43 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Thu, 20 Oct 2016 15:43:23 +0200
Subject: [PATCH] Prevent issues between libparted and udev
libparted does committing of a new partition table to disk in two steps:
1. committing (writing and flushing) to disk and
2. telling OS about the partitions.
However, that means that if things go wrong, udev may step in between the above
steps and trigger events when the block device file is closed (from being opened
RW) that could lead to a failure of the second step because some other process
may open the block device file in the reaction to the event.
In order to prevent such issues we need to acquire an exclusive lock on the
block device file, which prevents udev from triggering events, for the time we
let libparted perform the two operations above.
(cherry picked from commit 0a65466154994759cbec15ce984b751b073a891f)
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/part.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/plugins/part.c b/src/plugins/part.c
index 4634ef8..d5239e3 100644
--- a/src/plugins/part.c
+++ b/src/plugins/part.c
@@ -23,6 +23,8 @@
#include <stdlib.h>
#include <math.h>
#include <inttypes.h>
+#include <unistd.h>
+#include <sys/file.h>
#include <utils.h>
#include "part.h"
@@ -150,11 +152,22 @@ static const gchar *table_type_str[BD_PART_TABLE_UNDEF] = {"msdos", "gpt"};
static gboolean disk_commit (PedDisk *disk, gchar *path, GError **error) {
gint ret = 0;
+ gint dev_fd = 0;
+
+ /* XXX: try to grab an exclusive lock for the device so that udev doesn't
+ trigger events for it in between the two operations we need to perform
+ (see below) */
+ dev_fd = open (disk->dev->path, O_RDONLY|O_CLOEXEC);
+ if (dev_fd >= 0)
+ /* if this fails, we can do no better anyway, so just ignore the return
+ value */
+ flock (dev_fd, LOCK_EX);
ret = ped_disk_commit_to_dev (disk);
if (ret == 0) {
set_parted_error (error, BD_PART_ERROR_FAIL);
g_prefix_error (error, "Failed to commit changes to device '%s'", path);
+ close (dev_fd);
return FALSE;
}
@@ -162,9 +175,11 @@ static gboolean disk_commit (PedDisk *disk, gchar *path, GError **error) {
if (ret == 0) {
set_parted_error (error, BD_PART_ERROR_FAIL);
g_prefix_error (error, "Failed to inform OS about changes on the '%s' device", path);
+ close (dev_fd);
return FALSE;
}
+ close (dev_fd);
return TRUE;
}
--
2.7.4

View File

@ -1 +1 @@
4fc2e0563981c6553a87aa2dcc578c6d libblockdev-1.9.tar.gz
0bd637d4f56c20db914d55b186b23027 libblockdev-2.1.tar.gz