import RHEL 10 Beta libblockdev-3.1.0-7.el10

This commit is contained in:
eabdullin 2024-11-20 13:20:48 +00:00
parent a3a7bc4e2c
commit 1ed559f41d
15 changed files with 12508 additions and 2827 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
SOURCES/libblockdev-2.28.tar.gz
libblockdev-3.1.0.tar.gz
smart-tests.tar.gz

View File

@ -0,0 +1,107 @@
From 9ca6684291e8a30cce2158285078664f8c771638 Mon Sep 17 00:00:00 2001
From: guazhang <guazhang@redhat.com>
Date: Wed, 27 Mar 2024 11:53:21 +0800
Subject: [PATCH 1/3] fixed md_create issue #1013
---
src/python/gi/overrides/BlockDev.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/python/gi/overrides/BlockDev.py b/src/python/gi/overrides/BlockDev.py
index d830e485..25852f66 100644
--- a/src/python/gi/overrides/BlockDev.py
+++ b/src/python/gi/overrides/BlockDev.py
@@ -1018,7 +1018,7 @@ __all__.append("md_get_superblock_size")
_md_create = BlockDev.md_create
@override(BlockDev.md_create)
-def md_create(device_name, level, disks, spares=0, version=None, bitmap=False, chunk_size=0, extra=None, **kwargs):
+def md_create(device_name, level, disks, spares=0, version=None, bitmap=None, chunk_size=0, extra=None, **kwargs):
extra = _get_extra(extra, kwargs)
return _md_create(device_name, level, disks, spares, version, bitmap, chunk_size, extra)
__all__.append("md_create")
--
2.45.0
From 829cea63351c8d5264573eb3d8953cd0069d2566 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 3 Apr 2024 15:58:04 +0200
Subject: [PATCH 2/3] crypto: Fix double free in bd_crypto_luks_remove_key
---
src/plugins/crypto.c | 1 -
tests/crypto_test.py | 6 ++++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c
index 5120ec57..f764593f 100644
--- a/src/plugins/crypto.c
+++ b/src/plugins/crypto.c
@@ -1480,7 +1480,6 @@ gboolean bd_crypto_luks_remove_key (const gchar *device, BDCryptoKeyslotContext
return FALSE;
}
- crypt_safe_free (key_buf);
crypt_free (cd);
bd_utils_report_finished (progress_id, "Completed");
return TRUE;
diff --git a/tests/crypto_test.py b/tests/crypto_test.py
index 6fe15a07..54ec0176 100644
--- a/tests/crypto_test.py
+++ b/tests/crypto_test.py
@@ -524,6 +524,9 @@ class CryptoTestRemoveKey(CryptoTestCase):
succ = BlockDev.crypto_luks_add_key(self.loop_dev, ctx, nctx2)
self.assertTrue(succ)
+ nctx3 = BlockDev.CryptoKeyslotContext(keyfile=self.keyfile)
+ succ = BlockDev.crypto_luks_add_key(self.loop_dev, ctx, nctx3)
+
with self.assertRaises(GLib.GError):
wctx = BlockDev.CryptoKeyslotContext(passphrase="wrong-passphrase")
BlockDev.crypto_luks_remove_key(self.loop_dev, wctx)
@@ -534,6 +537,9 @@ class CryptoTestRemoveKey(CryptoTestCase):
succ = BlockDev.crypto_luks_remove_key(self.loop_dev, nctx2)
self.assertTrue(succ)
+ succ = BlockDev.crypto_luks_remove_key(self.loop_dev, nctx3)
+ self.assertTrue(succ)
+
@tag_test(TestTags.SLOW)
def test_luks_remove_key(self):
self._remove_key(self._luks_format)
--
2.45.0
From c50d43b4d8e9d10b410265c72d2bbf5372eb41e6 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 16 Apr 2024 12:02:27 +0200
Subject: [PATCH 3/3] tests: Fix running tests without ntfsprogs
---
tests/fs_tests/generic_test.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/fs_tests/generic_test.py b/tests/fs_tests/generic_test.py
index fb890229..df25e25a 100644
--- a/tests/fs_tests/generic_test.py
+++ b/tests/fs_tests/generic_test.py
@@ -342,8 +342,12 @@ class CanResizeRepairCheckLabel(GenericNoDevTestCase):
self.assertEqual(util, "resize2fs")
avail, util = BlockDev.fs_can_get_min_size("ntfs")
- self.assertTrue(avail)
- self.assertEqual(util, None)
+ if self.ntfs_avail:
+ self.assertTrue(avail)
+ self.assertEqual(util, None)
+ else:
+ self.assertFalse(avail)
+ self.assertEqual(util, "ntfsresize")
with self.assertRaises(GLib.GError):
BlockDev.fs_can_get_min_size("xfs")
--
2.45.0

View File

@ -0,0 +1,86 @@
From 91c22078e9d369d266c044f949b65ebd611f31b0 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 21 May 2024 15:42:29 +0200
Subject: [PATCH] utils: Check also for aliases in bd_utils_have_kernel_module
We want to return true for ext2/3 which are now supported by ext4
module.
---
src/utils/module.c | 12 +++++++++++-
tests/utils_test.py | 22 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/utils/module.c b/src/utils/module.c
index 66d02343..71d53b46 100644
--- a/src/utils/module.c
+++ b/src/utils/module.c
@@ -85,6 +85,7 @@ gboolean bd_utils_have_kernel_module (const gchar *module_name, GError **error)
gint ret = 0;
struct kmod_ctx *ctx = NULL;
struct kmod_module *mod = NULL;
+ struct kmod_list *list = NULL;
gchar *null_config = NULL;
const gchar *path = NULL;
gboolean have_path = FALSE;
@@ -100,21 +101,30 @@ gboolean bd_utils_have_kernel_module (const gchar *module_name, GError **error)
}
set_kmod_logging (ctx);
- ret = kmod_module_new_from_name (ctx, module_name, &mod);
+ ret = kmod_module_new_from_lookup (ctx, module_name, &list);
if (ret < 0) {
g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL,
"Failed to get the module: %s", strerror_l (-ret, c_locale));
kmod_unref (ctx);
+ kmod_module_unref_list (list);
+ freelocale (c_locale);
+ return FALSE;
+ }
+
+ if (list == NULL) {
+ kmod_unref (ctx);
freelocale (c_locale);
return FALSE;
}
+ mod = kmod_module_get_module (list);
path = kmod_module_get_path (mod);
have_path = (path != NULL) && (g_strcmp0 (path, "") != 0);
if (!have_path) {
builtin = kmod_module_get_initstate (mod) == KMOD_MODULE_BUILTIN;
}
kmod_module_unref (mod);
+ kmod_module_unref_list (list);
kmod_unref (ctx);
freelocale (c_locale);
diff --git a/tests/utils_test.py b/tests/utils_test.py
index d656d309..372228f8 100644
--- a/tests/utils_test.py
+++ b/tests/utils_test.py
@@ -484,3 +484,25 @@ def test_initialization(self):
self.assertEqual(ver.major, ver2.major)
self.assertEqual(ver.minor, ver2.minor)
self.assertEqual(ver.micro, ver2.micro)
+
+
+class UtilsKernelModuleTest(UtilsTestCase):
+ @tag_test(TestTags.NOSTORAGE, TestTags.CORE)
+ def test_have_kernel_module(self):
+ """ Test checking for kernel modules """
+
+ have = BlockDev.utils_have_kernel_module("definitely-not-existing-kernel-module")
+ self.assertFalse(have)
+
+ # loop should be everywhere, right?
+ have = BlockDev.utils_have_kernel_module("loop")
+ self.assertTrue(have)
+
+ # lets check some filesystems support and compare with 'modprobe' results
+ for fs in ("ext2", "ext3", "ext4", "xfs", "btrfs"):
+ have_fs = BlockDev.utils_have_kernel_module(fs)
+ ret, _out, _err = run_command("modprobe --dry-run %s" % fs)
+ if ret == 0:
+ self.assertTrue(have_fs)
+ else:
+ self.assertFalse(have_fs)

View File

