New version 3.0.1

This commit is contained in:
Vojtech Trefny 2023-07-04 15:21:37 +02:00
parent 16293e5a70
commit 0a37033dee
7 changed files with 28 additions and 255 deletions

1
.gitignore vendored
View File

@ -50,3 +50,4 @@
/libblockdev-2.27.tar.gz
/libblockdev-2.28.tar.gz
/libblockdev-3.0.tar.gz
/libblockdev-3.0.1.tar.gz

View File

@ -1,171 +0,0 @@
From 1536c3fcc0e887a2116ff035bda187a4eab4ef47 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 17 May 2023 15:49:14 +0200
Subject: [PATCH] Allow resizing of inactive LVs with latest LVM
Latest LVM doesn't allow resizing of inactive LVs without the
"--fs ignore" option to protect users from corrupting their
filesystems. As a low level API we don't really want to offer this
kind of protection and we should allow to resize an inactive LV.
---
src/plugins/lvm-dbus.c | 28 +++++++++++++++++++++++++++-
src/plugins/lvm.c | 30 +++++++++++++++++++++++++++---
tests/lvm_dbus_tests.py | 4 ++++
tests/lvm_test.py | 4 ++++
tests/skip.yml | 6 ++++++
5 files changed, 68 insertions(+), 4 deletions(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index 51572c9a..1408236a 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -63,6 +63,8 @@ static gchar *global_config_str = NULL;
#define METHOD_CALL_TIMEOUT 5000
#define PROGRESS_WAIT 500 * 1000 /* microseconds */
+#define LVM_VERSION_FSRESIZE "2.03.19"
+
#define UNUSED __attribute__((unused))
static GDBusConnection *bus = NULL;
@@ -2102,6 +2104,15 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
GVariantBuilder builder;
GVariantType *type = NULL;
GVariant *params = NULL;
+ GVariant *extra_params = NULL;
+ gboolean success = FALSE;
+ BDLVMLVdata *lvinfo = NULL;
+ GError *l_error = NULL;
+
+ lvinfo = bd_lvm_lvinfo (vg_name, lv_name, error);
+ if (!lvinfo)
+ /* error is already populated */
+ return FALSE;
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&builder, g_variant_new ("t", size));
@@ -2111,7 +2122,22 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
params = g_variant_builder_end (&builder);
g_variant_builder_clear (&builder);
- call_lv_method_sync (vg_name, lv_name, "Resize", params, NULL, extra, TRUE, error);
+ if (lvinfo->attr[4] != 'a') {
+ /* starting with 2.03.19 we need to add extra option to allow resizing of inactive LVs */
+ success = bd_utils_check_util_version ("lvm", LVM_VERSION_FSRESIZE,
+ "version", "LVM version:\\s+([\\d\\.]+)", &l_error);
+ if (success) {
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
+ g_variant_builder_add (&builder, "{sv}", "--fs", g_variant_new ("s", "ignore"));
+ extra_params = g_variant_builder_end (&builder);
+ g_variant_builder_clear (&builder);
+ }
+ g_clear_error (&l_error);
+ }
+
+ bd_lvm_lvdata_free (lvinfo);
+
+ call_lv_method_sync (vg_name, lv_name, "Resize", params, extra_params, extra, TRUE, error);
return (*error == NULL);
}
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
index 26af0d19..a07db65b 100644
--- a/src/plugins/lvm.c
+++ b/src/plugins/lvm.c
@@ -31,6 +31,8 @@
#define SECTOR_SIZE 512
#define VDO_POOL_SUFFIX "vpool"
+#define LVM_VERSION_FSRESIZE "2.03.19"
+
static GMutex global_config_lock;
static gchar *global_config_str = NULL;
@@ -1583,15 +1585,37 @@ gboolean bd_lvm_lvrename (const gchar *vg_name, const gchar *lv_name, const gcha
* Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
*/
gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error) {
- const gchar *args[6] = {"lvresize", "--force", "-L", NULL, NULL, NULL};
+ const gchar *args[8] = {"lvresize", "--force", "-L", NULL, NULL, NULL, NULL, NULL};
gboolean success = FALSE;
+ guint8 next_arg = 4;
+ g_autofree gchar *lvspec = NULL;
+ BDLVMLVdata *lvinfo = NULL;
+ GError *l_error = NULL;
+
+ lvinfo = bd_lvm_lvinfo (vg_name, lv_name, error);
+ if (!lvinfo)
+ /* error is already populated */
+ return FALSE;
args[3] = g_strdup_printf ("%"G_GUINT64_FORMAT"K", size/1024);
- args[4] = g_strdup_printf ("%s/%s", vg_name, lv_name);
+ if (lvinfo->attr[4] != 'a') {
+ /* starting with 2.03.19 we need to add extra option to allow resizing of inactive LVs */
+ success = bd_utils_check_util_version (deps[DEPS_LVM].name, LVM_VERSION_FSRESIZE,
+ deps[DEPS_LVM].ver_arg, deps[DEPS_LVM].ver_regexp, &l_error);
+ if (success) {
+ args[next_arg++] = "--fs";
+ args[next_arg++] = "ignore";
+ }
+ g_clear_error (&l_error);
+ }
+
+ bd_lvm_lvdata_free (lvinfo);
+
+ lvspec = g_strdup_printf ("%s/%s", vg_name, lv_name);
+ args[next_arg++] = lvspec;
success = call_lvm_and_report_error (args, extra, TRUE, error);
g_free ((gchar *) args[3]);
- g_free ((gchar *) args[4]);
return success;
}
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
index 3fb7946a..b9493642 100644
--- a/tests/lvm_dbus_tests.py
+++ b/tests/lvm_dbus_tests.py
@@ -901,6 +901,10 @@ class LvmTestLVresize(LvmPVVGLVTestCase):
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
self.assertTrue(succ)
+ # try to shrink when deactivated
+ succ = BlockDev.lvm_lvresize("testVG", "testLV", 400 * 1024**2, None)
+ self.assertTrue(succ)
+
@unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
class LvmTestLVrename(LvmPVVGLVTestCase):
def test_lvrename(self):
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
index 7be8f1ab..8baae513 100644
--- a/tests/lvm_test.py
+++ b/tests/lvm_test.py
@@ -830,6 +830,10 @@ class LvmTestLVresize(LvmPVVGLVTestCase):
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
self.assertTrue(succ)
+ # try to shrink when deactivated
+ succ = BlockDev.lvm_lvresize("testVG", "testLV", 400 * 1024**2, None)
+ self.assertTrue(succ)
+
class LvmTestLVrename(LvmPVVGLVTestCase):
def test_lvrename(self):
"""Verify that it's possible to rename an LV"""
diff --git a/tests/skip.yml b/tests/skip.yml
index b06d05da..543d1396 100644
--- a/tests/skip.yml
+++ b/tests/skip.yml
@@ -143,3 +143,9 @@
- distro: "centos"
version: "9"
reason: "Creating RAID 1 LV on CentOS/RHEL 9 causes a system deadlock"
+
+- test: (lvm_test|lvm_dbus_tests).LvmTestLVresize.test_lvresize
+ skip_on:
+ - distro: "centos"
+ version: "9"
+ reason: "LVM >= 2.03.19 is not yet available breaking our check for LVM resize on CentOS 9 Stream"
--
2.40.1

