!19 Update to libblockdev-2.26-1

From: @wenchao-hao
Reviewed-by: @liuzhiqiang26
Signed-off-by: @liuzhiqiang26
This commit is contained in:
openeuler-ci-bot 2021-11-24 08:53:38 +00:00 committed by Gitee
commit d9ff7de33c
17 changed files with 11 additions and 391 deletions

View File

@ -1,119 +0,0 @@
From f1b6e752d8836d23ebcdf6833b96e09678bda2c9 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
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

View File

@ -1,30 +0,0 @@
From 6c0ae13b509975e67c65d690d388afccc78a0b63 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 25 Sep 2020 14:23:24 +0200
Subject: [PATCH 10/15] dm: Fix memory leak in the DM plugin and DM logging
redirect function
conflict:
1. there is no dm_logging.c in v2.24
Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
src/plugins/dm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/plugins/dm.c b/src/plugins/dm.c
index 93a47f4..e8f0f4e 100644
--- a/src/plugins/dm.c
+++ b/src/plugins/dm.c
@@ -246,6 +246,7 @@ gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error) {
if (!success) {
/* errror is already populated */
+ g_free (ret);
return NULL;
}
--
1.8.3.1

View File

@ -1,29 +0,0 @@
From 11e899c9f7256cd549e6a0a5ef607925b15cdb7a Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 25 Sep 2020 14:24:14 +0200
Subject: [PATCH 11/15] fs: Fix memory leak
Conflict:
1. due to context differences, we have adapted the patch.
Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
src/plugins/fs/mount.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/plugins/fs/mount.c b/src/plugins/fs/mount.c
index 43d64e8..98110aa 100644
--- a/src/plugins/fs/mount.c
+++ b/src/plugins/fs/mount.c
@@ -541,6 +541,7 @@ static gboolean run_as_user (MountFunc func, MountArgs *args, uid_t run_as_uid,
"Unknoen error while reading error.");
g_io_channel_unref (channel);
close (pipefd[0]);
+ g_free(error_msg);
return FALSE;
}
--
1.8.3.1

View File

