main - lvmdbustest: Re-work setUp
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=897b326cccc017b9e03...
Commit: 897b326cccc017b9e033b83d24ddcb007a3922f4
Parent: 7966f1dd18ab88199da7dd0d84a44945c2f864ca
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Sep 22 17:10:13 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Sep 22 17:10:13 2022 -0500
lvmdbustest: Re-work setUp
Place the addCleanup at the end as we don't want to go through clean up
if we don't make it through setUp. If we don't do this we can remove VGs
that we didn't create in the unit test.
---
test/dbus/lvmdbustest.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 9b1024db3..cf50bc564 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -385,8 +385,7 @@ class DaemonInfo(object):
# noinspection PyUnresolvedReferences
class TestDbusService(unittest.TestCase):
def setUp(self):
-
- self.addCleanup(self.clean_up)
+ self.pvs = []
# Because of the sensitive nature of running LVM tests we will only
# run if we have PVs and nothing else, so that we can be confident that
@@ -395,6 +394,10 @@ class TestDbusService(unittest.TestCase):
if len(self.objs[PV_INT]) == 0:
std_err_print('No PVs present exiting!')
sys.exit(1)
+
+ for p in self.objs[PV_INT]:
+ self.pvs.append(p.Pv.Name)
+
if len(self.objs[MANAGER_INT]) != 1:
std_err_print('Expecting a manager object!')
sys.exit(1)
@@ -403,9 +406,7 @@ class TestDbusService(unittest.TestCase):
std_err_print('Expecting no VGs to exist!')
sys.exit(1)
- self.pvs = []
- for p in self.objs[PV_INT]:
- self.pvs.append(p.Pv.Name)
+ self.addCleanup(self.clean_up)
self.vdo = supports_vdo()
@@ -460,7 +461,7 @@ class TestDbusService(unittest.TestCase):
# Check to make sure the PVs we had to start exist, else re-create
# them
self.objs, self.bus = get_objects()
- if hasattr(self, "pvs") and len(self.pvs) != len(self.objs[PV_INT]):
+ if len(self.pvs) != len(self.objs[PV_INT]):
for p in self.pvs:
found = False
for pc in self.objs[PV_INT]:
1 year, 7 months
main - lvmdbustest: Refuse to remove a VG we didn't create
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7966f1dd18ab88199da...
Commit: 7966f1dd18ab88199da7dd0d84a44945c2f864ca
Parent: 40018cbf5386e4ba76c0d4cc10aa1bd88ef0e6ab
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Sep 22 16:18:48 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Sep 22 16:19:16 2022 -0500
lvmdbustest: Refuse to remove a VG we didn't create
One of our previous commits introduced the side effect that we could
inadvertently remove a VG we didn't create, and lose data.
---
test/dbus/lvmdbustest.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index fc84026df..9b1024db3 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -410,9 +410,13 @@ class TestDbusService(unittest.TestCase):
self.vdo = supports_vdo()
def _recurse_vg_delete(self, vg_proxy, pv_proxy, nested_pv_hash):
+ vg_name = str(vg_proxy.Vg.Name)
+
+ if not vg_name.endswith(VG_TEST_SUFFIX):
+ std_err_print("Refusing to remove VG: %s" % vg_name)
+ return
for pv_device_name, t in nested_pv_hash.items():
- vg_name = str(vg_proxy.Vg.Name)
if vg_name in pv_device_name:
self._recurse_vg_delete(t[0], t[1], nested_pv_hash)
break
1 year, 7 months
main - lvmdbustest: Make vg name suffix more unique
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=40018cbf5386e4ba76c...
Commit: 40018cbf5386e4ba76c0d4cc10aa1bd88ef0e6ab
Parent: 36a8fb20bf8a42e7e3227ad85a2b29e0b1432b14
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Sep 22 16:17:20 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Sep 22 16:17:20 2022 -0500
lvmdbustest: Make vg name suffix more unique
---
test/dbus/lvmdbustest.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 045dbb2b0..fc84026df 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -29,6 +29,8 @@ g_tmo = 0
# Approx. min size
VDO_MIN_SIZE = mib(8192)
+VG_TEST_SUFFIX = "_vg_LvMdBuS_TEST"
+
EXE_NAME="/lvmdbusd"
# Prefix on created objects to enable easier clean-up
@@ -71,7 +73,7 @@ if pv_device_list:
def vg_n(prefix=None):
- name = rs(8, '_vg')
+ name = rs(8, VG_TEST_SUFFIX)
if prefix:
name = prefix + name
return g_prefix + name
1 year, 7 months
main - lvmdbusd: Correct lvm shell signal & child process handling
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=36a8fb20bf8a42e7e32...
Commit: 36a8fb20bf8a42e7e3227ad85a2b29e0b1432b14
Parent: c21783d4929ffd60f567ea90c9ae7c644d793d12
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Sep 21 10:05:36 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Sep 22 08:33:06 2022 -0500
lvmdbusd: Correct lvm shell signal & child process handling
Previously when the __del__ method ran on LVMShellProxy we would blindly
call terminate(). This was a race condition as the underlying process
may/maynot be present. When the process is still present the SIGTERM will
end up being seen by lvmdbusd too. Re-work the code so that we
first try to wait for the child process to exit and only then if it hasn't
exited will we send it a SIGTERM. We also ensure that when this is
executed we will briefly ignore a SIGTERM that arrives for the daemon.
---
daemons/lvmdbusd/cfg.py | 3 +++
daemons/lvmdbusd/lvm_shell_proxy.py.in | 32 +++++++++++++++++++++-----------
daemons/lvmdbusd/utils.py | 11 +++++++++++
3 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/daemons/lvmdbusd/cfg.py b/daemons/lvmdbusd/cfg.py
index 142cfabc7..70edad846 100644
--- a/daemons/lvmdbusd/cfg.py
+++ b/daemons/lvmdbusd/cfg.py
@@ -45,6 +45,9 @@ worker_q = queue.Queue()
# Main event loop
loop = None
+# Used to instruct the daemon if we should ignore SIGTERM
+ignore_sigterm = False
+
BUS_NAME = os.getenv('LVM_DBUS_NAME', 'com.redhat.lvmdbus1')
BASE_INTERFACE = 'com.redhat.lvmdbus1'
PV_INTERFACE = BASE_INTERFACE + '.Pv'
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
index 0ba0ffe5c..ac6d51e65 100755
--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
@@ -26,7 +26,7 @@ except ImportError:
import json
-from lvmdbusd.cfg import LVM_CMD, run
+import lvmdbusd.cfg as cfg
from lvmdbusd.utils import log_debug, log_error, add_no_notify, make_non_block,\
read_decoded, extract_stack_trace, LvmBug
@@ -59,7 +59,7 @@ class LVMShellProxy(object):
# a hang. Keep reading until we get the prompt back and the report
# FD does not contain valid JSON
- while keep_reading and run.value != 0:
+ while keep_reading and cfg.run.value != 0:
try:
rd_fd = [
self.parent_stdout_fd,
@@ -113,7 +113,7 @@ class LVMShellProxy(object):
self.exit_shell()
raise ioe
- if keep_reading and run.value == 0:
+ if keep_reading and cfg.run.value == 0:
# We didn't complete as we are shutting down
# Try to clean up lvm shell process
log_debug("exiting lvm shell as we are shutting down")
@@ -158,7 +158,7 @@ class LVMShellProxy(object):
# run the lvm shell
self.lvm_shell = subprocess.Popen(
- [LVM_CMD],
+ [cfg.LVM_CMD],
stdin=child_stdin_fd,
stdout=child_stdout_fd, env=local_env,
stderr=child_stderr_fd, close_fds=True,
@@ -259,18 +259,28 @@ class LVMShellProxy(object):
def exit_shell(self):
try:
self._write_cmd('exit\n')
- except Exception as e:
- log_error(str(e))
+ self.lvm_shell.wait(1)
+ self.lvm_shell = None
+ except Exception as _e:
+ log_error(str(_e))
def __del__(self):
- try:
- self.lvm_shell.terminate()
- except:
- pass
+ # Note: When we are shutting down the daemon and the main process has already exited
+ # and this gets called we have a limited set of things we can do, like we cannot call
+ # log_error as _common_log is None!!!
+ if self.lvm_shell is not None:
+ try:
+ self.lvm_shell.wait(1)
+ except subprocess.TimeoutExpired:
+ print("lvm shell child process did not exit as instructed, sending SIGTERM")
+ cfg.ignore_sigterm = True
+ self.lvm_shell.terminate()
+ child_exit_code = self.lvm_shell.wait(1)
+ print("lvm shell process exited with %d" % child_exit_code)
if __name__ == "__main__":
- print("USING LVM BINARY: %s " % LVM_CMD)
+ print("USING LVM BINARY: %s " % cfg.LVM_CMD)
try:
if len(sys.argv) > 1 and sys.argv[1] == "bisect":
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index dcb3e06bd..5aecb1fff 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -390,6 +390,17 @@ def handler(signum):
cfg.debug.dump()
cfg.flightrecorder.dump()
else:
+ # If we are getting a SIGTERM, and we sent one to the lvm shell we
+ # will ignore this and keep running.
+ if signum == signal.SIGTERM and cfg.ignore_sigterm:
+ # Clear the flag, so we will exit on SIGTERM if we didn't
+ # send it.
+ cfg.ignore_sigterm = False
+ return True
+
+ # If lvm shell is in use, tell it to exit
+ if cfg.SHELL_IN_USE is not None:
+ cfg.SHELL_IN_USE.exit_shell()
cfg.run.value = 0
log_error('Exiting daemon with signal %d' % signum)
if cfg.loop is not None:
1 year, 7 months
main - covscan: free wwid strings in lvmcache
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c21783d4929ffd60f56...
Commit: c21783d4929ffd60f567ea90c9ae7c644d793d12
Parent: e97cf8552c7e47ab0a85e9dbec2d3581e34e2cc3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Sep 21 12:15:13 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Sep 21 12:15:13 2022 -0500
covscan: free wwid strings in lvmcache
---
lib/cache/lvmcache.c | 46 +++++++++++++++++++++++++++++++---------------
1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 00916885c..2cb904fd4 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -644,8 +644,10 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
struct device *dev_mp = NULL;
struct device *dev1 = NULL;
struct device *dev;
+ char wwid1_buf[DEV_WWID_SIZE] = { 0 };
+ char wwid_buf[DEV_WWID_SIZE] = { 0 };
const char *wwid1 = NULL;
- const char *wwid;
+ const char *wwid = NULL;
int diff_wwid = 0;
int same_wwid = 0;
int dev_is_mp;
@@ -667,14 +669,23 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
dev = info->dev;
dev_is_mp = (cmd->dev_types->device_mapper_major == MAJOR(dev->dev)) && dev_has_mpath_uuid(cmd, dev, NULL);
+ /*
+ * dev_mpath_component_wwid allocates wwid from dm_pool,
+ * device_id_system_read does not and needs free.
+ */
+
if (dev_is_mp) {
if ((wwid1 = dev_mpath_component_wwid(cmd, dev))) {
+ strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE);
dev_mp = dev;
dev1 = dev;
}
} else {
- if ((wwid1 = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID)))
+ if ((wwid1 = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
+ strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE);
+ free((char *)wwid1);
dev1 = dev;
+ }
}
}
@@ -682,31 +693,36 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
dev = devl->dev;
dev_is_mp = (cmd->dev_types->device_mapper_major == MAJOR(dev->dev)) && dev_has_mpath_uuid(cmd, dev, NULL);
- if (dev_is_mp)
- wwid = dev_mpath_component_wwid(cmd, dev);
- else
- wwid = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID);
+ if (dev_is_mp) {
+ if ((wwid = dev_mpath_component_wwid(cmd, dev)))
+ strncpy(wwid_buf, wwid, DEV_WWID_SIZE);
+ } else {
+ if ((wwid = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
+ strncpy(wwid_buf, wwid, DEV_WWID_SIZE);
+ free((char *)wwid);
+ }
+ }
- if (!wwid && wwid1) {
+ if (!wwid_buf[0] && wwid1_buf[0]) {
log_debug("Different wwids for duplicate PVs %s %s %s none",
- dev_name(dev1), wwid1, dev_name(dev));
+ dev_name(dev1), wwid1_buf, dev_name(dev));
diff_wwid++;
continue;
}
- if (!wwid)
+ if (!wwid_buf[0])
continue;
- if (!wwid1) {
- wwid1 = wwid;
+ if (!wwid1_buf[0]) {
+ memcpy(wwid1_buf, wwid_buf, DEV_WWID_SIZE);
dev1 = dev;
continue;
}
/* Different wwids indicates these are not multipath components. */
- if (strcmp(wwid1, wwid)) {
+ if (strcmp(wwid1_buf, wwid_buf)) {
log_debug("Different wwids for duplicate PVs %s %s %s %s",
- dev_name(dev1), wwid1, dev_name(dev), wwid);
+ dev_name(dev1), wwid1_buf, dev_name(dev), wwid_buf);
diff_wwid++;
continue;
}
@@ -714,7 +730,7 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
/* Different mpath devs with the same wwid shouldn't happen. */
if (dev_is_mp && dev_mp) {
log_print("Found multiple multipath devices for PVID %s WWID %s: %s %s",
- pvid, wwid1, dev_name(dev_mp), dev_name(dev));
+ pvid, wwid1_buf, dev_name(dev_mp), dev_name(dev));
continue;
}
@@ -730,7 +746,7 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
return 0;
if (dev_mp)
- log_debug("Found multipath device %s for PVID %s WWID %s.", dev_name(dev_mp), pvid, wwid1);
+ log_debug("Found multipath device %s for PVID %s WWID %s.", dev_name(dev_mp), pvid, wwid1_buf);
*dev_mpath = dev_mp;
return 1;
1 year, 7 months
main - make: generate
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e97cf8552c7e47ab0a8...
Commit: e97cf8552c7e47ab0a85e9dbec2d3581e34e2cc3
Parent: 3a7aeebf7d7c58e53158321d73542c239896a3d7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 16 12:52:28 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 21 14:58:34 2022 +0200
make: generate
---
man/lvextend.8_pregen | 59 +++++++++++++++++++++++++++++++++++++++++++++------
man/lvreduce.8_pregen | 43 +++++++++++++++++++++++++++++++++----
man/lvresize.8_pregen | 51 ++++++++++++++++++++++++++++++++++++++++----
3 files changed, 139 insertions(+), 14 deletions(-)
diff --git a/man/lvextend.8_pregen b/man/lvextend.8_pregen
index 3c2bfa6bf..2e0ed3068 100644
--- a/man/lvextend.8_pregen
+++ b/man/lvextend.8_pregen
@@ -36,6 +36,10 @@ lvextend \(em Add space to a logical volume
\fB-l\fP|\fB--extents\fP [\fB+\fP]\fINumber\fP[PERCENT]
.br
\fB-f\fP|\fB--force\fP
+.br
+ \fB--fs\fP \fIString\fP
+.br
+ \fB--fsmode\fP \fIString\fP
.br
\fB-h\fP|\fB--help\fP
.br
@@ -123,6 +127,10 @@ Extend an LV by a specified size.
.br
[ \fB--poolmetadatasize\fP [\fB+\fP]\fISize\fP[m|UNIT] ]
.br
+[ \fB--fs\fP \fIString\fP ]
+.br
+[ \fB--fsmode\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -145,6 +153,10 @@ Extend an LV by specified PV extents.
.br
[ \fB-I\fP|\fB--stripesize\fP \fISize\fP[k|UNIT] ]
.br
+[ \fB--fs\fP \fIString\fP ]
+.br
+[ \fB--fsmode\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -170,7 +182,7 @@ Extend a pool metadata SubLV by a specified size.
.RE
.P
.RS 4
-LV1 types: thinpool
+LV1 types: linear thinpool
.RE
.P
\(em
@@ -184,6 +196,10 @@ Extend an LV according to a predefined policy.
.ad l
[ \fB-r\fP|\fB--resizefs\fP ]
.br
+[ \fB--fs\fP \fIString\fP ]
+.br
+[ \fB--fsmode\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -192,7 +208,7 @@ Extend an LV according to a predefined policy.
.RE
.P
.RS 4
-LV1 types: snapshot thinpool
+LV1 types: snapshot thinpool vdopool
.RE
.P
\(em
@@ -377,6 +393,36 @@ Override various checks, confirmations and protections.
Use with extreme caution.
.
.HP
+\fB--fs\fP \fIString\fP
+.br
+Control file system resizing when resizing an LV.
+\fBchecksize\fP: Check the fs size and reduce the LV if the fs is not
+using the reduced space (fs reduce is not needed.) If the reduced space
+is used by the fs, then do not resize the fs or LV, and return an error.
+(checksize only applies when reducing, and does nothing for extend.)
+\fBresize\fP: Resize the fs by calling the fs-specific resize command.
+This may also include mounting, unmounting, or running fsck. See --fsmode to
+control mounting behavior, and --nofsck to disable fsck.
+\fBresize_fsadm\fP: Use the old method of calling fsadm to handle the fs
+(deprecated.) Warning: this option does not prevent lvreduce from destroying
+file systems that are unmounted (or mounted if prompts are skipped.)
+\fBignore\fP: Resize the LV without checking for or handling a file system.
+Warning: using ignore when reducing the LV size may destroy the file system.
+.
+.HP
+\fB--fsmode\fP \fIString\fP
+.br
+Control file system mounting behavior for fs resize.
+\fBmanage\fP: Mount or unmount the fs as needed to resize the fs,
+and attempt to restore the original mount state at the end.
+\fBnochange\fP: Do not mount or unmount the fs. If mounting or unmounting
+is required to resize the fs, then do not resize the fs or the LV and fail
+the command.
+\fBoffline\fP: Unmount the fs if it is mounted, and resize the fs while it
+is unmounted. If mounting is required to resize the fs, then do not resize
+the fs or the LV and fail the command.
+.
+.HP
\fB-h\fP|\fB--help\fP
.br
Display help text.
@@ -410,9 +456,7 @@ Not used.
.HP
\fB-n\fP|\fB--nofsck\fP
.br
-Do not perform fsck before resizing filesystem when filesystem
-requires it. You may need to use --force to proceed with
-this option.
+Do not perform fsck when resizing the file system with --resizefs.
.
.HP
\fB--nohints\fP
@@ -485,7 +529,10 @@ See \fBlvmreport\fP(7) for more information.
.HP
\fB-r\fP|\fB--resizefs\fP
.br
-Resize underlying filesystem together with the LV using \fBfsadm\fP(8).
+Resize the fs using the fs-specific resize command.
+May include mounting, unmounting, or running fsck. See --fsmode to control
+mounting behavior, and --nofsck to disable fsck. See --fs for more options
+(--resizefs is equivalent to --fs resize.)
.
.HP
\fB-L\fP|\fB--size\fP [\fB+\fP]\fISize\fP[m|UNIT]
diff --git a/man/lvreduce.8_pregen b/man/lvreduce.8_pregen
index 4f6615449..61b71e4d9 100644
--- a/man/lvreduce.8_pregen
+++ b/man/lvreduce.8_pregen
@@ -52,6 +52,10 @@ the options section.
.br
[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
+[ \fB--fs\fP \fIString\fP ]
+.br
+[ \fB--fsmode\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -179,6 +183,36 @@ Override various checks, confirmations and protections.
Use with extreme caution.
.
.HP
+\fB--fs\fP \fIString\fP
+.br
+Control file system resizing when resizing an LV.
+\fBchecksize\fP: Check the fs size and reduce the LV if the fs is not
+using the reduced space (fs reduce is not needed.) If the reduced space
+is used by the fs, then do not resize the fs or LV, and return an error.
+(checksize only applies when reducing, and does nothing for extend.)
+\fBresize\fP: Resize the fs by calling the fs-specific resize command.
+This may also include mounting, unmounting, or running fsck. See --fsmode to
+control mounting behavior, and --nofsck to disable fsck.
+\fBresize_fsadm\fP: Use the old method of calling fsadm to handle the fs
+(deprecated.) Warning: this option does not prevent lvreduce from destroying
+file systems that are unmounted (or mounted if prompts are skipped.)
+\fBignore\fP: Resize the LV without checking for or handling a file system.
+Warning: using ignore when reducing the LV size may destroy the file system.
+.
+.HP
+\fB--fsmode\fP \fIString\fP
+.br
+Control file system mounting behavior for fs resize.
+\fBmanage\fP: Mount or unmount the fs as needed to resize the fs,
+and attempt to restore the original mount state at the end.
+\fBnochange\fP: Do not mount or unmount the fs. If mounting or unmounting
+is required to resize the fs, then do not resize the fs or the LV and fail
+the command.
+\fBoffline\fP: Unmount the fs if it is mounted, and resize the fs while it
+is unmounted. If mounting is required to resize the fs, then do not resize
+the fs or the LV and fail the command.
+.
+.HP
\fB-h\fP|\fB--help\fP
.br
Display help text.
@@ -207,9 +241,7 @@ Display long help text.
.HP
\fB-n\fP|\fB--nofsck\fP
.br
-Do not perform fsck before resizing filesystem when filesystem
-requires it. You may need to use --force to proceed with
-this option.
+Do not perform fsck when resizing the file system with --resizefs.
.
.HP
\fB--nohints\fP
@@ -259,7 +291,10 @@ See \fBlvmreport\fP(7) for more information.
.HP
\fB-r\fP|\fB--resizefs\fP
.br
-Resize underlying filesystem together with the LV using \fBfsadm\fP(8).
+Resize the fs using the fs-specific resize command.
+May include mounting, unmounting, or running fsck. See --fsmode to control
+mounting behavior, and --nofsck to disable fsck. See --fs for more options
+(--resizefs is equivalent to --fs resize.)
.
.HP
\fB-L\fP|\fB--size\fP [\fB-\fP]\fISize\fP[m|UNIT]
diff --git a/man/lvresize.8_pregen b/man/lvresize.8_pregen
index 1671741ce..89261f38d 100644
--- a/man/lvresize.8_pregen
+++ b/man/lvresize.8_pregen
@@ -36,6 +36,10 @@ lvresize \(em Resize a logical volume
\fB-l\fP|\fB--extents\fP [\fB+\fP|\fB-\fP]\fINumber\fP[PERCENT]
.br
\fB-f\fP|\fB--force\fP
+.br
+ \fB--fs\fP \fIString\fP
+.br
+ \fB--fsmode\fP \fIString\fP
.br
\fB-h\fP|\fB--help\fP
.br
@@ -109,6 +113,10 @@ Resize an LV by a specified size.
.br
[ \fB--poolmetadatasize\fP [\fB+\fP]\fISize\fP[m|UNIT] ]
.br
+[ \fB--fs\fP \fIString\fP ]
+.br
+[ \fB--fsmode\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -127,6 +135,10 @@ Resize an LV by specified PV extents.
.ad l
[ \fB-r\fP|\fB--resizefs\fP ]
.br
+[ \fB--fs\fP \fIString\fP ]
+.br
+[ \fB--fsmode\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -335,6 +347,36 @@ Override various checks, confirmations and protections.
Use with extreme caution.
.
.HP
+\fB--fs\fP \fIString\fP
+.br
+Control file system resizing when resizing an LV.
+\fBchecksize\fP: Check the fs size and reduce the LV if the fs is not
+using the reduced space (fs reduce is not needed.) If the reduced space
+is used by the fs, then do not resize the fs or LV, and return an error.
+(checksize only applies when reducing, and does nothing for extend.)
+\fBresize\fP: Resize the fs by calling the fs-specific resize command.
+This may also include mounting, unmounting, or running fsck. See --fsmode to
+control mounting behavior, and --nofsck to disable fsck.
+\fBresize_fsadm\fP: Use the old method of calling fsadm to handle the fs
+(deprecated.) Warning: this option does not prevent lvreduce from destroying
+file systems that are unmounted (or mounted if prompts are skipped.)
+\fBignore\fP: Resize the LV without checking for or handling a file system.
+Warning: using ignore when reducing the LV size may destroy the file system.
+.
+.HP
+\fB--fsmode\fP \fIString\fP
+.br
+Control file system mounting behavior for fs resize.
+\fBmanage\fP: Mount or unmount the fs as needed to resize the fs,
+and attempt to restore the original mount state at the end.
+\fBnochange\fP: Do not mount or unmount the fs. If mounting or unmounting
+is required to resize the fs, then do not resize the fs or the LV and fail
+the command.
+\fBoffline\fP: Unmount the fs if it is mounted, and resize the fs while it
+is unmounted. If mounting is required to resize the fs, then do not resize
+the fs or the LV and fail the command.
+.
+.HP
\fB-h\fP|\fB--help\fP
.br
Display help text.
@@ -363,9 +405,7 @@ Display long help text.
.HP
\fB-n\fP|\fB--nofsck\fP
.br
-Do not perform fsck before resizing filesystem when filesystem
-requires it. You may need to use --force to proceed with
-this option.
+Do not perform fsck when resizing the file system with --resizefs.
.
.HP
\fB--nohints\fP
@@ -438,7 +478,10 @@ See \fBlvmreport\fP(7) for more information.
.HP
\fB-r\fP|\fB--resizefs\fP
.br
-Resize underlying filesystem together with the LV using \fBfsadm\fP(8).
+Resize the fs using the fs-specific resize command.
+May include mounting, unmounting, or running fsck. See --fsmode to control
+mounting behavior, and --nofsck to disable fsck. See --fs for more options
+(--resizefs is equivalent to --fs resize.)
.
.HP
\fB-L\fP|\fB--size\fP [\fB+\fP|\fB-\fP]\fISize\fP[m|UNIT]
1 year, 7 months
main - tests: validate CONFIG_HZ_1000
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3a7aeebf7d7c58e5315...
Commit: 3a7aeebf7d7c58e53158321d73542c239896a3d7
Parent: 96f303eb08d6429e92d727020788830a3f7fcfc8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 21 14:44:05 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 21 14:58:34 2022 +0200
tests: validate CONFIG_HZ_1000
If we plan to use dm throttling for mirror targets - we actually
have to check whether kernel runs with CONFIG_HZ_1000 - if it does
not the whole idea of throttling is actually not working in the
testsuite as within a single 'tick' with HZ 100 way too much date
is being moved on any modern hardware - and since there is no plan
to change this in kernel - we simply avoid using throttling on such
kernel and test needs to work differently - either ignore results
or use much larger mirror sizes...
---
test/lib/aux.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index ca9406383..58439d62d 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1206,6 +1206,16 @@ remove_dm_devs() {
# Throttle down performance of kcopyd when mirroring i.e. disk image
throttle_sys="/sys/module/dm_mirror/parameters/raid1_resync_throttle"
throttle_dm_mirror() {
+ # if the kernel config file is present, validate whether the kernel uses HZ_1000
+ # and return failure for this 'throttling' when it does NOT as without this setting
+ # whole throttling is pointless on modern hardware
+ local kconfig="/boot/config-$(uname -r)"
+ if test -e "$kconfig" ; then
+ grep -q "CONFIG_HZ_1000=y" "$kconfig" 2>/dev/null || {
+ echo "WARNING: CONFIG_HZ_1000=y is NOT set in $kconfig -> throttling is unusable"
+ return 1
+ }
+ fi
test -e "$throttle_sys" || return
test -f THROTTLE || cat "$throttle_sys" > THROTTLE
echo ${1-1} > "$throttle_sys"
1 year, 7 months
main - tests: discard update
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=96f303eb08d6429e92d...
Commit: 96f303eb08d6429e92d727020788830a3f7fcfc8
Parent: cbfdb8735831412a7c87ce57c0ada5f1ee1c2358
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 16 12:52:08 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 21 14:58:34 2022 +0200
tests: discard update
---
test/shell/lvchange-thin.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvchange-thin.sh b/test/shell/lvchange-thin.sh
index d9d261e4b..5c231030c 100644
--- a/test/shell/lvchange-thin.sh
+++ b/test/shell/lvchange-thin.sh
@@ -30,8 +30,12 @@ lvcreate -L10M -T $vg/pool
# tests for checking thin-pool discard passdown are skipped
pvmajor=$(get pv_field "$dev1" major)
pvminor=$(get pv_field "$dev1" minor)
-test "$(< "/sys/dev/block/$pvmajor:$pvminor/queue/discard_granularity")" -ne 0 || \
- no_discard=1
+
+if test "$(< "/sys/dev/block/$pvmajor:$pvminor/queue/discard_granularity")" -eq 0 ; then
+ no_discard=1
+else
+ no_discard=
+fi
#
# Check change operations on a thin-pool without any thin LV
1 year, 7 months
main - makefiles: use single libs definition
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cbfdb8735831412a7c8...
Commit: cbfdb8735831412a7c87ce57c0ada5f1ee1c2358
Parent: 1bf1aca544e6d422d34aea356e69d6dbf0bdf3ba
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 5 15:57:21 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 21 14:58:34 2022 +0200
makefiles: use single libs definition
---
make.tmpl.in | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index a390553a4..869b87e12 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -298,9 +298,7 @@ endif
endif
ifeq ("@BUILD_DMEVENTD@", "yes")
- DMEVENT_LIBS = -ldevmapper-event -L$(interfacebuilddir) -ldevmapper
- LDFLAGS += -L$(top_builddir)/daemons/dmeventd
- CLDFLAGS += -L$(top_builddir)/daemons/dmeventd
+ DMEVENT_LIBS = -L$(top_builddir)/daemons/dmeventd -ldevmapper-event -L$(interfacebuilddir) -ldevmapper
endif
# Combination of DEBUG_POOL and DEBUG_ENFORCE_POOL_LOCKING is not suppored.
1 year, 7 months
main - tests: integrity switch to ext4
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1bf1aca544e6d422d34...
Commit: 1bf1aca544e6d422d34aea356e69d6dbf0bdf3ba
Parent: 9c2ed7422105c59446c4d8a894c87feb37c5de7a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 9 13:33:28 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 21 14:58:34 2022 +0200
tests: integrity switch to ext4
Since we would need to create a lot of 300M filesystem,
switch this test suite to ext4.
---
test/shell/integrity-blocksize-2.sh | 7 +++----
test/shell/integrity-blocksize-3.sh | 20 +++++++++-----------
test/shell/integrity-dmeventd.sh | 5 ++---
3 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/test/shell/integrity-blocksize-2.sh b/test/shell/integrity-blocksize-2.sh
index ae0e72ec6..b2e0fb06e 100644
--- a/test/shell/integrity-blocksize-2.sh
+++ b/test/shell/integrity-blocksize-2.sh
@@ -67,7 +67,7 @@ blockdev --getpbsz "$dev2"
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -88,7 +88,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -109,7 +109,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
lvconvert --raidintegrity y $vg/$lv1
@@ -127,4 +127,3 @@ lvchange -an $vg/$lv1
lvremove $vg/$lv1
vgremove -ff $vg
-
diff --git a/test/shell/integrity-blocksize-3.sh b/test/shell/integrity-blocksize-3.sh
index 7034bc362..300cc1895 100644
--- a/test/shell/integrity-blocksize-3.sh
+++ b/test/shell/integrity-blocksize-3.sh
@@ -66,7 +66,7 @@ blockdev --getpbsz "$dev2"
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -86,7 +86,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -106,7 +106,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
lvconvert --raidintegrity y $vg/$lv1
@@ -143,7 +143,7 @@ blockdev --getpbsz "$dev2"
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -163,7 +163,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -183,7 +183,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
lvconvert --raidintegrity y $vg/$lv1
@@ -220,7 +220,7 @@ blockdev --getpbsz "$dev2"
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -241,7 +241,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
umount $mnt
@@ -262,7 +262,7 @@ lvremove $vg/$lv1
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
echo "hello world" > $mnt/hello
lvconvert --raidintegrity y $vg/$lv1
@@ -281,5 +281,3 @@ lvremove $vg/$lv1
vgremove -ff $vg
aux cleanup_scsi_debug_dev
-sleep 1
-
diff --git a/test/shell/integrity-dmeventd.sh b/test/shell/integrity-dmeventd.sh
index 9049eb0f7..44121a186 100644
--- a/test/shell/integrity-dmeventd.sh
+++ b/test/shell/integrity-dmeventd.sh
@@ -14,7 +14,7 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-which mkfs.xfs || skip
+which mkfs.ext4 || skip
aux have_integrity 1 5 0 || skip
# Avoid 4K ramdisk devices on older kernels
aux kernel_at_least 5 10 || export LVM_TEST_PREFER_BRD=0
@@ -41,7 +41,7 @@ _prepare_vg() {
}
_add_new_data_to_mnt() {
- mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv1"
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
@@ -294,4 +294,3 @@ lvchange -an $vg/$lv1
_verify_data_on_lv
lvremove $vg/$lv1
vgremove -ff $vg
-
1 year, 7 months