@ -0,0 +1,65 @@
From 7afe64265c9fc6ac67bfc412e43d00e5a21c867a Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 22 Mar 2024 14:54:15 +0100
Subject: [PATCH] lvm-dbus: Fix passing size for pvresize over DBus
"u" is UINT32, we need to use "t" for UINT64
---
src/plugins/lvm-dbus.c | 2 +-
tests/lvm_dbus_tests.py | 6 ++++++
tests/lvm_test.py | 6 ++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index 5ecf47f6..ff9eb24b 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -1776,7 +1776,7 @@ gboolean bd_lvm_pvresize (const gchar *device, guint64 size, const BDExtraArg **
if (!obj_path)
return FALSE;
- params = g_variant_new ("(u)", size);
+ params = g_variant_new ("(t)", size);
return call_lvm_method_sync (obj_path, PV_INTF, "ReSize", params, NULL, extra, TRUE, error);
}
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
index 013a29c3..c179a82c 100644
--- a/tests/lvm_dbus_tests.py
+++ b/tests/lvm_dbus_tests.py
@@ -431,9 +431,15 @@ def test_pvresize(self):
succ = BlockDev.lvm_pvresize(self.loop_dev, 200 * 1024**2, None)
self.assertTrue(succ)
+ info = BlockDev.lvm_pvinfo(self.loop_dev)
+ self.assertEqual(info.pv_size, 200 * 1024**2)
+
succ = BlockDev.lvm_pvresize(self.loop_dev, 200 * 1024**3, None)
self.assertTrue(succ)
+ info = BlockDev.lvm_pvinfo(self.loop_dev)
+ self.assertEqual(info.pv_size, 200 * 1024**3)
+
@unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
class LvmTestPVscan(LvmPVonlyTestCase):
def test_pvscan(self):
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
index e7800d8f..261615e9 100644
--- a/tests/lvm_test.py
+++ b/tests/lvm_test.py
@@ -434,9 +434,15 @@ def test_pvresize(self):
succ = BlockDev.lvm_pvresize(self.loop_dev, 200 * 1024**2, None)
self.assertTrue(succ)
+ info = BlockDev.lvm_pvinfo(self.loop_dev)
+ self.assertEqual(info.pv_size, 200 * 1024**2)
+
succ = BlockDev.lvm_pvresize(self.loop_dev, 200 * 1024**3, None)
self.assertTrue(succ)
+ info = BlockDev.lvm_pvinfo(self.loop_dev)
+ self.assertEqual(info.pv_size, 200 * 1024**3)
+
class LvmTestPVscan(LvmPVonlyTestCase):
def test_pvscan(self):
"""Verify that pvscan runs without issues with cache or without"""

View File