@ -1,24 +0,0 @@
From bc7fddbe15f21eba45d55b3d9a9feaabf954a309 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 25 Sep 2020 14:26:24 +0200
Subject: [PATCH 12/15] kbd: Fix memory leak
---
src/plugins/kbd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/plugins/kbd.c b/src/plugins/kbd.c
index a2908ec..41593be 100644
--- a/src/plugins/kbd.c
+++ b/src/plugins/kbd.c
@@ -1254,6 +1254,7 @@ static gboolean get_cache_size_used (const gchar *cache_dev_sys, guint64 *size,
g_io_channel_unref (file);
if (!found) {
+ g_free (line);
g_set_error (error, BD_KBD_ERROR, BD_KBD_ERROR_BCACHE_INVAL,
"Failed to get cache usage data");
return FALSE;
--
1.8.3.1

View File

@ -1,24 +0,0 @@
From 696dd84099cc2144b7c6b530933bed01b5fbaac4 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 25 Sep 2020 14:26:37 +0200
Subject: [PATCH 13/15] lvm-dbus: Fix memory leak
---
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 b0efe7a..bf60141 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -2978,6 +2978,7 @@ gboolean bd_lvm_cache_detach (const gchar *vg_name, const gchar *cached_lv, gboo
lv_id = g_strdup_printf ("%s/%s", vg_name, cached_lv);
call_lvm_obj_method_sync (lv_id, CACHED_LV_INTF, "DetachCachePool", params, NULL, extra, TRUE, error);
g_free (lv_id);
+ g_free (cache_pool_name);
return ((*error) == NULL);
}
--
1.8.3.1

View File

@ -1,24 +0,0 @@
From d60f654d4547febf7c6ce5353a403ca0df60450c Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 25 Sep 2020 14:27:22 +0200
Subject: [PATCH 14/15] mdraid: Fix memory leak
---
src/plugins/mdraid.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
index 74af744..b97bc64 100644
--- a/src/plugins/mdraid.c
+++ b/src/plugins/mdraid.c
@@ -1332,6 +1332,7 @@ gchar* bd_md_name_from_node (const gchar *node, GError **error) {
continue;
}
node_name = g_path_get_basename (dev_path);
+ g_free (dev_path);
if (g_strcmp0 (node_name, node) == 0) {
found = TRUE;
name = g_path_get_basename (*path_p);
--
1.8.3.1

View File

@ -1,24 +0,0 @@
From 58e7484228fcfbffc439a9d5131a221dd9e35d5f Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 25 Sep 2020 14:27:54 +0200
Subject: [PATCH 15/15] swap: Fix memory leak
---
src/plugins/swap.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/plugins/swap.c b/src/plugins/swap.c
index 102780a..115f8fc 100644
--- a/src/plugins/swap.c
+++ b/src/plugins/swap.c
@@ -417,6 +417,7 @@ gboolean bd_swap_swapstatus (const gchar *device, GError **error) {
if (!real_device) {
/* the device doesn't exist and thus is not an active swap */
g_clear_error (error);
+ g_free (file_content);
return FALSE;
}
}
--
1.8.3.1

View File

@ -1,101 +0,0 @@
From 5528baef6ccc835a06c45f9db34a2c9c3f2dd940 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 16 Mar 2021 12:05:37 +0100
Subject: [PATCH] vdo: Do not use g_memdup in bd_vdo_stats_copy
g_memdup is deprecated and the replacement g_memdup2 is not yet
available so lets just do the copy manually.
Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
---
src/lib/plugin_apis/vdo.api | 17 ++++++++++++++++-
src/lib/plugin_apis/vdo.c | 17 ++++++++++++++++-
src/plugins/vdo.c | 17 ++++++++++++++++-
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/src/lib/plugin_apis/vdo.api b/src/lib/plugin_apis/vdo.api
index 936f8e0..312de4e 100644
--- a/src/lib/plugin_apis/vdo.api
+++ b/src/lib/plugin_apis/vdo.api
@@ -170,7 +170,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) {
* Deprecated: 2.24: Use LVM-VDO integration instead.
*/
BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) {
- return g_memdup (stats, sizeof (BDVDOStats));
+ if (stats == NULL)
+ return NULL;
+
+ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1);
+
+ new_stats->block_size = stats->block_size;
+ new_stats->logical_block_size = stats->logical_block_size;
+ new_stats->physical_blocks = stats->physical_blocks;
+ new_stats->data_blocks_used = stats->data_blocks_used;
+ new_stats->overhead_blocks_used = stats->overhead_blocks_used;
+ new_stats->logical_blocks_used = stats->logical_blocks_used;
+ new_stats->used_percent = stats->used_percent;
+ new_stats->saving_percent = stats->saving_percent;
+ new_stats->write_amplification_ratio = stats->write_amplification_ratio;
+
+ return new_stats;
}
GType bd_vdo_stats_get_type () {
diff --git a/src/lib/plugin_apis/vdo.c b/src/lib/plugin_apis/vdo.c
index 40563ee..3e23bbc 100644
--- a/src/lib/plugin_apis/vdo.c
+++ b/src/lib/plugin_apis/vdo.c
@@ -106,7 +106,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) {
* Deprecated: 2.24: Use LVM-VDO integration instead.
*/
BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) {
- return g_memdup (stats, sizeof (BDVDOStats));
+ if (stats == NULL)
+ return NULL;
+
+ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1);
+
+ new_stats->block_size = stats->block_size;
+ new_stats->logical_block_size = stats->logical_block_size;
+ new_stats->physical_blocks = stats->physical_blocks;
+ new_stats->data_blocks_used = stats->data_blocks_used;
+ new_stats->overhead_blocks_used = stats->overhead_blocks_used;
+ new_stats->logical_blocks_used = stats->logical_blocks_used;
+ new_stats->used_percent = stats->used_percent;
+ new_stats->saving_percent = stats->saving_percent;
+ new_stats->write_amplification_ratio = stats->write_amplification_ratio;
+
+ return new_stats;
}
GType bd_vdo_stats_get_type () {
diff --git a/src/plugins/vdo.c b/src/plugins/vdo.c
index 2352394..a9eb54a 100644
--- a/src/plugins/vdo.c
+++ b/src/plugins/vdo.c
@@ -81,7 +81,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) {
}
BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) {
- return g_memdup (stats, sizeof (BDVDOStats));
+ if (stats == NULL)
+ return NULL;
+
+ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1);
+
+ new_stats->block_size = stats->block_size;
+ new_stats->logical_block_size = stats->logical_block_size;
+ new_stats->physical_blocks = stats->physical_blocks;
+ new_stats->data_blocks_used = stats->data_blocks_used;
+ new_stats->overhead_blocks_used = stats->overhead_blocks_used;
+ new_stats->logical_blocks_used = stats->logical_blocks_used;
+ new_stats->used_percent = stats->used_percent;
+ new_stats->saving_percent = stats->saving_percent;
+ new_stats->write_amplification_ratio = stats->write_amplification_ratio;
+
+ return new_stats;
}
--
2.27.0

Binary file not shown.

BIN
libblockdev-2.26.tar.gz Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
Name: libblockdev
Version: 2.24
Release: 8
Version: 2.26
Release: 1
Summary: libblockdev is a C library supporting GObject introspection for manipulation of block devices
License: LGPLv2+
URL: https://github.com/storaged-project/libblockdev
@ -8,20 +8,12 @@ Source0: https://github.com/storaged-project/libblockdev/releases/download/%{ver
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
Patch7: 0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch
Patch8: 0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch
Patch9: 0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch
Patch10: 0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch
Patch11: 0011-fs-Fix-memory-leak.patch
Patch12: 0012-kbd-Fix-memory-leak.patch
Patch13: 0013-lvm-dbus-Fix-memory-leak.patch
Patch14: 0014-mdraid-Fix-memory-leak.patch
Patch15: 0015-swap-Fix-memory-leak.patch
Patch16: 0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch
Patch3: 0003-lvm-Fix-checking-for-LVM-VDO-dependencies.patch
Patch4: 0004-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch
Patch5: 0005-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch
Patch6: 0006-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch
Patch7: 0007-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch
Patch8: 0008-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch
BuildRequires: 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
@ -172,6 +164,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%changelog
* Wed Nov 17 Wenchao Hao <haowenchao@huawei.com> - 2.26-1
- update to libblockdev-2.26
* Tue Sep 28 2021 Wenchao Hao <haowenchao@huawei.com> - 2.24-8
- NOP:nothing but to make it able to sync between differnt branches