View File

@ -1,24 +0,0 @@
From c06dd957335053595e50f705c6a4d4e1caf15a9c Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 26 Jan 2022 08:33:19 +0100
Subject: [PATCH] s390: Remove double fclose in bd_s390_dasd_online (#2045784)
---
src/plugins/s390.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/plugins/s390.c b/src/plugins/s390.c
index ac12b049..fb0dc982 100644
--- a/src/plugins/s390.c
+++ b/src/plugins/s390.c
@@ -290,7 +290,6 @@ gboolean bd_s390_dasd_online (const gchar *dasd, GError **error) {
if (wrc == EOF) {
g_set_error (error, BD_S390_ERROR, BD_S390_ERROR_DEVICE,
"Could not set DASD device %s online", dasd);
- fclose(fd);
bd_utils_report_finished (progress_id, (*error)->message);
return FALSE;
}
--
2.33.1

View File

@ -1,28 +0,0 @@
From b870898b014f44a97fe996278210f59c57c1196b Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 29 Jun 2023 08:36:48 +0200
Subject: [PATCH] vdo_stats: Remove unused libparted include
I have no idea where this came from, but we don't need (and never
did) libparted in vdo_stats.
Fixes: #916
---
src/plugins/vdo_stats.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/plugins/vdo_stats.c b/src/plugins/vdo_stats.c
index 7c8b8a45..620e972f 100644
--- a/src/plugins/vdo_stats.c
+++ b/src/plugins/vdo_stats.c
@@ -18,7 +18,6 @@
*/
#include <glib.h>
-#include <parted/parted.h>
#include <blockdev/utils.h>
#include "vdo_stats.h"
--
2.41.0

View File

@ -1,25 +0,0 @@
From ea1c7363b88d804e41a7ba0844a0e558f521eb03 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 19 Jun 2023 11:09:10 +0200
Subject: [PATCH] s390: Do not try to close an unopened stream
Our Fedora builds are failing on this on s390x.
---
src/plugins/s390.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/plugins/s390.c b/src/plugins/s390.c
index fb0dc982..705a9ae7 100644
--- a/src/plugins/s390.c
+++ b/src/plugins/s390.c
@@ -601,7 +601,6 @@ gboolean bd_s390_zfcp_online (const gchar *devno, const gchar *wwpn, const gchar
boolrc = bd_utils_exec_and_report_error_no_progress (zfcp_cio_free, NULL, error);
if (!boolrc) {
- fclose (fd);
g_free (online);
g_set_error (error, BD_S390_ERROR, BD_S390_ERROR_DEVICE,
"Could not remove device %s from device ignore list.", devno);
--
2.40.1

View File

@ -77,13 +77,12 @@
%define configure_opts %{?python3_copts} %{?lvm_dbus_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?tools_copts} %{?gi_copts} %{?nvme_copts}
Name: libblockdev
Version: 3.0
Release: 2%{?dist}
Version: 3.0.1
Release: 1%{?dist}
Summary: A library for low-level manipulation with block devices
License: LGPL-2.1-or-later
URL: https://github.com/storaged-project/libblockdev
Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz
Patch0: 0001-vdo_stats-Remove-unused-libparted-include.patch
BuildRequires: make
BuildRequires: glib2-devel
@ -483,6 +482,7 @@ Various nice storage-related tools based on libblockdev.
%ifarch s390 s390x
%package s390
Summary: The s390 plugin for the libblockdev library
Requires: %{name}-utils%{?_isa} = %{version}-%{release}
Requires: s390utils
%description s390
@ -641,8 +641,8 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%{_libdir}/girepository*/BlockDev*.typelib
%endif
%dir %{_sysconfdir}/libblockdev
%dir %{_sysconfdir}/libblockdev/conf.d
%config %{_sysconfdir}/libblockdev/conf.d/00-default.cfg
%dir %{_sysconfdir}/libblockdev/3/conf.d
%config %{_sysconfdir}/libblockdev/3/conf.d/00-default.cfg
%files devel
%{_libdir}/libblockdev.so
@ -751,7 +751,7 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%if %{with_lvm_dbus}
%files lvm-dbus
%{_libdir}/libbd_lvm-dbus.so.*
%config %{_sysconfdir}/libblockdev/conf.d/10-lvm-dbus.cfg
%config %{_sysconfdir}/libblockdev/3/conf.d/10-lvm-dbus.cfg
%files lvm-dbus-devel
%{_libdir}/libbd_lvm-dbus.so
@ -845,6 +845,26 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files plugins-all
%changelog
* Tue Jul 04 2023 Vojtech Trefny <vtrefny@redhat.com> - 3.0.1-1
- fs: Simplify struct BDFSInfo (tbzatek)
- boilerplate_generator: Annotate stub func args as G_GNUC_UNUSED (tbzatek)
- crypto: Remove stray struct redefinition (tbzatek)
- loop: Remove unused variable (tbzatek)
- build: Exit before AC_OUTPUT on error (tbzatek)
- loop: define LOOP_SET_BLOCK_SIZE is not defined (giulio.benetti)
- Make the conf.d directory versioned (vtrefny)
- configure: Fix MAJOR_VER macro (vtrefny)
- spec: Add dependency on libblockdev-utils to the s390 plugin (vtrefny)
- nvme: Mark private symbols as hidden (tbzatek)
- dist: Sync spec with downstream (vtrefny)
- misc: Update steps and Dockerfile for Python documentation (vtrefny)
- fs: Add missing copy and free functions to the header file (vtrefny)
- lvm: Add bd_lvm_segdata_copy/free to the header file (vtrefny)
- loop: Remove bd_loop_get_autoclear definition (vtrefny)
- lvm: Fix declaration for bd_lvm_vdolvpoolname (vtrefny)
- lvm: Make _vglock_start_stop static (vtrefny)
- vdo_stats: Remove unused libparted include (vtrefny)
* Thu Jun 29 2023 Python Maint <python-maint@redhat.com> - 3.0-2
- Rebuilt for Python 3.12

View File

@ -1 +1 @@
SHA512 (libblockdev-3.0.tar.gz) = b2f801b93832343934f81dc9b2440805a9ef72ac7cde80f5b2d6581eb2585f6a05c52c5791b52fabee4278593e6bfffb0cd46175708b8f9bcc03f64bf40f620f
SHA512 (libblockdev-3.0.1.tar.gz) = b45e2f26691fe4016c8a161e1300f1edfca7a810e7535dd1eb787ad88a0d3110f75e0da289027eaed16bad275bfbb709b29b946e5fc3750a56e86c6453aa3a6d