@ -0,0 +1,571 @@
From 5db24c0542a6c7ee44e2d487969ef71170d9cb33 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 2 Jul 2024 12:30:42 +0200
Subject: [PATCH 1/2] lvm: Check for dm-vdo instead of kvdo module for VDO
support
VDO is available in the upstream kernel since 6.9 as dm-vdo so we
should check for it instead of the out-of-tree kvdo module.
---
src/plugins/lvm-dbus.c | 2 +-
src/plugins/lvm.c | 2 +-
tests/lvm_dbus_tests.py | 4 ++--
tests/lvm_test.py | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index d080b389..0c017306 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -321,7 +321,7 @@ static const UtilFeatureDep features[FEATURES_LAST] = {
#define MODULE_DEPS_VDO_MASK (1 << MODULE_DEPS_VDO)
#define MODULE_DEPS_LAST 1
-static const gchar*const module_deps[MODULE_DEPS_LAST] = { "kvdo" };
+static const gchar*const module_deps[MODULE_DEPS_LAST] = { "dm-vdo" };
/**
* bd_lvm_init:
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
index 361a084b..dc7491a7 100644
--- a/src/plugins/lvm.c
+++ b/src/plugins/lvm.c
@@ -329,7 +329,7 @@ static const UtilFeatureDep features[FEATURES_LAST] = {
#define MODULE_DEPS_VDO_MASK (1 << MODULE_DEPS_VDO)
#define MODULE_DEPS_LAST 1
-static const gchar*const module_deps[MODULE_DEPS_LAST] = { "kvdo" };
+static const gchar*const module_deps[MODULE_DEPS_LAST] = { "dm-vdo" };
#define UNUSED __attribute__((unused))
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
index fc270cb5..9f302611 100644
--- a/tests/lvm_dbus_tests.py
+++ b/tests/lvm_dbus_tests.py
@@ -2029,11 +2029,11 @@ class LVMVDOTest(LVMTestCase):
@classmethod
def setUpClass(cls):
- if not BlockDev.utils_have_kernel_module("kvdo"):
+ if not BlockDev.utils_have_kernel_module("dm-vdo"):
raise unittest.SkipTest("VDO kernel module not available, skipping.")
try:
- BlockDev.utils_load_kernel_module("kvdo")
+ BlockDev.utils_load_kernel_module("dm-vdo")
except GLib.GError as e:
if "File exists" not in e.message:
raise unittest.SkipTest("cannot load VDO kernel module, skipping.")
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
index a4c90172..b1d65baf 100644
--- a/tests/lvm_test.py
+++ b/tests/lvm_test.py
@@ -1933,11 +1933,11 @@ class LVMVDOTest(LVMTestCase):
@classmethod
def setUpClass(cls):
- if not BlockDev.utils_have_kernel_module("kvdo"):
+ if not BlockDev.utils_have_kernel_module("dm-vdo"):
raise unittest.SkipTest("VDO kernel module not available, skipping.")
try:
- BlockDev.utils_load_kernel_module("kvdo")
+ BlockDev.utils_load_kernel_module("dm-vdo")
except GLib.GError as e:
if "File exists" not in e.message:
raise unittest.SkipTest("cannot load VDO kernel module, skipping.")
--
2.45.2
From 6cf4de50d385d801c1936fc67ee2902f9c60e04e Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 2 Jul 2024 12:32:46 +0200
Subject: [PATCH 2/2] lvm: Get VDO stats from device mapper instead of
/sys/kvdo
The /sys/kvdo API has been removed so we need to get the full
statistics using libdevmapper now.
---
configure.ac | 4 +
dist/libblockdev.spec.in | 2 +
src/lib/plugin_apis/lvm.api | 6 +-
src/plugins/Makefile.am | 8 +-
src/plugins/lvm-dbus.c | 18 +--
src/plugins/lvm.c | 18 +--
src/plugins/vdo_stats.c | 213 ++++++++++++++++++++++--------------
tests/lvm_dbus_tests.py | 4 +-
tests/lvm_test.py | 10 +-
9 files changed, 175 insertions(+), 108 deletions(-)
diff --git a/configure.ac b/configure.ac
index 02b26e3e..cc875bb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,6 +193,10 @@ AS_IF([test "x$with_dm" != "xno" -o "x$with_lvm" != "xno" -o "x$with_lvm_dbus" !
[LIBBLOCKDEV_PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.93])],
[])
+AS_IF([test "x$with_lvm" != "xno" -o "x$with_lvm_dbus" != "xno"],
+ [LIBBLOCKDEV_PKG_CHECK_MODULES([YAML], [yaml-0.1])],
+ [])
+
AS_IF([test "x$with_part" != "xno"],
[LIBBLOCKDEV_PKG_CHECK_MODULES([FDISK], [fdisk >= 2.31.0])],
[])
diff --git a/dist/libblockdev.spec.in b/dist/libblockdev.spec.in
index 768aa0c0..e8703411 100644
--- a/dist/libblockdev.spec.in
+++ b/dist/libblockdev.spec.in
@@ -290,6 +290,7 @@ with the libblockdev-loop plugin/library.
%if %{with_lvm}
%package lvm
BuildRequires: device-mapper-devel
+BuildRequires: libyaml-devel
Summary: The LVM plugin for the libblockdev library
Requires: %{name}-utils%{?_isa} = %{version}-%{release}
Requires: lvm2
@@ -312,6 +313,7 @@ with the libblockdev-lvm plugin/library.
%if %{with_lvm_dbus}
%package lvm-dbus
BuildRequires: device-mapper-devel
+BuildRequires: libyaml-devel
Summary: The LVM plugin for the libblockdev library
Requires: %{name}-utils%{?_isa} = %{version}-%{release}
Requires: lvm2-dbusd >= 2.02.156
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
index 2152aa79..3dd5ea4a 100644
--- a/src/lib/plugin_apis/lvm.api
+++ b/src/lib/plugin_apis/lvm.api
@@ -1965,10 +1965,10 @@ BDLVMVDOWritePolicy bd_lvm_get_vdo_write_policy_from_str (const gchar *policy_st
* statistics or %NULL in case of error
* (@error gets populated in those cases)
*
- * Statistics are collected from the values exposed by the kernel `kvdo` module
- * at the `/sys/kvdo/<VDO_NAME>/statistics/` path.
+ * Statistics are collected from the values exposed by the kernel `dm-vdo` module.
+ *
* Some of the keys are computed to mimic the information produced by the vdo tools.
- * Please note the contents of the hashtable may vary depending on the actual kvdo module version.
+ * Please note the contents of the hashtable may vary depending on the actual dm-vdo module version.
*
* Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY
*/
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 0195e9e1..71bacb7c 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -97,16 +97,16 @@ libbd_loop_la_SOURCES = loop.c loop.h
endif
if WITH_LVM
-libbd_lvm_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror
-libbd_lvm_la_LIBADD = ${builddir}/../utils/libbd_utils.la -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS)
+libbd_lvm_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) $(YAML_CFLAGS) -Wall -Wextra -Werror
+libbd_lvm_la_LIBADD = ${builddir}/../utils/libbd_utils.la -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) $(YAML_LIBS)
libbd_lvm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*'
libbd_lvm_la_CPPFLAGS = -I${builddir}/../../include/
libbd_lvm_la_SOURCES = lvm.c lvm.h check_deps.c check_deps.h dm_logging.c dm_logging.h vdo_stats.c vdo_stats.h
endif
if WITH_LVM_DBUS
-libbd_lvm_dbus_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror
-libbd_lvm_dbus_la_LIBADD = ${builddir}/../utils/libbd_utils.la -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS)
+libbd_lvm_dbus_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) $(YAML_CFLAGS) -Wall -Wextra -Werror
+libbd_lvm_dbus_la_LIBADD = ${builddir}/../utils/libbd_utils.la -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) $(YAML_LIBS)
libbd_lvm_dbus_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*'
libbd_lvm_dbus_la_CPPFLAGS = -I${builddir}/../../include/
libbd_lvm_dbus_la_SOURCES = lvm-dbus.c lvm.h check_deps.c check_deps.h dm_logging.c dm_logging.h vdo_stats.c vdo_stats.h
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index 0c017306..92d90718 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -4701,10 +4701,10 @@ BDLVMVDOWritePolicy bd_lvm_get_vdo_write_policy_from_str (const gchar *policy_st
* statistics or %NULL in case of error
* (@error gets populated in those cases)
*
- * Statistics are collected from the values exposed by the kernel `kvdo` module
- * at the `/sys/kvdo/<VDO_NAME>/statistics/` path.
+ * Statistics are collected from the values exposed by the kernel `dm-vdo` module.
+ *
* Some of the keys are computed to mimic the information produced by the vdo tools.
- * Please note the contents of the hashtable may vary depending on the actual kvdo module version.
+ * Please note the contents of the hashtable may vary depending on the actual dm-vdo module version.
*
* Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY
*/
@@ -4736,12 +4736,12 @@ BDLVMVDOStats* bd_lvm_vdo_get_stats (const gchar *vg_name, const gchar *pool_nam
return NULL;
stats = g_new0 (BDLVMVDOStats, 1);
- get_stat_val64_default (full_stats, "block_size", &stats->block_size, -1);
- get_stat_val64_default (full_stats, "logical_block_size", &stats->logical_block_size, -1);
- get_stat_val64_default (full_stats, "physical_blocks", &stats->physical_blocks, -1);
- get_stat_val64_default (full_stats, "data_blocks_used", &stats->data_blocks_used, -1);
- get_stat_val64_default (full_stats, "overhead_blocks_used", &stats->overhead_blocks_used, -1);
- get_stat_val64_default (full_stats, "logical_blocks_used", &stats->logical_blocks_used, -1);
+ get_stat_val64_default (full_stats, "blockSize", &stats->block_size, -1);
+ get_stat_val64_default (full_stats, "logicalBlockSize", &stats->logical_block_size, -1);
+ get_stat_val64_default (full_stats, "physicalBlocks", &stats->physical_blocks, -1);
+ get_stat_val64_default (full_stats, "dataBlocksUsed", &stats->data_blocks_used, -1);
+ get_stat_val64_default (full_stats, "overheadBlocksUsed", &stats->overhead_blocks_used, -1);
+ get_stat_val64_default (full_stats, "logicalBlocksUsed", &stats->logical_blocks_used, -1);
get_stat_val64_default (full_stats, "usedPercent", &stats->used_percent, -1);
get_stat_val64_default (full_stats, "savingPercent", &stats->saving_percent, -1);
if (!get_stat_val_double (full_stats, "writeAmplificationRatio", &stats->write_amplification_ratio))
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
index dc7491a7..0af9a382 100644
--- a/src/plugins/lvm.c
+++ b/src/plugins/lvm.c
@@ -3799,10 +3799,10 @@ BDLVMVDOWritePolicy bd_lvm_get_vdo_write_policy_from_str (const gchar *policy_st
* statistics or %NULL in case of error
* (@error gets populated in those cases)
*
- * Statistics are collected from the values exposed by the kernel `kvdo` module
- * at the `/sys/kvdo/<VDO_NAME>/statistics/` path.
+ * Statistics are collected from the values exposed by the kernel `dm-vdo` module.
+ *
* Some of the keys are computed to mimic the information produced by the vdo tools.
- * Please note the contents of the hashtable may vary depending on the actual kvdo module version.
+ * Please note the contents of the hashtable may vary depending on the actual dm-vdo module version.
*
* Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY
*/
@@ -3834,12 +3834,12 @@ BDLVMVDOStats* bd_lvm_vdo_get_stats (const gchar *vg_name, const gchar *pool_nam
return NULL;
stats = g_new0 (BDLVMVDOStats, 1);
- get_stat_val64_default (full_stats, "block_size", &stats->block_size, -1);
- get_stat_val64_default (full_stats, "logical_block_size", &stats->logical_block_size, -1);
- get_stat_val64_default (full_stats, "physical_blocks", &stats->physical_blocks, -1);
- get_stat_val64_default (full_stats, "data_blocks_used", &stats->data_blocks_used, -1);
- get_stat_val64_default (full_stats, "overhead_blocks_used", &stats->overhead_blocks_used, -1);
- get_stat_val64_default (full_stats, "logical_blocks_used", &stats->logical_blocks_used, -1);
+ get_stat_val64_default (full_stats, "blockSize", &stats->block_size, -1);
+ get_stat_val64_default (full_stats, "logicalBlockSize", &stats->logical_block_size, -1);
+ get_stat_val64_default (full_stats, "physicalBlocks", &stats->physical_blocks, -1);
+ get_stat_val64_default (full_stats, "dataBlocksUsed", &stats->data_blocks_used, -1);
+ get_stat_val64_default (full_stats, "overheadBlocksUsed", &stats->overhead_blocks_used, -1);
+ get_stat_val64_default (full_stats, "logicalBlocksUsed", &stats->logical_blocks_used, -1);
get_stat_val64_default (full_stats, "usedPercent", &stats->used_percent, -1);
get_stat_val64_default (full_stats, "savingPercent", &stats->saving_percent, -1);
if (!get_stat_val_double (full_stats, "writeAmplificationRatio", &stats->write_amplification_ratio))
diff --git a/src/plugins/vdo_stats.c b/src/plugins/vdo_stats.c
index 620e972f..ab914821 100644
--- a/src/plugins/vdo_stats.c
+++ b/src/plugins/vdo_stats.c
@@ -19,10 +19,11 @@
#include <glib.h>
#include <blockdev/utils.h>
+#include <libdevmapper.h>
+#include <yaml.h>
#include "vdo_stats.h"
-
-#define VDO_SYS_PATH "/sys/kvdo"
+#include "lvm.h"
gboolean __attribute__ ((visibility ("hidden")))
@@ -67,9 +68,9 @@ get_stat_val_double (GHashTable *stats, const gchar *key, gdouble *val) {
static void add_write_ampl_r_stats (GHashTable *stats) {
gint64 bios_meta_write, bios_out_write, bios_in_write;
- if (! get_stat_val64 (stats, "bios_meta_write", &bios_meta_write) ||
- ! get_stat_val64 (stats, "bios_out_write", &bios_out_write) ||
- ! get_stat_val64 (stats, "bios_in_write", &bios_in_write))
+ if (! get_stat_val64 (stats, "biosMetaWrite", &bios_meta_write) ||
+ ! get_stat_val64 (stats, "biosOutWrite", &bios_out_write) ||
+ ! get_stat_val64 (stats, "biosInWrite", &bios_in_write))
return;
if (bios_in_write <= 0)
@@ -84,11 +85,11 @@ static void add_block_stats (GHashTable *stats) {
gint64 physical_blocks, block_size, data_blocks_used, overhead_blocks_used, logical_blocks_used;
gint64 savings;
- if (! get_stat_val64 (stats, "physical_blocks", &physical_blocks) ||
- ! get_stat_val64 (stats, "block_size", &block_size) ||
- ! get_stat_val64 (stats, "data_blocks_used", &data_blocks_used) ||
- ! get_stat_val64 (stats, "overhead_blocks_used", &overhead_blocks_used) ||
- ! get_stat_val64 (stats, "logical_blocks_used", &logical_blocks_used))
+ if (! get_stat_val64 (stats, "physicalBlocks", &physical_blocks) ||
+ ! get_stat_val64 (stats, "blockSize", &block_size) ||
+ ! get_stat_val64 (stats, "dataBlocksUsed", &data_blocks_used) ||
+ ! get_stat_val64 (stats, "overheadBlocksUsed", &overhead_blocks_used) ||
+ ! get_stat_val64 (stats, "logicalBlocksUsed", &logical_blocks_used))
return;
g_hash_table_replace (stats, g_strdup ("oneKBlocks"), g_strdup_printf ("%"G_GINT64_FORMAT, physical_blocks * block_size / 1024));
@@ -105,24 +106,24 @@ static void add_journal_stats (GHashTable *stats) {
gint64 journal_entries_committed, journal_entries_started, journal_entries_written;
gint64 journal_blocks_committed, journal_blocks_started, journal_blocks_written;
- if (! get_stat_val64 (stats, "journal_entries_committed", &journal_entries_committed) ||
- ! get_stat_val64 (stats, "journal_entries_started", &journal_entries_started) ||
- ! get_stat_val64 (stats, "journal_entries_written", &journal_entries_written) ||
- ! get_stat_val64 (stats, "journal_blocks_committed", &journal_blocks_committed) ||
- ! get_stat_val64 (stats, "journal_blocks_started", &journal_blocks_started) ||
- ! get_stat_val64 (stats, "journal_blocks_written", &journal_blocks_written))
+ if (! get_stat_val64 (stats, "journalEntriesCommitted", &journal_entries_committed) ||
+ ! get_stat_val64 (stats, "journalEntriesStarted", &journal_entries_started) ||
+ ! get_stat_val64 (stats, "journalEntriesWritten", &journal_entries_written) ||
+ ! get_stat_val64 (stats, "journalBlocksCommitted", &journal_blocks_committed) ||
+ ! get_stat_val64 (stats, "journalBlocksStarted", &journal_blocks_started) ||
+ ! get_stat_val64 (stats, "journalBlocksWritten", &journal_blocks_written))
return;
- g_hash_table_replace (stats, g_strdup ("journal_entries_batching"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_entries_started - journal_entries_written));
- g_hash_table_replace (stats, g_strdup ("journal_entries_writing"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_entries_written - journal_entries_committed));
- g_hash_table_replace (stats, g_strdup ("journal_blocks_batching"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_blocks_started - journal_blocks_written));
- g_hash_table_replace (stats, g_strdup ("journal_blocks_writing"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_blocks_written - journal_blocks_committed));
+ g_hash_table_replace (stats, g_strdup ("journalEntriesBatching"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_entries_started - journal_entries_written));
+ g_hash_table_replace (stats, g_strdup ("journalEntriesWriting"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_entries_written - journal_entries_committed));
+ g_hash_table_replace (stats, g_strdup ("journalBlocksBatching"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_blocks_started - journal_blocks_written));
+ g_hash_table_replace (stats, g_strdup ("journalBlocksWriting"), g_strdup_printf ("%"G_GINT64_FORMAT, journal_blocks_written - journal_blocks_committed));
}
static void add_computed_stats (GHashTable *stats) {
const gchar *s;
- s = g_hash_table_lookup (stats, "logical_block_size");
+ s = g_hash_table_lookup (stats, "logicalBlockSize");
g_hash_table_replace (stats,
g_strdup ("fiveTwelveByteEmulation"),
g_strdup ((g_strcmp0 (s, "512") == 0) ? "true" : "false"));
@@ -132,76 +133,128 @@ static void add_computed_stats (GHashTable *stats) {
add_journal_stats (stats);
}
-static gchar* _dm_node_from_name (const gchar *map_name, GError **error) {
- gchar *dev_path = NULL;
- gchar *ret = NULL;
- gchar *dev_mapper_path = g_strdup_printf ("/dev/mapper/%s", map_name);
+enum parse_flags {
+ PARSE_NEXT_KEY,
+ PARSE_NEXT_VAL,
+ PARSE_NEXT_IGN,
+};
- dev_path = bd_utils_resolve_device (dev_mapper_path, error);
- g_free (dev_mapper_path);
- if (!dev_path)
- /* error is already populated */
+GHashTable __attribute__ ((visibility ("hidden")))
+*vdo_get_stats_full (const gchar *name, GError **error) {
+ struct dm_task *dmt = NULL;
+ const gchar *response = NULL;
+ yaml_parser_t parser;
+ yaml_token_t token;
+ GHashTable *stats = NULL;
+ gchar *key = NULL;
+ gsize len = 0;
+ int next_token = PARSE_NEXT_IGN;
+ gchar *prefix = NULL;
+
+ dmt = dm_task_create (DM_DEVICE_TARGET_MSG);
+ if (!dmt) {
+ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_DM_ERROR,
+ "Failed to create DM task");
return NULL;
+ }
- ret = g_path_get_basename (dev_path);
- g_free (dev_path);
+ if (!dm_task_set_name (dmt, name)) {
+ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_DM_ERROR,
+ "Failed to set name for DM task");
+ dm_task_destroy (dmt);
+ return NULL;
+ }
- return ret;
-}
+ if (!dm_task_set_message (dmt, "stats")) {
+ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_DM_ERROR,
+ "Failed to set message for DM task");
+ dm_task_destroy (dmt);
+ return NULL;
+ }
-GHashTable __attribute__ ((visibility ("hidden")))
-*vdo_get_stats_full (const gchar *name, GError **error) {
- GHashTable *stats;
- GDir *dir;
- gchar *stats_dir;
- const gchar *direntry;
- gchar *s;
- gchar *val = NULL;
- g_autofree gchar *dm_node = NULL;
- GError *l_error = NULL;
-
- /* try "new" (kvdo >= 8) path first -- /sys/block/dm-X/vdo/statistics */
- dm_node = _dm_node_from_name (name, error);
- if (dm_node == NULL) {
- g_prefix_error (error, "Failed to get DM node for %s: ", name);
+ if (!dm_task_run (dmt)) {
+ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_DM_ERROR,
+ "Failed to run DM task");
+ dm_task_destroy (dmt);
+ return NULL;
+ }
+
+ response = dm_task_get_message_response (dmt);
+ if (!response) {
+ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_DM_ERROR,
+ "Failed to get response from the DM task");
+ dm_task_destroy (dmt);
return NULL;
}
- stats_dir = g_build_path (G_DIR_SEPARATOR_S, "/sys/block", dm_node, "vdo/statistics", NULL);
- dir = g_dir_open (stats_dir, 0, &l_error);
- if (dir == NULL) {
- bd_utils_log_format (BD_UTILS_LOG_INFO,
- "Failed to read VDO stats using the new API, falling back to %s: %s",
- VDO_SYS_PATH, l_error->message);
- g_free (stats_dir);
- g_clear_error (&l_error);
-
- /* lets try /sys/kvdo */
- stats_dir = g_build_path (G_DIR_SEPARATOR_S, VDO_SYS_PATH, name, "statistics", NULL);
- dir = g_dir_open (stats_dir, 0, error);
- if (dir == NULL) {
- g_prefix_error (error, "Error reading statistics from %s: ", stats_dir);
- g_free (stats_dir);
- return NULL;
- }
+ if (!yaml_parser_initialize (&parser)) {
+ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_DM_ERROR,
+ "Failed to get initialize YAML parser");
+ dm_task_destroy (dmt);
+ return NULL;
}
stats = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- while ((direntry = g_dir_read_name (dir))) {
- s = g_build_filename (stats_dir, direntry, NULL);
- if (! g_file_get_contents (s, &val, NULL, error)) {
- g_prefix_error (error, "Error reading statistics from %s: ", s);
- g_free (s);
- g_hash_table_destroy (stats);
- stats = NULL;
- break;
- }
- g_hash_table_replace (stats, g_strdup (direntry), g_strdup (g_strstrip (val)));
- g_free (val);
- g_free (s);
- }
- g_dir_close (dir);
- g_free (stats_dir);
+ yaml_parser_set_input_string (&parser, (guchar *) response, strlen (response));
+
+ do {
+ yaml_parser_scan (&parser, &token);
+ switch (token.type) {
+ /* key */
+ case YAML_KEY_TOKEN:
+ next_token = PARSE_NEXT_KEY;
+ break;
+ /* value */
+ case YAML_VALUE_TOKEN:
+ next_token = PARSE_NEXT_VAL;
+ break;
+ /* block mapping */
+ case YAML_BLOCK_MAPPING_START_TOKEN:
+ if (next_token == PARSE_NEXT_VAL)
+ /* we were expecting to read a key-value pair but this is actually
+ a block start, so we need to free the key we're not going to use */
+ g_free (key);
+ break;
+ /* mapping */
+ case YAML_FLOW_MAPPING_START_TOKEN:
+ /* start of flow mapping -> previously read key will be used as prefix
+ for all keys in the mapping:
+ previous key: biosInProgress
+ keys in the mapping: Read, Write...
+ with prefix: biosInProgressRead, biosInProgressWrite...
+ */
+ prefix = key;
+ break;
+ case YAML_FLOW_MAPPING_END_TOKEN:
+ /* end of flow mapping, discard the prefix used */
+ g_free (prefix);
+ prefix = NULL;
+ break;
+ /* actual data */
+ case YAML_SCALAR_TOKEN:
+ if (next_token == PARSE_NEXT_KEY) {
+ if (prefix) {
+ key = g_strdup_printf ("%s%s", prefix, (const gchar *) token.data.scalar.value);
+ len = strlen (prefix);
+ /* make sure the key with the prefix is still camelCase */
+ key[len] = g_ascii_toupper (key[len]);
+ } else
+ key = g_strdup ((const gchar *) token.data.scalar.value);
+ } else if (next_token == PARSE_NEXT_VAL) {
+ gchar *val = g_strdup ((const gchar *) token.data.scalar.value);
+ g_hash_table_insert (stats, key, val);
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (token.type != YAML_STREAM_END_TOKEN)
+ yaml_token_delete (&token);
+ } while (token.type != YAML_STREAM_END_TOKEN);
+
+ yaml_parser_delete (&parser);
+ dm_task_destroy (dmt);
if (stats != NULL)
add_computed_stats (stats);
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
index 9f302611..db0d5c90 100644
--- a/tests/lvm_dbus_tests.py
+++ b/tests/lvm_dbus_tests.py
@@ -2090,7 +2090,9 @@ class LVMVDOTest(LVMTestCase):
pool_info = BlockDev.lvm_lvinfo("testVDOVG", "vdoPool")
self.assertEqual(pool_info.segtype, "vdo-pool")
self.assertEqual(pool_info.data_lv, "vdoPool_vdata")
- self.assertGreater(pool_info.data_percent, 0)
+ lvm_version = self._get_lvm_version()
+ if lvm_version >= Version("2.03.24"):
+ self.assertGreater(pool_info.data_percent, 0)
pool = BlockDev.lvm_vdolvpoolname("testVDOVG", "vdoLV")
self.assertEqual(pool, lv_info.pool_lv)
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
index b1d65baf..96aa352a 100644
--- a/tests/lvm_test.py
+++ b/tests/lvm_test.py
@@ -1994,7 +1994,9 @@ class LVMVDOTest(LVMTestCase):
pool_info = BlockDev.lvm_lvinfo("testVDOVG", "vdoPool")
self.assertEqual(pool_info.segtype, "vdo-pool")
self.assertEqual(pool_info.data_lv, "vdoPool_vdata")
- self.assertGreater(pool_info.data_percent, 0)
+ lvm_version = self._get_lvm_version()
+ if lvm_version >= Version("2.03.24"):
+ self.assertGreater(pool_info.data_percent, 0)
pool = BlockDev.lvm_vdolvpoolname("testVDOVG", "vdoLV")
self.assertEqual(pool, lv_info.pool_lv)
@@ -2155,7 +2157,11 @@ class LVMVDOTest(LVMTestCase):
self.assertTrue(vdo_info.deduplication)
vdo_stats = BlockDev.lvm_vdo_get_stats("testVDOVG", "vdoPool")
- self.assertEqual(vdo_info.saving_percent, vdo_stats.saving_percent)
+
+ lvm_version = self._get_lvm_version()
+ if lvm_version >= Version("2.03.24"):
+ # saving_percent is incorrect with LVM < 2.03.24
+ self.assertEqual(vdo_info.saving_percent, vdo_stats.saving_percent)
# just sanity check
self.assertNotEqual(vdo_stats.used_percent, -1)
--
2.45.2

View File

@ -0,0 +1,86 @@
From e1c3c3e3555963104a8de00b510b69375eee5ced Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 7 Jun 2024 10:06:22 +0200
Subject: [PATCH 1/3] fs: Ignore unused-parameter warning in the FS plugin
There are some unused parameters in the libext2fs header which
together with Wall and Werror means the plugin compilation fails.
As a workaround we'll disable the unused-parameter warning for
now.
Fixes: #1026
---
src/plugins/fs/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am
index 7d4849c0..00474d5a 100644
--- a/src/plugins/fs/Makefile.am
+++ b/src/plugins/fs/Makefile.am
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects
lib_LTLIBRARIES = libbd_fs.la
-libbd_fs_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BLKID_CFLAGS) $(MOUNT_CFLAGS) $(UUID_CFLAGS) $(EXT2FS_CFLAGS) -Wall -Wextra -Werror
+libbd_fs_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BLKID_CFLAGS) $(MOUNT_CFLAGS) $(UUID_CFLAGS) $(EXT2FS_CFLAGS) -Wall -Wextra -Werror -Wno-unused-parameter
libbd_fs_la_LIBADD = ${builddir}/../../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(BLKID_LIBS) $(MOUNT_LIBS) $(UUID_LIBS) $(EXT2FS_LIBS)
libbd_fs_la_LDFLAGS = -L${srcdir}/../../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*'
libbd_fs_la_CPPFLAGS = -I${builddir}/../../../include/ -I${srcdir}/../
--
2.45.2
From 30e7d0bd7b78b5d9a2ddd031d0cdf9f45187a717 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 7 Jun 2024 15:21:09 +0200
Subject: [PATCH 2/3] fs: Ignore shift-count-overflow warning in FS plugin
The warning happens in the libext2fs header.
---
src/plugins/fs/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am
index 00474d5a..42e1c777 100644
--- a/src/plugins/fs/Makefile.am
+++ b/src/plugins/fs/Makefile.am
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects
lib_LTLIBRARIES = libbd_fs.la
-libbd_fs_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BLKID_CFLAGS) $(MOUNT_CFLAGS) $(UUID_CFLAGS) $(EXT2FS_CFLAGS) -Wall -Wextra -Werror -Wno-unused-parameter
+libbd_fs_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BLKID_CFLAGS) $(MOUNT_CFLAGS) $(UUID_CFLAGS) $(EXT2FS_CFLAGS) -Wall -Wextra -Werror -Wno-unused-parameter -Wno-shift-count-overflow
libbd_fs_la_LIBADD = ${builddir}/../../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(BLKID_LIBS) $(MOUNT_LIBS) $(UUID_LIBS) $(EXT2FS_LIBS)
libbd_fs_la_LDFLAGS = -L${srcdir}/../../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*'
libbd_fs_la_CPPFLAGS = -I${builddir}/../../../include/ -I${srcdir}/../
--
2.45.2
From b40ce052f98c9afb3e5bd0f91e7eb8bf6cbacd90 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 12 Jun 2024 15:34:02 +0200
Subject: [PATCH 3/3] fs: Fix ignoring errors from libext2fs
Follow-up for #1028, we still want to show the warning and not
completely supress it.
---
src/plugins/fs/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am
index 42e1c777..1ee256f0 100644
--- a/src/plugins/fs/Makefile.am
+++ b/src/plugins/fs/Makefile.am
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects
lib_LTLIBRARIES = libbd_fs.la
-libbd_fs_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BLKID_CFLAGS) $(MOUNT_CFLAGS) $(UUID_CFLAGS) $(EXT2FS_CFLAGS) -Wall -Wextra -Werror -Wno-unused-parameter -Wno-shift-count-overflow
+libbd_fs_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BLKID_CFLAGS) $(MOUNT_CFLAGS) $(UUID_CFLAGS) $(EXT2FS_CFLAGS) -Wall -Wextra -Werror -Wno-error=unused-parameter -Wno-error=shift-count-overflow
libbd_fs_la_LIBADD = ${builddir}/../../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(BLKID_LIBS) $(MOUNT_LIBS) $(UUID_LIBS) $(EXT2FS_LIBS)
libbd_fs_la_LDFLAGS = -L${srcdir}/../../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*'
libbd_fs_la_CPPFLAGS = -I${builddir}/../../../include/ -I${srcdir}/../
--
2.45.2

10506
0006-smart-plugin.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +0,0 @@
From 7a0e344d0642f76992c943158621d8ee7e5caea3 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 15 Nov 2022 13:21:25 +0100
Subject: [PATCH 1/2] crypto: Fix GError overwrite from libvolume_key
---
src/plugins/crypto.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c
index 35c38410..9064c8e3 100644
--- a/src/plugins/crypto.c
+++ b/src/plugins/crypto.c
@@ -2552,13 +2552,14 @@ static gboolean write_escrow_data_file (struct libvk_volume *volume, struct libv
GIOChannel *out_file = NULL;
GIOStatus status = G_IO_STATUS_ERROR;
gsize bytes_written = 0;
+ GError *l_error = NULL;
packet_data = libvk_volume_create_packet_asymmetric_with_format (volume, &packet_data_size, secret_type, cert,
- ui, LIBVK_PACKET_FORMAT_ASYMMETRIC_WRAP_SECRET_ONLY, error);
-
+ ui, LIBVK_PACKET_FORMAT_ASYMMETRIC_WRAP_SECRET_ONLY, &l_error);
if (!packet_data) {
g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_ESCROW_FAILED,
- "Failed to get escrow data");
+ "Failed to get escrow data: %s", l_error->message);
+ g_clear_error (&l_error);
libvk_volume_free (volume);
return FALSE;
}
--
2.38.1
From 25bf34c4c03e37eb3782dfccf459b9a3f795ddb3 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 16 Nov 2022 10:26:06 +0100
Subject: [PATCH 2/2] crypto: Fix double free in write_escrow_data_file
---
src/plugins/crypto.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c
index 9064c8e3..2086209e 100644
--- a/src/plugins/crypto.c
+++ b/src/plugins/crypto.c
@@ -2560,7 +2560,6 @@ static gboolean write_escrow_data_file (struct libvk_volume *volume, struct libv
g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_ESCROW_FAILED,
"Failed to get escrow data: %s", l_error->message);
g_clear_error (&l_error);
- libvk_volume_free (volume);
return FALSE;
}
--
2.38.1

