From 609b76074da08b02eae876598fefe68b9d380bd3 Mon Sep 17 00:00:00 2001 From: geruijun Date: Tue, 28 Jul 2020 16:24:04 +0800 Subject: [PATCH 1/2] backport upstream patches --- ...-activate-already-active-DMRAID-sets.patch | 96 ++++++++++++++ ...y-to-activate-already-active-MDRAID-.patch | 61 +++++++++ ...attribute-to-bd_lvm_pvdata_copy-in-L.patch | 25 ++++ ...or-message-when-loading-module-witho.patch | 37 ++++++ ...ec-Fix-setting-locale-for-util-calls.patch | 119 ++++++++++++++++++ ...ix-checking-for-LVM-VDO-dependencies.patch | 28 +++++ ...x-memory-leak-in-bd_lvm_cache_attach.patch | 25 ++++ ...y-leak-bd_lvm_cache_create_cached_lv.patch | 24 ++++ libblockdev.spec | 14 ++- 9 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch create mode 100644 0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch create mode 100644 0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch create mode 100644 0004-module.c-Fix-error-message-when-loading-module-witho.patch create mode 100644 0005-exec-Fix-setting-locale-for-util-calls.patch create mode 100644 0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch create mode 100644 0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch create mode 100644 0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch diff --git a/0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch b/0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch new file mode 100644 index 0000000..0d32d10 --- /dev/null +++ b/0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch @@ -0,0 +1,96 @@ +From 663614825c5d7ba7a66631af0b0efd7037569337 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 2 Jun 2020 10:20:35 +0200 +Subject: [PATCH 164/193] dm: Do not try to activate already active DMRAID sets + +--- + src/plugins/dm.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 43 insertions(+), 2 deletions(-) + +diff --git a/src/plugins/dm.c b/src/plugins/dm.c +index afb387c..af7e60b 100644 +--- a/src/plugins/dm.c ++++ b/src/plugins/dm.c +@@ -516,6 +516,29 @@ static void find_raid_sets_for_dev (const gchar *name, const gchar *uuid, gint m + } + } + } ++ ++static gboolean get_raid_set_status (struct raid_set *rs, GError **error) { ++ struct dm_task *dmt = NULL; ++ struct dm_info info; ++ gboolean ret; ++ ++ dmt = dm_task_create (DM_DEVICE_STATUS); ++ if (!dmt) { ++ g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK, ++ "Failed to create DM task"); ++ return FALSE; ++ } ++ ++ if (!dm_task_set_name (dmt, rs->name) || !dm_task_run (dmt) || !dm_task_get_info (dmt, &info)) { ++ /* the DM device doesn't exist or some weird error appeared, just assume the RAID set is not active */ ++ dm_task_destroy (dmt); ++ return FALSE; ++ } ++ ++ ret = info.exists; ++ dm_task_destroy (dmt); ++ return ret; ++} + #endif // WITH_BD_DMRAID + + /** +@@ -610,6 +633,7 @@ static gboolean change_set_by_name (const gchar *name, enum activate_type action + struct lib_context *lc = NULL; + struct raid_set *iter_rs = NULL; + struct raid_set *match_rs = NULL; ++ gboolean status = FALSE; + + lc = init_dmraid_stack (error); + if (!lc) +@@ -629,6 +653,19 @@ static gboolean change_set_by_name (const gchar *name, enum activate_type action + return FALSE; + } + ++ status = get_raid_set_status (match_rs, error); ++ if (!status && error) { ++ g_prefix_error (error, "Failed to get status for the RAID set '%s'", name); ++ libdmraid_exit (lc); ++ return FALSE; ++ } ++ ++ if (action == A_ACTIVATE && status) { ++ /* nothing to do here the set is already in the desired state */ ++ libdmraid_exit (lc); ++ return TRUE; ++ } ++ + rc = change_set (lc, action, match_rs); + if (!rc) { + g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL, +@@ -647,7 +684,9 @@ static gboolean change_set_by_name (const gchar *name, enum activate_type action + * @name: name of the DM RAID set to activate + * @error: (out): variable to store error (if any) + * +- * Returns: whether the RAID set @name was successfully activate or not ++ * Returns: whether the RAID set @name was successfully activated or not ++ * ++ * Note: This is a no-op for already active RAID sets. + * + * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_CREATE_ACTIVATE + */ +@@ -676,7 +715,9 @@ gboolean bd_dm_activate_raid_set (const gchar *name, GError **error) { + * @name: name of the DM RAID set to deactivate + * @error: (out): variable to store error (if any) + * +- * Returns: whether the RAID set @name was successfully deactivate or not ++ * Returns: whether the RAID set @name was successfully deactivated or not ++ * ++ * Note: This function will return an error for non-existing (or deactivated) RAID sets. + * + * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_REMOVE_DEACTIVATE + */ +-- +1.8.3.1 + diff --git a/0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch b/0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch new file mode 100644 index 0000000..28a3d9d --- /dev/null +++ b/0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch @@ -0,0 +1,61 @@ +From 5c12914d465edf608a4596bff4e4caa70897b7fe Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 2 Jun 2020 10:46:31 +0200 +Subject: [PATCH 165/193] mdraid: Do not try to activate already active MDRAID + devices + +--- + src/plugins/mdraid.c | 16 ++++++++++++++++ + tests/mdraid_test.py | 5 +++++ + 2 files changed, 21 insertions(+) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index e5be1b1..af5f913 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -720,10 +720,26 @@ gboolean bd_md_activate (const gchar *raid_spec, const gchar **members, const gc + guint argv_top = 0; + guint i = 0; + gboolean ret = FALSE; ++ BDMDDetailData *data = NULL; + + if (!check_deps (&avail_deps, DEPS_MDADM_MASK, deps, DEPS_LAST, &deps_check_lock, error)) + return FALSE; + ++ if (raid_spec) { ++ data = bd_md_detail (raid_spec, error); ++ if (!data) ++ g_clear_error (error); ++ else { ++ bd_utils_log_format (BD_UTILS_LOG_INFO, ++ "RAID array '%s' is already active with %"G_GUINT64_FORMAT" devices" ++ " (%"G_GUINT64_FORMAT" active, %"G_GUINT64_FORMAT" spare)", ++ raid_spec, data->total_devices, ++ data->active_devices, data->spare_devices); ++ bd_md_detail_data_free (data); ++ return TRUE; ++ } ++ } ++ + /* mdadm, --assemble, raid_spec/--scan, --run, --uuid=uuid, member1, member2,..., NULL*/ + argv = g_new0 (const gchar*, num_members + 6); + +diff --git a/tests/mdraid_test.py b/tests/mdraid_test.py +index 0b2bdc9..9c6cd17 100644 +--- a/tests/mdraid_test.py ++++ b/tests/mdraid_test.py +@@ -245,6 +245,11 @@ class MDTestActivateDeactivate(MDTestCase): + [self.loop_dev, self.loop_dev2, self.loop_dev3], None) + self.assertTrue(succ) + ++ # try to activate again, should not fail, just no-op ++ succ = BlockDev.md_activate("bd_test_md", ++ [self.loop_dev, self.loop_dev2, self.loop_dev3], None) ++ self.assertTrue(succ) ++ + # try to deactivate using the node instead of name + with wait_for_action("resync"): + succ = BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_md")) +-- +1.8.3.1 + diff --git a/0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch b/0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch new file mode 100644 index 0000000..05c376c --- /dev/null +++ b/0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch @@ -0,0 +1,25 @@ +From 93b0a8881790097e2b4c3116fe9af38f237fb8cc Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 2 Jun 2020 16:15:18 +0200 +Subject: [PATCH 167/193] lvm: Add missing attribute to bd_lvm_pvdata_copy in + LVM DBUs plugin + +--- + src/plugins/lvm-dbus.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index 222597b..454fc78 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -100,6 +100,7 @@ BDLVMPVdata* bd_lvm_pvdata_copy (BDLVMPVdata *data) { + new_data->pv_name = g_strdup (data->pv_name); + new_data->pv_uuid = g_strdup (data->pv_uuid); + new_data->pv_free = data->pv_free; ++ new_data->pv_size = data->pv_size; + new_data->pe_start = data->pe_start; + new_data->vg_name = g_strdup (data->vg_name); + new_data->vg_uuid = g_strdup (data->vg_uuid); +-- +1.8.3.1 + diff --git a/0004-module.c-Fix-error-message-when-loading-module-witho.patch b/0004-module.c-Fix-error-message-when-loading-module-witho.patch new file mode 100644 index 0000000..773bde9 --- /dev/null +++ b/0004-module.c-Fix-error-message-when-loading-module-witho.patch @@ -0,0 +1,37 @@ +From be58ebe20fd9fdfc2db7bdd99a55eff835cef23a Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 10 Jun 2020 14:31:15 +0200 +Subject: [PATCH 184/193] module.c: Fix error message when loading module + without options + +Lets avoid error messages like "Failed to load the module 'kvdo' +with options '(null)'". +--- + src/utils/module.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/src/utils/module.c b/src/utils/module.c +index 988f603..eb3f765 100644 +--- a/src/utils/module.c ++++ b/src/utils/module.c +@@ -167,9 +167,14 @@ gboolean bd_utils_load_kernel_module (const gchar *module_name, const gchar *opt + ret = kmod_module_probe_insert_module (mod, KMOD_PROBE_FAIL_ON_LOADED, + options, NULL, NULL, NULL); + if (ret < 0) { +- g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL, +- "Failed to load the module '%s' with options '%s': %s", +- module_name, options, strerror_l (-ret, c_locale)); ++ if (options) ++ g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL, ++ "Failed to load the module '%s' with options '%s': %s", ++ module_name, options, strerror_l (-ret, c_locale)); ++ else ++ g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL, ++ "Failed to load the module '%s': %s", ++ module_name, strerror_l (-ret, c_locale)); + kmod_module_unref (mod); + kmod_unref (ctx); + freelocale (c_locale); +-- +1.8.3.1 + diff --git a/0005-exec-Fix-setting-locale-for-util-calls.patch b/0005-exec-Fix-setting-locale-for-util-calls.patch new file mode 100644 index 0000000..b536fc2 --- /dev/null +++ b/0005-exec-Fix-setting-locale-for-util-calls.patch @@ -0,0 +1,119 @@ +From f1b6e752d8836d23ebcdf6833b96e09678bda2c9 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 10 Jun 2020 17:03:28 +0200 +Subject: [PATCH 185/193] exec: Fix setting locale for util calls + +This actually fixes two issue. The _utils_exec_and_report_progress +function didn't set the LC_ALL=C environment variable to make sure +we get output in English. And also we shouldn't use setenv in the +GSpawnChildSetupFunc, it's actually example of what not to do in +g_spawn_async documentation. This fix uses g_environ_setenv and +passes the new environment to the g_spawn call. +--- + src/utils/exec.c | 26 +++++++++++++++++--------- + tests/utils_test.py | 7 +++++++ + 2 files changed, 24 insertions(+), 9 deletions(-) + +diff --git a/src/utils/exec.c b/src/utils/exec.c +index 9293930..37bd960 100644 +--- a/src/utils/exec.c ++++ b/src/utils/exec.c +@@ -140,11 +140,6 @@ static void log_done (guint64 task_id, gint exit_code) { + return; + } + +-static void set_c_locale(gpointer user_data __attribute__((unused))) { +- if (setenv ("LC_ALL", "C", 1) != 0) +- g_warning ("Failed to set LC_ALL=C for a child process!"); +-} +- + /** + * bd_utils_exec_and_report_error: + * @argv: (array zero-terminated=1): the argv array for the call +@@ -194,6 +189,8 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr + const BDExtraArg **extra_p = NULL; + gint exit_status = 0; + guint i = 0; ++ gchar **old_env = NULL; ++ gchar **new_env = NULL; + + if (extra) { + args_len = g_strv_length ((gchar **) argv); +@@ -219,16 +216,20 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr + args[i] = NULL; + } + ++ old_env = g_get_environ (); ++ new_env = g_environ_setenv (old_env, "LC_ALL", "C", TRUE); ++ + task_id = log_running (args ? args : argv); +- success = g_spawn_sync (NULL, args ? (gchar **) args : (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH, +- (GSpawnChildSetupFunc) set_c_locale, NULL, +- &stdout_data, &stderr_data, &exit_status, error); ++ success = g_spawn_sync (NULL, args ? (gchar **) args : (gchar **) argv, new_env, G_SPAWN_SEARCH_PATH, ++ NULL, NULL, &stdout_data, &stderr_data, &exit_status, error); + if (!success) { + /* error is already populated from the call */ ++ g_strfreev (new_env); + g_free (stdout_data); + g_free (stderr_data); + return FALSE; + } ++ g_strfreev (new_env); + + /* g_spawn_sync set the status in the same way waitpid() does, we need + to get the process exit code manually (this is similar to calling +@@ -297,6 +298,8 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt + gboolean err_done = FALSE; + GString *stdout_data = g_string_new (NULL); + GString *stderr_data = g_string_new (NULL); ++ gchar **old_env = NULL; ++ gchar **new_env = NULL; + + /* TODO: share this code between functions */ + if (extra) { +@@ -325,7 +328,10 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt + + task_id = log_running (args ? args : argv); + +- ret = g_spawn_async_with_pipes (NULL, args ? (gchar**) args : (gchar**) argv, NULL, ++ old_env = g_get_environ (); ++ new_env = g_environ_setenv (old_env, "LC_ALL", "C", TRUE); ++ ++ ret = g_spawn_async_with_pipes (NULL, args ? (gchar**) args : (gchar**) argv, new_env, + G_SPAWN_DEFAULT|G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, &pid, NULL, &out_fd, &err_fd, error); + +@@ -333,9 +339,11 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt + /* error is already populated */ + g_string_free (stdout_data, TRUE); + g_string_free (stderr_data, TRUE); ++ g_strfreev (new_env); + g_free (args); + return FALSE; + } ++ g_strfreev (new_env); + + args_str = g_strjoinv (" ", args ? (gchar **) args : (gchar **) argv); + msg = g_strdup_printf ("Started '%s'", args_str); +diff --git a/tests/utils_test.py b/tests/utils_test.py +index 4bec3db..2bec5ed 100644 +--- a/tests/utils_test.py ++++ b/tests/utils_test.py +@@ -170,6 +170,13 @@ class UtilsExecLoggingTest(UtilsTestCase): + # exit code != 0 + self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util-fail", "1.1", "version", "Version:\\s(.*)")) + ++ @tag_test(TestTags.NOSTORAGE, TestTags.CORE) ++ def test_exec_locale(self): ++ """Verify that setting locale for exec functions works as expected""" ++ ++ succ, out = BlockDev.utils_exec_and_capture_output(["locale"]) ++ self.assertTrue(succ) ++ self.assertIn("LC_ALL=C", out) + + class UtilsDevUtilsTestCase(UtilsTestCase): + @tag_test(TestTags.NOSTORAGE, TestTags.CORE) +-- +1.8.3.1 + diff --git a/0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch b/0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch new file mode 100644 index 0000000..cfc55ef --- /dev/null +++ b/0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch @@ -0,0 +1,28 @@ +From dff4f13d20e7371cd55df7aab7a1800c41e3d39b Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 29 Jun 2020 14:40:57 +0200 +Subject: [PATCH 188/193] lvm: Fix checking for LVM VDO dependencies + +We also need to check for the LVM tools availability when checking +for BD_LVM_TECH_VDO availability. +--- + src/plugins/lvm.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c +index 32ad55c..2bd7782 100644 +--- a/src/plugins/lvm.c ++++ b/src/plugins/lvm.c +@@ -329,7 +329,8 @@ gboolean bd_lvm_is_tech_avail (BDLVMTech tech, guint64 mode, GError **error) { + return TRUE; + case BD_LVM_TECH_VDO: + return check_features (&avail_features, FEATURES_VDO_MASK, features, FEATURES_LAST, &deps_check_lock, error) && +- check_module_deps (&avail_module_deps, MODULE_DEPS_VDO_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error); ++ check_module_deps (&avail_module_deps, MODULE_DEPS_VDO_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error) && ++ check_deps (&avail_deps, DEPS_LVM_MASK, deps, DEPS_LAST, &deps_check_lock, error); + default: + /* everything is supported by this implementation of the plugin */ + return check_deps (&avail_deps, DEPS_LVM_MASK, deps, DEPS_LAST, &deps_check_lock, error); +-- +1.8.3.1 + diff --git a/0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch b/0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch new file mode 100644 index 0000000..7eda3b2 --- /dev/null +++ b/0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch @@ -0,0 +1,25 @@ +From c9e76261bc52cf2360ee7f43dcdfedfa7149b30e Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 30 Jun 2020 16:05:47 +0200 +Subject: [PATCH 189/193] lvm-dbus: Fix memory leak in bd_lvm_cache_attach + +--- + src/plugins/lvm-dbus.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index fa19d1a..327969d 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -3274,6 +3274,8 @@ gboolean bd_lvm_cache_attach (const gchar *vg_name, const gchar *data_lv, const + lv_id = g_strdup_printf ("%s/%s", vg_name, cache_pool_lv); + + call_lvm_obj_method_sync (lv_id, CACHE_POOL_INTF, "CacheLv", params, NULL, extra, TRUE, error); ++ g_free (lv_id); ++ g_free (lv_obj_path); + return ((*error) == NULL); + } + +-- +1.8.3.1 + diff --git a/0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch b/0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch new file mode 100644 index 0000000..fe1c9d1 --- /dev/null +++ b/0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch @@ -0,0 +1,24 @@ +From d9e8b2d43c84a664aa6a9b498047a865a1a38225 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 30 Jun 2020 16:06:01 +0200 +Subject: [PATCH 190/193] lvm: Fix memory leak bd_lvm_cache_create_cached_lv + +--- + src/plugins/lvm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c +index 0aae9ac..bec7656 100644 +--- a/src/plugins/lvm.c ++++ b/src/plugins/lvm.c +@@ -2475,6 +2475,7 @@ gboolean bd_lvm_cache_create_cached_lv (const gchar *vg_name, const gchar *lv_na + + success = bd_lvm_lvcreate (vg_name, lv_name, data_size, NULL, slow_pvs, NULL, error); + if (!success) { ++ g_free (name); + g_prefix_error (error, "Failed to create the data LV: "); + bd_utils_report_finished (progress_id, (*error)->message); + return FALSE; +-- +1.8.3.1 + diff --git a/libblockdev.spec b/libblockdev.spec index 48cb0fc..a3e0725 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -1,11 +1,20 @@ Name: libblockdev Version: 2.24 -Release: 2 +Release: 3 Summary: libblockdev is a C library supporting GObject introspection for manipulation of block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-1/%{name}-%{version}.tar.gz +Patch1: 0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch +Patch2: 0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch +Patch3: 0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch +Patch4: 0004-module.c-Fix-error-message-when-loading-module-witho.patch +Patch5: 0005-exec-Fix-setting-locale-for-util-calls.patch +Patch6: 0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch +Patch7: 0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch +Patch8: 0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch + BuildRequires: git glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel BuildRequires: device-mapper-devel dmraid-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel BuildRequires: cryptsetup-devel kmod-devel libxslt glib2-doc gtk-doc python2-devel python3-devel gobject-introspection-devel @@ -167,6 +176,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %changelog +* Tue Jul 28 2020 Ruijun Ge - 2.24-3 +- backport upstream patches + * Wed Jul 15 2020 Zhiqiang Liu - 2.24-2 - download tar file from source0 in spec -- Gitee From b0b2f5862c1c32a632dc8a8a5d9e3f407d0f870f Mon Sep 17 00:00:00 2001 From: geruijun Date: Wed, 29 Jul 2020 08:25:55 +0800 Subject: [PATCH 2/2] fix build error of unversioned obsoletes and remove unnecessary patches Signed-off-by: geruijun --- ...-activate-already-active-DMRAID-sets.patch | 96 ------------------- ...attribute-to-bd_lvm_pvdata_copy-in-L.patch | 0 ...y-to-activate-already-active-MDRAID-.patch | 61 ------------ ...or-message-when-loading-module-witho.patch | 0 ...ec-Fix-setting-locale-for-util-calls.patch | 0 ...ix-checking-for-LVM-VDO-dependencies.patch | 0 ...x-memory-leak-in-bd_lvm_cache_attach.patch | 0 ...y-leak-bd_lvm_cache_create_cached_lv.patch | 0 libblockdev.spec | 76 +++++++-------- 9 files changed, 37 insertions(+), 196 deletions(-) delete mode 100644 0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch rename 0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch => 0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch (100%) delete mode 100644 0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch rename 0004-module.c-Fix-error-message-when-loading-module-witho.patch => 0002-module.c-Fix-error-message-when-loading-module-witho.patch (100%) rename 0005-exec-Fix-setting-locale-for-util-calls.patch => 0003-exec-Fix-setting-locale-for-util-calls.patch (100%) rename 0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch => 0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch (100%) rename 0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch => 0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch (100%) rename 0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch => 0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch (100%) diff --git a/0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch b/0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch deleted file mode 100644 index 0d32d10..0000000 --- a/0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 663614825c5d7ba7a66631af0b0efd7037569337 Mon Sep 17 00:00:00 2001 -From: Vojtech Trefny -Date: Tue, 2 Jun 2020 10:20:35 +0200 -Subject: [PATCH 164/193] dm: Do not try to activate already active DMRAID sets - ---- - src/plugins/dm.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 43 insertions(+), 2 deletions(-) - -diff --git a/src/plugins/dm.c b/src/plugins/dm.c -index afb387c..af7e60b 100644 ---- a/src/plugins/dm.c -+++ b/src/plugins/dm.c -@@ -516,6 +516,29 @@ static void find_raid_sets_for_dev (const gchar *name, const gchar *uuid, gint m - } - } - } -+ -+static gboolean get_raid_set_status (struct raid_set *rs, GError **error) { -+ struct dm_task *dmt = NULL; -+ struct dm_info info; -+ gboolean ret; -+ -+ dmt = dm_task_create (DM_DEVICE_STATUS); -+ if (!dmt) { -+ g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK, -+ "Failed to create DM task"); -+ return FALSE; -+ } -+ -+ if (!dm_task_set_name (dmt, rs->name) || !dm_task_run (dmt) || !dm_task_get_info (dmt, &info)) { -+ /* the DM device doesn't exist or some weird error appeared, just assume the RAID set is not active */ -+ dm_task_destroy (dmt); -+ return FALSE; -+ } -+ -+ ret = info.exists; -+ dm_task_destroy (dmt); -+ return ret; -+} - #endif // WITH_BD_DMRAID - - /** -@@ -610,6 +633,7 @@ static gboolean change_set_by_name (const gchar *name, enum activate_type action - struct lib_context *lc = NULL; - struct raid_set *iter_rs = NULL; - struct raid_set *match_rs = NULL; -+ gboolean status = FALSE; - - lc = init_dmraid_stack (error); - if (!lc) -@@ -629,6 +653,19 @@ static gboolean change_set_by_name (const gchar *name, enum activate_type action - return FALSE; - } - -+ status = get_raid_set_status (match_rs, error); -+ if (!status && error) { -+ g_prefix_error (error, "Failed to get status for the RAID set '%s'", name); -+ libdmraid_exit (lc); -+ return FALSE; -+ } -+ -+ if (action == A_ACTIVATE && status) { -+ /* nothing to do here the set is already in the desired state */ -+ libdmraid_exit (lc); -+ return TRUE; -+ } -+ - rc = change_set (lc, action, match_rs); - if (!rc) { - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL, -@@ -647,7 +684,9 @@ static gboolean change_set_by_name (const gchar *name, enum activate_type action - * @name: name of the DM RAID set to activate - * @error: (out): variable to store error (if any) - * -- * Returns: whether the RAID set @name was successfully activate or not -+ * Returns: whether the RAID set @name was successfully activated or not -+ * -+ * Note: This is a no-op for already active RAID sets. - * - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_CREATE_ACTIVATE - */ -@@ -676,7 +715,9 @@ gboolean bd_dm_activate_raid_set (const gchar *name, GError **error) { - * @name: name of the DM RAID set to deactivate - * @error: (out): variable to store error (if any) - * -- * Returns: whether the RAID set @name was successfully deactivate or not -+ * Returns: whether the RAID set @name was successfully deactivated or not -+ * -+ * Note: This function will return an error for non-existing (or deactivated) RAID sets. - * - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_REMOVE_DEACTIVATE - */ --- -1.8.3.1 - diff --git a/0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch b/0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch similarity index 100% rename from 0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch rename to 0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch diff --git a/0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch b/0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch deleted file mode 100644 index 28a3d9d..0000000 --- a/0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 5c12914d465edf608a4596bff4e4caa70897b7fe Mon Sep 17 00:00:00 2001 -From: Vojtech Trefny -Date: Tue, 2 Jun 2020 10:46:31 +0200 -Subject: [PATCH 165/193] mdraid: Do not try to activate already active MDRAID - devices - ---- - src/plugins/mdraid.c | 16 ++++++++++++++++ - tests/mdraid_test.py | 5 +++++ - 2 files changed, 21 insertions(+) - -diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c -index e5be1b1..af5f913 100644 ---- a/src/plugins/mdraid.c -+++ b/src/plugins/mdraid.c -@@ -720,10 +720,26 @@ gboolean bd_md_activate (const gchar *raid_spec, const gchar **members, const gc - guint argv_top = 0; - guint i = 0; - gboolean ret = FALSE; -+ BDMDDetailData *data = NULL; - - if (!check_deps (&avail_deps, DEPS_MDADM_MASK, deps, DEPS_LAST, &deps_check_lock, error)) - return FALSE; - -+ if (raid_spec) { -+ data = bd_md_detail (raid_spec, error); -+ if (!data) -+ g_clear_error (error); -+ else { -+ bd_utils_log_format (BD_UTILS_LOG_INFO, -+ "RAID array '%s' is already active with %"G_GUINT64_FORMAT" devices" -+ " (%"G_GUINT64_FORMAT" active, %"G_GUINT64_FORMAT" spare)", -+ raid_spec, data->total_devices, -+ data->active_devices, data->spare_devices); -+ bd_md_detail_data_free (data); -+ return TRUE; -+ } -+ } -+ - /* mdadm, --assemble, raid_spec/--scan, --run, --uuid=uuid, member1, member2,..., NULL*/ - argv = g_new0 (const gchar*, num_members + 6); - -diff --git a/tests/mdraid_test.py b/tests/mdraid_test.py -index 0b2bdc9..9c6cd17 100644 ---- a/tests/mdraid_test.py -+++ b/tests/mdraid_test.py -@@ -245,6 +245,11 @@ class MDTestActivateDeactivate(MDTestCase): - [self.loop_dev, self.loop_dev2, self.loop_dev3], None) - self.assertTrue(succ) - -+ # try to activate again, should not fail, just no-op -+ succ = BlockDev.md_activate("bd_test_md", -+ [self.loop_dev, self.loop_dev2, self.loop_dev3], None) -+ self.assertTrue(succ) -+ - # try to deactivate using the node instead of name - with wait_for_action("resync"): - succ = BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_md")) --- -1.8.3.1 - diff --git a/0004-module.c-Fix-error-message-when-loading-module-witho.patch b/0002-module.c-Fix-error-message-when-loading-module-witho.patch similarity index 100% rename from 0004-module.c-Fix-error-message-when-loading-module-witho.patch rename to 0002-module.c-Fix-error-message-when-loading-module-witho.patch diff --git a/0005-exec-Fix-setting-locale-for-util-calls.patch b/0003-exec-Fix-setting-locale-for-util-calls.patch similarity index 100% rename from 0005-exec-Fix-setting-locale-for-util-calls.patch rename to 0003-exec-Fix-setting-locale-for-util-calls.patch diff --git a/0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch b/0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch similarity index 100% rename from 0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch rename to 0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch diff --git a/0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch b/0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch similarity index 100% rename from 0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch rename to 0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch diff --git a/0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch b/0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch similarity index 100% rename from 0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch rename to 0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch diff --git a/libblockdev.spec b/libblockdev.spec index a3e0725..69de633 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -6,14 +6,12 @@ License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-1/%{name}-%{version}.tar.gz -Patch1: 0001-dm-Do-not-try-to-activate-already-active-DMRAID-sets.patch -Patch2: 0002-mdraid-Do-not-try-to-activate-already-active-MDRAID-.patch -Patch3: 0003-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch -Patch4: 0004-module.c-Fix-error-message-when-loading-module-witho.patch -Patch5: 0005-exec-Fix-setting-locale-for-util-calls.patch -Patch6: 0006-lvm-Fix-checking-for-LVM-VDO-dependencies.patch -Patch7: 0007-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch -Patch8: 0008-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch +Patch1: 0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch +Patch2: 0002-module.c-Fix-error-message-when-loading-module-witho.patch +Patch3: 0003-exec-Fix-setting-locale-for-util-calls.patch +Patch4: 0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch +Patch5: 0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch +Patch6: 0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch BuildRequires: git glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel BuildRequires: device-mapper-devel dmraid-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel @@ -24,37 +22,37 @@ Requires: device-mapper-persistent-data lvm2-dbusd >= 2.02.156 ndctl gdisk Recommends: vdo kmod-kvdo Provides: %{name}-utils%{?_isa} %{name}-utils -Obsoletes: %{name}-utils +Obsoletes: %{name}-utils < %{version} Provides: %{name}-btrfs%{?_isa} %{name}-btrfs -Obsoletes: %{name}-btrfs +Obsoletes: %{name}-btrfs < %{version} Provides: %{name}-crypto%{?_isa} %{name}-crypto -Obsoletes: %{name}-crypto +Obsoletes: %{name}-crypto < %{version} Provides: %{name}-dm%{?_isa} %{name}-dm -Obsoletes: %{name}-dm +Obsoletes: %{name}-dm < %{version} Provides: %{name}-fs%{?_isa} %{name}-fs -Obsoletes: %{name}-fs +Obsoletes: %{name}-fs < %{version} Provides: %{name}-kbd%{?_isa} %{name}-kbd -Obsoletes: %{name}-kbd +Obsoletes: %{name}-kbd < %{version} Provides: %{name}-vdo%{?_isa} %{name}-vdo -Obsoletes: %{name}-vdo +Obsoletes: %{name}-vdo < %{version} Provides: %{name}-loop%{?_isa} %{name}-loop -Obsoletes: %{name}-loop +Obsoletes: %{name}-loop < %{version} Provides: %{name}-lvm%{?_isa} %{name}-lvm -Obsoletes: %{name}-lvm +Obsoletes: %{name}-lvm < %{version} Provides: %{name}-lvm-dbus%{?_isa} %{name}-lvm-dbus -Obsoletes: %{name}-lvm-dbus +Obsoletes: %{name}-lvm-dbus < %{version} Provides: %{name}-mdraid%{?_isa} %{name}-mdraid -Obsoletes: %{name}-mdraid +Obsoletes: %{name}-mdraid < %{version} Provides: %{name}-mpath%{?_isa} %{name}-mpath -Obsoletes: %{name}-mpath +Obsoletes: %{name}-mpath < %{version} Provides: %{name}-nvdimm%{?_isa} %{name}-nvdimm -Obsoletes: %{name}-nvdimm +Obsoletes: %{name}-nvdimm < %{version} Provides: %{name}-part%{?_isa} %{name}-part -Obsoletes: %{name}-part +Obsoletes: %{name}-part < %{version} Provides: %{name}-swap%{?_isa} %{name}-swap -Obsoletes: %{name}-swap +Obsoletes: %{name}-swap < %{version} Provides: %{name}-plugins-all%{?_isa} %{name}-plugins-all -Obsoletes: %{name}-plugins-all +Obsoletes: %{name}-plugins-all < %{version} %description libblockdev is a C library supporting GObject introspection for manipulation of block devices. @@ -67,35 +65,35 @@ Requires: %{name}%{?_isa} = %{version}-%{release} Requires: glib2-devel device-mapper-devel xfsprogs dosfstools dmraid-devel systemd-devel Provides: %{name}-btrfs-devel%{?_isa} %{name}-btrfs-devel -Obsoletes: %{name}-btrfs-devel +Obsoletes: %{name}-btrfs-devel < %{version} Provides: %{name}-crypto-devel%{?_isa} %{name}-crypto-devel -Obsoletes: %{name}-crypto-devel +Obsoletes: %{name}-crypto-devel < %{version} Provides: %{name}-dm-devel%{?_isa} %{name}-dm-devel -Obsoletes: %{name}-dm-devel +Obsoletes: %{name}-dm-devel < %{version} Provides: %{name}-fs-devel%{?_isa} %{name}-fs-devel -Obsoletes: %{name}-fs-devel +Obsoletes: %{name}-fs-devel < %{version} Provides: %{name}-kbd-devel%{?_isa} %{name}-kbd-devel -Obsoletes: %{name}-kbd-devel +Obsoletes: %{name}-kbd-devel < %{version} Provides: %{name}-loop-devel%{?_isa} %{name}-loop-devel -Obsoletes: %{name}-loop-devel +Obsoletes: %{name}-loop-devel < %{version} Provides: %{name}-lvm-devel%{?_isa} %{name}-lvm-devel -Obsoletes: %{name}-lvm-devel +Obsoletes: %{name}-lvm-devel < %{version} Provides: %{name}-lvm-dbus-devel%{?_isa} %{name}-lvm-dbus-devel -Obsoletes: %{name}-lvm-dbus-devel +Obsoletes: %{name}-lvm-dbus-devel < %{version} Provides: %{name}-mdraid-devel%{?_isa} %{name}-mdraid-devel -Obsoletes: %{name}-mdraid-devel +Obsoletes: %{name}-mdraid-devel < %{version} Provides: %{name}-mpath-devel%{?_isa} %{name}-mpath-devel -Obsoletes: %{name}-mpath-devel +Obsoletes: %{name}-mpath-devel < %{version} Provides: %{name}-nvdimm-devel%{?_isa} %{name}-nvdimm-devel -Obsoletes: %{name}-nvdimm-devel +Obsoletes: %{name}-nvdimm-devel < %{version} Provides: %{name}-part-devel%{?_isa} %{name}-part-devel -Obsoletes: %{name}-part-devel +Obsoletes: %{name}-part-devel < %{version} Provides: %{name}-swap-devel%{?_isa} %{name}-swap-devel -Obsoletes: %{name}-swap-devel +Obsoletes: %{name}-swap-devel < %{version} Provides: %{name}-vdo-devel%{?_isa} %{name}-vdo-devel -Obsoletes: %{name}-vdo-devel +Obsoletes: %{name}-vdo-devel < %{version} Provides: %{name}-utils-devel%{?_isa} %{name}-utils-devel -Obsoletes: %{name}-utils-devel +Obsoletes: %{name}-utils-devel < %{version} %description devel Libraries and header files for a set for utils(libblockdev,libblockdev-btrfs,libblockdev-crypto, -- Gitee