View File

@ -1,41 +0,0 @@
From 6700dfded31219c99fea054aa10fd68b90bace82 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 31 Oct 2022 12:43:17 +0100
Subject: [PATCH] tests: Fix test_swapon_pagesize on systems with 64k pages
---
tests/swap_test.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tests/swap_test.py b/tests/swap_test.py
index 0a0f333d..e350f8e8 100644
--- a/tests/swap_test.py
+++ b/tests/swap_test.py
@@ -1,5 +1,6 @@
import unittest
import os
+import resource
import overrides_hack
from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, run_command, run, TestTags, tag_test
@@ -102,8 +103,15 @@ class SwapTestCase(SwapTest):
def test_swapon_pagesize(self):
"""Verify that activating swap with different pagesize fails"""
- # create swap with 64k pagesize
- ret, out, err = run_command("mkswap --pagesize 65536 %s" % self.loop_dev)
+ # pick some wrong page size: 8k on 64k and 64k everywhere else
+ pagesize = resource.getpagesize()
+ if pagesize == 65536:
+ wrong_pagesize = 8192
+ else:
+ wrong_pagesize = 65536
+
+ # create swap with "wrong" pagesize
+ ret, out, err = run_command("mkswap --pagesize %s %s" % (wrong_pagesize, self.loop_dev))
if ret != 0:
self.fail("Failed to prepare swap for pagesize test: %s %s" % (out, err))
--
2.39.2

View File

@ -1,32 +0,0 @@
From 9c96e621e9abb0649118d2e1731a09b1fa139579 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 19 Apr 2023 09:50:38 +0200
Subject: [PATCH] part: Fix segfault when adding a partition too big for MSDOS
Resolves: rhbz#2185564
---
src/plugins/part.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/plugins/part.c b/src/plugins/part.c
index 8b2285f5..28e20c28 100644
--- a/src/plugins/part.c
+++ b/src/plugins/part.c
@@ -841,6 +841,14 @@ static gboolean resize_part (PedPartition *part, PedDevice *dev, PedDisk *disk,
constr = ped_constraint_any (dev);
geom = ped_disk_get_max_partition_geometry (disk, part, constr);
+ if (!geom) {
+ set_parted_error (error, BD_PART_ERROR_FAIL);
+ g_prefix_error (error, "Failed to create geometry for partition on device '%s'", dev->path);
+ ped_constraint_destroy (constr);
+ finish_alignment_constraint (disk, orig_flag_state);
+ return FALSE;
+ }
+
if (!ped_geometry_set_start (geom, start)) {
set_parted_error (error, BD_PART_ERROR_FAIL);
g_prefix_error (error, "Failed to set partition start on device '%s'", dev->path);
--
2.40.1

View File

@ -1,300 +0,0 @@
From ee9c3afec5ef2fe1e9fd50718cd732e267b235ed Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 24 Apr 2023 11:57:18 +0200
Subject: [PATCH] lvm: Add a function to activate LVs in shared mode
Needed by the new blivet feature to support shared LVM setups.
---
src/lib/plugin_apis/lvm.api | 16 +++++++++
src/plugins/lvm-dbus.c | 51 ++++++++++++++++++++-------
src/plugins/lvm.c | 53 ++++++++++++++++++++++-------
src/plugins/lvm.h | 1 +
src/python/gi/overrides/BlockDev.py | 5 ++-
tests/lvm_dbus_tests.py | 18 +++++++---
tests/lvm_test.py | 18 +++++++---
7 files changed, 124 insertions(+), 38 deletions(-)
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
index dc8c1348..bac70a75 100644
--- a/src/lib/plugin_apis/lvm.api
+++ b/src/lib/plugin_apis/lvm.api
@@ -1055,6 +1055,22 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
*/
gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error);
+/**
+ * bd_lvm_lvactivate_shared:
+ * @vg_name: name of the VG containing the to-be-activated LV
+ * @lv_name: name of the to-be-activated LV
+ * @ignore_skip: whether to ignore the skip flag or not
+ * @shared: whether to activate the LV in shared mode
+ * @extra: (allow-none) (array zero-terminated=1): extra options for the LV activation
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the @vg_name/@lv_name LV was successfully activated or not
+ *
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error);
+
/**
* bd_lvm_lvdeactivate:
* @vg_name: name of the VG containing the to-be-deactivated LV
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index b7b4480e..d8e997f9 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -2115,6 +2115,27 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
return (*error == NULL);
}
+static gboolean _lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
+ GVariant *params = NULL;
+ GVariantBuilder builder;
+ GVariant *extra_params = NULL;
+
+ if (shared)
+ params = g_variant_new ("(t)", (guint64) 1 << 6);
+ else
+ params = g_variant_new ("(t)", (guint64) 0);
+
+ if (ignore_skip) {
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
+ g_variant_builder_add (&builder, "{sv}", "-K", g_variant_new ("s", ""));
+ extra_params = g_variant_builder_end (&builder);
+ g_variant_builder_clear (&builder);
+ }
+ call_lv_method_sync (vg_name, lv_name, "Activate", params, extra_params, extra, TRUE, error);
+
+ return (*error == NULL);
+}
+
/**
* bd_lvm_lvactivate:
* @vg_name: name of the VG containing the to-be-activated LV
@@ -2129,19 +2150,25 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
* Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
*/
gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error) {
- GVariant *params = g_variant_new ("(t)", (guint64) 0);
- GVariantBuilder builder;
- GVariant *extra_params = NULL;
-
- if (ignore_skip) {
- g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
- g_variant_builder_add (&builder, "{sv}", "-K", g_variant_new ("s", ""));
- extra_params = g_variant_builder_end (&builder);
- g_variant_builder_clear (&builder);
- }
- call_lv_method_sync (vg_name, lv_name, "Activate", params, extra_params, extra, TRUE, error);
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, FALSE, extra, error);
+}
- return (*error == NULL);
+/**
+ * bd_lvm_lvactivate_shared:
+ * @vg_name: name of the VG containing the to-be-activated LV
+ * @lv_name: name of the to-be-activated LV
+ * @ignore_skip: whether to ignore the skip flag or not
+ * @shared: whether to activate the LV in shared mode
+ * @extra: (allow-none) (array zero-terminated=1): extra options for the LV activation
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the @vg_name/@lv_name LV was successfully activated or not
+ *
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, shared, extra, error);
}
/**
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
index 50da656c..d7281339 100644
--- a/src/plugins/lvm.c
+++ b/src/plugins/lvm.c
@@ -1594,6 +1594,28 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
return success;
}
+static gboolean _lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
+ const gchar *args[5] = {"lvchange", NULL, NULL, NULL, NULL};
+ guint8 next_arg = 2;
+ gboolean success = FALSE;
+
+ if (shared)
+ args[1] = "-asy";
+ else
+ args[1] = "-ay";
+
+ if (ignore_skip) {
+ args[next_arg] = "-K";
+ next_arg++;
+ }
+ args[next_arg] = g_strdup_printf ("%s/%s", vg_name, lv_name);
+
+ success = call_lvm_and_report_error (args, extra, TRUE, error);
+ g_free ((gchar *) args[next_arg]);
+
+ return success;
+}
+
/**
* bd_lvm_lvactivate:
* @vg_name: name of the VG containing the to-be-activated LV
@@ -1608,20 +1630,25 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
* Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
*/
gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error) {
- const gchar *args[5] = {"lvchange", "-ay", NULL, NULL, NULL};
- guint8 next_arg = 2;
- gboolean success = FALSE;
-
- if (ignore_skip) {
- args[next_arg] = "-K";
- next_arg++;
- }
- args[next_arg] = g_strdup_printf ("%s/%s", vg_name, lv_name);
-
- success = call_lvm_and_report_error (args, extra, TRUE, error);
- g_free ((gchar *) args[next_arg]);
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, FALSE, extra, error);
+}
- return success;
+/**
+ * bd_lvm_lvactivate_shared:
+ * @vg_name: name of the VG containing the to-be-activated LV
+ * @lv_name: name of the to-be-activated LV
+ * @ignore_skip: whether to ignore the skip flag or not
+ * @shared: whether to activate the LV in shared mode
+ * @extra: (allow-none) (array zero-terminated=1): extra options for the LV activation
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the @vg_name/@lv_name LV was successfully activated or not
+ *
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, shared, extra, error);
}
/**
diff --git a/src/plugins/lvm.h b/src/plugins/lvm.h
index 2162d769..244663a4 100644
--- a/src/plugins/lvm.h
+++ b/src/plugins/lvm.h
@@ -275,6 +275,7 @@ gboolean bd_lvm_lvremove (const gchar *vg_name, const gchar *lv_name, gboolean f
gboolean bd_lvm_lvrename (const gchar *vg_name, const gchar *lv_name, const gchar *new_name, const BDExtraArg **extra, GError **error);
gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error);
gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error);
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error);
gboolean bd_lvm_lvdeactivate (const gchar *vg_name, const gchar *lv_name, const BDExtraArg **extra, GError **error);
gboolean bd_lvm_lvsnapshotcreate (const gchar *vg_name, const gchar *origin_name, const gchar *snapshot_name, guint64 size, const BDExtraArg **extra, GError **error);
gboolean bd_lvm_lvsnapshotmerge (const gchar *vg_name, const gchar *snapshot_name, const BDExtraArg **extra, GError **error);
diff --git a/src/python/gi/overrides/BlockDev.py b/src/python/gi/overrides/BlockDev.py
index f768c8bd..c7d72f4b 100644
--- a/src/python/gi/overrides/BlockDev.py
+++ b/src/python/gi/overrides/BlockDev.py
@@ -580,11 +580,10 @@ def lvm_lvresize(vg_name, lv_name, size, extra=None, **kwargs):
return _lvm_lvresize(vg_name, lv_name, size, extra)
__all__.append("lvm_lvresize")
-_lvm_lvactivate = BlockDev.lvm_lvactivate
@override(BlockDev.lvm_lvactivate)
-def lvm_lvactivate(vg_name, lv_name, ignore_skip=False, extra=None, **kwargs):
+def lvm_lvactivate(vg_name, lv_name, ignore_skip=False, shared=False, extra=None, **kwargs):
extra = _get_extra(extra, kwargs)
- return _lvm_lvactivate(vg_name, lv_name, ignore_skip, extra)
+ return BlockDev.lvm_lvactivate_shared(vg_name, lv_name, ignore_skip, shared, extra)
__all__.append("lvm_lvactivate")
_lvm_lvdeactivate = BlockDev.lvm_lvdeactivate
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
index 4882da88..67eaccd1 100644
--- a/tests/lvm_dbus_tests.py
+++ b/tests/lvm_dbus_tests.py
@@ -799,15 +799,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
self.assertTrue(succ)
with self.assertRaises(GLib.GError):
- BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True, None)
+ BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True)
with self.assertRaises(GLib.GError):
- BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True, None)
+ BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True)
with self.assertRaises(GLib.GError):
- BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True, None)
+ BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True)
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
self.assertTrue(succ)
with self.assertRaises(GLib.GError):
@@ -822,7 +822,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
self.assertTrue(succ)
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
+ self.assertTrue(succ)
+
+ # try activating in shared mode, unfortunately no way to check whether it really
+ # works or not
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, True)
self.assertTrue(succ)
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
index eb94c917..25e2f109 100644
--- a/tests/lvm_test.py
+++ b/tests/lvm_test.py
@@ -730,15 +730,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
self.assertTrue(succ)
with self.assertRaises(GLib.GError):
- BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True, None)
+ BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True)
with self.assertRaises(GLib.GError):
- BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True, None)
+ BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True)
with self.assertRaises(GLib.GError):
- BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True, None)
+ BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True)
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
self.assertTrue(succ)
with self.assertRaises(GLib.GError):
@@ -753,7 +753,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
self.assertTrue(succ)
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
+ self.assertTrue(succ)
+
+ # try activating in shared mode, unfortunately no way to check whether it really
+ # works or not
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, True)
self.assertTrue(succ)
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
--
2.41.0

View File

@ -1,299 +0,0 @@
From 5e8429d004445c6f6e6f16cab67cf14cb4d32a65 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 18 Apr 2023 12:05:35 +0200
Subject: [PATCH] lvm: Add support for starting and stopping VG locking
---
docs/libblockdev-sections.txt | 2 ++
src/lib/plugin_apis/lvm.api | 27 +++++++++++++++++++
src/plugins/lvm-dbus.c | 49 ++++++++++++++++++++++++++++++++++-
src/plugins/lvm.c | 41 +++++++++++++++++++++++++++++
src/plugins/lvm.h | 3 +++
tests/lvm_dbus_tests.py | 33 +++++++++++++++++++++++
tests/lvm_test.py | 32 +++++++++++++++++++++++
7 files changed, 186 insertions(+), 1 deletion(-)
diff --git a/docs/libblockdev-sections.txt b/docs/libblockdev-sections.txt
index 512820c2..7377dd17 100644
--- a/docs/libblockdev-sections.txt
+++ b/docs/libblockdev-sections.txt
@@ -286,6 +286,8 @@ bd_lvm_vgactivate
bd_lvm_vgdeactivate
bd_lvm_vgextend
bd_lvm_vgreduce
+bd_lvm_vglock_start
+bd_lvm_vglock_stop
bd_lvm_vginfo
bd_lvm_vgs
bd_lvm_lvorigin
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
index 54c47a93..14f2620a 100644
--- a/src/lib/plugin_apis/lvm.api
+++ b/src/lib/plugin_apis/lvm.api
@@ -601,6 +601,7 @@ typedef enum {
BD_LVM_TECH_CACHE_CALCS,
BD_LVM_TECH_GLOB_CONF,
BD_LVM_TECH_VDO,
+ BD_LVM_TECH_SHARED,
} BDLVMTech;
typedef enum {
@@ -941,6 +942,32 @@ gboolean bd_lvm_vgextend (const gchar *vg_name, const gchar *device, const BDExt
*/
gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
+/**
+ * bd_lvm_vglock_start:
+ * @vg_name: a shared VG to start the lockspace in lvmlockd
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the lock was successfully started for @vg_name or not
+ *
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error);
+
+/**
+ * bd_lvm_vglock_stop:
+ * @vg_name: a shared VG to stop the lockspace in lvmlockd
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the lock was successfully stopped for @vg_name or not
+ *
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error);
+
/**
* bd_lvm_vginfo:
* @vg_name: a VG to get information about
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index e1f946fe..ad44dfb3 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -1848,10 +1848,57 @@ gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExt
return ((*error) == NULL);
}
+gboolean _vglock_start_stop (const gchar *vg_name, gboolean start, const BDExtraArg **extra, GError **error) {
+ GVariantBuilder builder;
+ GVariant *params = NULL;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
+ if (start)
+ g_variant_builder_add (&builder, "{sv}", "--lockstart", g_variant_new ("s", ""));
+ else
+ g_variant_builder_add (&builder, "{sv}", "--lockstop", g_variant_new ("s", ""));
+ params = g_variant_builder_end (&builder);
+ g_variant_builder_clear (&builder);
+
+ call_lvm_obj_method_sync (vg_name, VG_INTF, "Change", NULL, params, extra, TRUE, error);
+
+ return ((*error) == NULL);
+}
+
+/**
+ * bd_lvm_vglock_start:
+ * @vg_name: a shared VG to start the lockspace in lvmlockd
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the lock was successfully started for @vg_name or not
+ *
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
+ return _vglock_start_stop (vg_name, TRUE, extra, error);
+}
+
+/**
+ * bd_lvm_vglock_stop:
+ * @vg_name: a shared VG to stop the lockspace in lvmlockd
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the lock was successfully stopped for @vg_name or not
+ *
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
+ return _vglock_start_stop (vg_name, FALSE, extra, error);
+}
+
/**
* bd_lvm_vginfo:
* @vg_name: a VG to get information about
- * @error: (out): place to store error (if any)
+ * @error: (out) (optional): place to store error (if any)
*
* Returns: (transfer full): information about the @vg_name VG or %NULL in case
* of error (the @error) gets populated in those cases)
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
index 8bb3ae24..1aaf6747 100644
--- a/src/plugins/lvm.c
+++ b/src/plugins/lvm.c
@@ -1316,6 +1316,47 @@ gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExt
return call_lvm_and_report_error (args, extra, TRUE, error);
}
+gboolean _vglock_start_stop (const gchar *vg_name, gboolean start, const BDExtraArg **extra, GError **error) {
+ const gchar *args[4] = {"vgchange", NULL, vg_name, NULL};
+
+ if (start)
+ args[1] = "--lockstart";
+ else
+ args[1] = "--lockstop";
+
+ return call_lvm_and_report_error (args, extra, TRUE, error);
+}
+
+/**
+ * bd_lvm_vglock_start:
+ * @vg_name: a shared VG to start the lockspace in lvmlockd
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the lock was successfully started for @vg_name or not
+ *
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
+ return _vglock_start_stop (vg_name, TRUE, extra, error);
+}
+
+/**
+ * bd_lvm_vglock_stop:
+ * @vg_name: a shared VG to stop the lockspace in lvmlockd
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
+ * (just passed to LVM as is)
+ * @error: (out): place to store error (if any)
+ *
+ * Returns: whether the lock was successfully stopped for @vg_name or not
+ *
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
+ */
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
+ return _vglock_start_stop (vg_name, FALSE, extra, error);
+}
+
/**
* bd_lvm_vginfo:
* @vg_name: a VG to get information about
diff --git a/src/plugins/lvm.h b/src/plugins/lvm.h
index 244663a4..da14cc1a 100644
--- a/src/plugins/lvm.h
+++ b/src/plugins/lvm.h
@@ -216,6 +216,7 @@ typedef enum {
BD_LVM_TECH_CACHE_CALCS,
BD_LVM_TECH_GLOB_CONF,
BD_LVM_TECH_VDO,
+ BD_LVM_TECH_SHARED,
} BDLVMTech;
typedef enum {
@@ -266,6 +267,8 @@ gboolean bd_lvm_vgactivate (const gchar *vg_name, const BDExtraArg **extra, GErr
gboolean bd_lvm_vgdeactivate (const gchar *vg_name, const BDExtraArg **extra, GError **error);
gboolean bd_lvm_vgextend (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error);
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error);
BDLVMVGdata* bd_lvm_vginfo (const gchar *vg_name, GError **error);
BDLVMVGdata** bd_lvm_vgs (GError **error);
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
index 862a44cf..2a92c7c1 100644
--- a/tests/lvm_dbus_tests.py
+++ b/tests/lvm_dbus_tests.py
@@ -612,6 +612,39 @@ class LvmTestVGs(LvmPVVGTestCase):
succ = BlockDev.lvm_pvremove(self.loop_dev, None)
self.assertTrue(succ)
+@unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
+class LvmTestVGLocking(LvmPVVGTestCase):
+ @tag_test(TestTags.UNSAFE)
+ def test_vglock_stop_start(self):
+ """Verify that it is possible to start and stop locking on a VG"""
+
+ # better not do anything if lvmlockd is running, shared VGs have
+ # a tendency to wreak havoc on your system if you look at them wrong
+ ret, _out, _err = run_command("systemctl is-active lvmlockd")
+ if ret == 0:
+ self.skipTest("lvmlockd is running, skipping")
+
+ _ret, out, _err = run_command("lvm config 'global/use_lvmlockd'")
+ if "use_lvmlockd=0" not in out:
+ self.skipTest("lvmlockd is enabled, skipping")
+
+ succ = BlockDev.lvm_pvcreate(self.loop_dev, 0, 0, None)
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_pvcreate(self.loop_dev2, 0, 0, None)
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_vgcreate("testVG", [self.loop_dev, self.loop_dev2], 0, None)
+ self.assertTrue(succ)
+
+ # this actually doesn't "test" anything, the commands will just say lvmlockd is not
+ # running and return 0, but that's good enough for us
+ succ = BlockDev.lvm_vglock_start("testVG")
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_vglock_stop("testVG")
+ self.assertTrue(succ)
+
@unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
class LvmPVVGLVTestCase(LvmPVVGTestCase):
def _clean_up(self):
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
index 96f1670d..3ab11f04 100644
--- a/tests/lvm_test.py
+++ b/tests/lvm_test.py
@@ -585,6 +585,38 @@ class LvmTestVGs(LvmPVVGTestCase):
succ = BlockDev.lvm_pvremove(self.loop_dev, None)
self.assertTrue(succ)
+class LvmTestVGLocking(LvmPVVGTestCase):
+ @tag_test(TestTags.UNSAFE)
+ def test_vglock_stop_start(self):
+ """Verify that it is possible to start and stop locking on a VG"""
+
+ # better not do anything if lvmlockd is running, shared VGs have
+ # a tendency to wreak havoc on your system if you look at them wrong
+ ret, _out, _err = run_command("systemctl is-active lvmlockd")
+ if ret == 0:
+ self.skipTest("lvmlockd is running, skipping")
+
+ _ret, out, _err = run_command("lvm config 'global/use_lvmlockd'")
+ if "use_lvmlockd=0" not in out:
+ self.skipTest("lvmlockd is enabled, skipping")
+
+ succ = BlockDev.lvm_pvcreate(self.loop_dev, 0, 0, None)
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_pvcreate(self.loop_dev2, 0, 0, None)
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_vgcreate("testVG", [self.loop_dev, self.loop_dev2], 0, None)
+ self.assertTrue(succ)
+
+ # this actually doesn't "test" anything, the commands will just say lvmlockd is not
+ # running and return 0, but that's good enough for us
+ succ = BlockDev.lvm_vglock_start("testVG")
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_vglock_stop("testVG")
+ self.assertTrue(succ)
+
class LvmPVVGLVTestCase(LvmPVVGTestCase):
def _clean_up(self):
try:
--
2.41.0

File diff suppressed because it is too large Load Diff

1083
libblockdev.spec Normal file

File diff suppressed because it is too large Load Diff

2
sources Normal file
View File

@ -0,0 +1,2 @@
SHA512 (libblockdev-3.1.0.tar.gz) = 1e5f8155ceaf1b1f02607d0e2075bfe3b1a2c8d6845de5c90201e6b7aefde3bab7af8e9abf137763e6e9ca42fefe5218697ea63731b3b4952eb004b01cf3719a
SHA512 (smart-tests.tar.gz) = 6ece82eef09c3b22c8f1473653d791bcac7316c3f267368170cea5b152d55603d2a1014c729c4ed190e39660a8734a51989eb53c4a427b843e074f750b1f9a9b