David Teigland [Tue, 2 Sep 2025 17:55:46 +0000 (12:55 -0500)]
lvmpersist: fix check for no keys on mpath device
David Teigland [Tue, 2 Sep 2025 17:44:59 +0000 (12:44 -0500)]
lvmpersist: allow deactivation without PR
Zdenek Kabelac [Mon, 1 Sep 2025 21:54:55 +0000 (23:54 +0200)]
dmstats: fix parsing of list regions
Replace %4095c sscanf format specifier with position-based copying.
The _stats_parse_list_region() function previously used %4095c to read
the remaining part of the input buffer. Recent glibc versions
(2.42.9000-3.fc44) have changed the behavior of this format
specifier to align with C standard specifications, which affects
parsing when the buffer contains fewer than 4095 characters.
To ensure compatibility across different glibc versions, switch to
using %n to track the parsing position and manually copy the string
data using dm_strncpy().
Note: Binaries compiled with the previous implementation may experience
compatibility issues with newer glibc versions.
Zdenek Kabelac [Mon, 1 Sep 2025 11:40:34 +0000 (13:40 +0200)]
dmeventd: ignore result of pthread_cond_timedwait()
Used just for some sleep....
Zdenek Kabelac [Mon, 1 Sep 2025 11:26:24 +0000 (13:26 +0200)]
dmeventd: simplify grace period synchronization
Remove per-thread grace_mutex and use existing global_mutex
with per-thread condition variables.
We separate take of grace mutex there was slight race chance
of hitting wait condition while 2nd. thread already signaled wakeup.
With the use of global mutex (which must be held before and after
anyway), there is no such race chance even possible.
Zdenek Kabelac [Sun, 31 Aug 2025 19:35:01 +0000 (21:35 +0200)]
dmeventd: handle case for missing udev link
With old systems we cannot always check /dev/mapper/vg-lv name,
as those might be symlinks managed by udev. However monitoring
is not 'synchronized' with udev as dmventd API is major:minor
based and does not needed symlinks. So to 'compensate' this
and make just 'old system' working - just check also for
presence of /dev/dm-X device.
Zdenek Kabelac [Fri, 29 Aug 2025 20:00:24 +0000 (22:00 +0200)]
dmeventd: simplify _grace_period
Use plain 'int' time - so it doesn't make problems
on some archs (x32) printing time_t.
Also drop ret asign from pthread_cond_timedwait().
Zdenek Kabelac [Fri, 29 Aug 2025 19:38:37 +0000 (21:38 +0200)]
dmeventd: fix inode check for old kernels <3.x
Improve _get_device_inode() function with kernel version check
For kernel >=3: Use sysfs path format (/sys/dev/block/major:minor).
For kernel <3: Use /dev/mapper device path format.
Add explicit handling for very old kernels (<3.x) that don't change
inode numbers for /sys device-mapper devices.
David Teigland [Fri, 29 Aug 2025 14:42:29 +0000 (09:42 -0500)]
lvmpersist: fix vgremove when another key is registered
For vgremove, split persist stop steps into:
1. prepare, which gets the pr key and VG devices,
and happens before the normal vgremove.
2. run, which removes pr key from the VG devices,
and happens after the normal vgremove.
This is necessary if another PR key is registered on the device
(which likely doesn't happen in the normal usage pattern, but is
still possible.)
When another key exists, removing the local PR key will cause the
machine to lose the ability to write VG metadata to the device.
So, the removal of the local PR key must happen after the VG metadata
is written for vgremove. The prepare step must remain at the beginning
of the command, while the list of PVs in the VG still exists.
Peter Rajnoha [Fri, 29 Aug 2025 11:50:20 +0000 (13:50 +0200)]
tools: pvchange: unlock devices file at the end of cmd processing
Remove the line, not just comment out.
Peter Rajnoha [Fri, 29 Aug 2025 11:43:20 +0000 (13:43 +0200)]
tools: pvchange: unlock devices file at the end of cmd processing
Unlock devices file at the end of cmd processing, after all the PVs are
processed, not after the first processed PV.
Before this patch:
❯ pvchange -u /dev/sda /dev/sdb
Physical volume "/dev/sda" changed
WARNING: Devices file unlock no fd.
Physical volume "/dev/sdb" changed
2 physical volumes changed / 0 physical volumes not changed
With this patch applied:
❯ pvchange -u /dev/sda /dev/sdb
Physical volume "/dev/sda" changed
Physical volume "/dev/sdb" changed
2 physical volumes changed / 0 physical volumes not changed
The lvm_run_command/devices_file_exit/unlock_devices_file will
do the unlock at the very end of cmd processing.
Zdenek Kabelac [Thu, 28 Aug 2025 12:43:50 +0000 (14:43 +0200)]
dmeventd: fixes for grace period timer
Fix several problems in recent dmeventd grace period enhancement:
1. **Timer reset bug**: Threads exiting grace period were starting
time period with rather random time 'offset' causing change
in behavior and firing monitor action in non-deterministic time.
Reset timer (next_time = current_time + timeout) AFTER grace
period wait.
2. **Device identity verification**: Add inode tracking to prevent
incorrect thread reuse when device UUID is recycled. Grace period
thread lookup now verifies device inode matches to ensure same
physical device. This avoid reusing of monitored values for
a different device.
'diskseq' was also considered as unique identifier, but inode
check seems to be easier to check and is not 'so new'.
Also another solution could have been to change dmeventd protocol,
and introduce supend/resume calls - but this could be another source
of problem.
3. **Signal handling order**: Move SIGALRM reset to occur BEFORE
entering grace period instead of after. This prevents potential
error path trouble that may have shutdown reused thread causing
the actual monitoring to be silently lost.
4. **Event state cleanup**: Clear current_events before grace period
to prevent stale event processing after thread reuse.
Note: wondering if there can be any problem with inode check....
David Teigland [Mon, 25 Aug 2025 17:39:39 +0000 (12:39 -0500)]
man lvmpersist: shared VGs with locktype dlm work with PR
David Teigland [Mon, 25 Aug 2025 17:33:24 +0000 (12:33 -0500)]
vgchange persist stop: use lockopt force to skip lockstop check
vgchange --persist stop requires locking to first be stopped
(vgchange --lockstop). Allow setting --lockopt force to bypass
this check so that PR can be forcibly stopped.
David Teigland [Mon, 25 Aug 2025 17:16:41 +0000 (12:16 -0500)]
lvmpersist: fix device support check
Fix commit
b2bc06caf8e653828cbfd70250114043846c377a
"lvmpersist: check devices support PR before certain commands"
which broke clear and read commands. Change to skip individual
devices in clear/read if they don't support PR.
David Teigland [Mon, 25 Aug 2025 15:54:35 +0000 (10:54 -0500)]
man lvmpersist: improve description
Marian Csontos [Tue, 19 Aug 2025 13:56:21 +0000 (15:56 +0200)]
toollib: proper error path handling
Peter Rajnoha [Tue, 19 Aug 2025 08:54:21 +0000 (10:54 +0200)]
tools: allow --reportformat for pv/vg/lvdisplay log report
The pv/vg/lvdisplay (without -C|--columns) does not use the reporting
mode for the output. However, we can still allow the --reportformat
option for these commands, but it will affect only the log report,
like we have for other non-reporting lvm commands
(e.g. lvchange,vgchange...).
David Teigland [Fri, 8 Aug 2025 17:36:11 +0000 (12:36 -0500)]
lvmdevices: do not create system.devices when deleting entries
When using "lvmdevices --deldev" or "lvmdevices --delpvid" and no
system.devices file exists, the commands should not create the file.
David Teigland [Thu, 14 Aug 2025 21:27:09 +0000 (16:27 -0500)]
lvmpersist: check devices support PR before certain commands
Produce a proper error message, avoiding an ugly jq null list
error when handling nvme devs that do not support PR.
David Teigland [Thu, 14 Aug 2025 21:03:32 +0000 (16:03 -0500)]
vgchange: setpersist enabling should check if PR works on devs
attempt to read PR keys from VG devs before enabling PR on the VG
to ensure PR works.
Peter Rajnoha [Wed, 13 Aug 2025 11:57:55 +0000 (13:57 +0200)]
tests: update listings.sh
Test further reporting options that can be used only with -C|--columns
for pv/vg/lvdisplay.
Peter Rajnoha [Wed, 13 Aug 2025 11:43:20 +0000 (13:43 +0200)]
WHATS_NEW: update
Peter Rajnoha [Wed, 13 Aug 2025 10:52:57 +0000 (12:52 +0200)]
toollib: also initialize processing handle in process_each_pv
Just like process_each_vg and process_each_lv, the top-level process_each_pv
should also initialize the processing handle (if the handle not already passed
as argument for use). This is mainly important, among others, for proper
log_report tracking and proper output formatting.
For example:
Before this patch - there are two "log" sections as the processing handle is
initialized dynamically more times if not passed explicitly from the top-level
process_each_pv function:
❯ pvdisplay --config 'log/report_command_log=1 report/output_format=json'
{
"log": [
...
]
}
{
"log": [
...
]
}
❯ pvdisplay --config 'log/report_command_log=1 report/output_format=json' | jsonlint
<stdin>:17:2: Error: Unexpected text after end of JSON value
| At line 17, column 2, offset 4463
<stdin>: has errors
With this patch applied:
❯ pvdisplay --config 'log/report_command_log=1 report/output_format=json'
{
"log": [
...
]
}
❯ pvdisplay --config 'log/report_command_log=1 report/output_format=json' | jsonlint
<stdin>: ok
Peter Rajnoha [Wed, 13 Aug 2025 07:24:59 +0000 (09:24 +0200)]
make: generate
Peter Rajnoha [Wed, 13 Aug 2025 07:23:31 +0000 (09:23 +0200)]
tools: allow report options only with pv/vg/lvdisplay -C|--columns
--configreport, --logonly, --reportformat and --select options can be
used only if -C|--columns is used at the same time. These options are
only to control the reporting infrastructure. We switch to reporting
mode using that -C|--columns switch.
Using the options for reporting mode if reporting is not initiated
(using the -C|--columns switch) can cause various issues and
inconsistencies in the output.
See also https://github.com/lvmteam/lvm2/issues/144.
Peter Rajnoha [Tue, 12 Aug 2025 12:14:00 +0000 (14:14 +0200)]
dmeventd: fix error with older compilers
Peter Rajnoha [Tue, 12 Aug 2025 12:11:13 +0000 (14:11 +0200)]
dmeventd: fix error with older compilers
dmeventd.c:97: error: initializer element is not constant
Peter Rajnoha [Tue, 12 Aug 2025 11:25:03 +0000 (13:25 +0200)]
tests: vgsplit-cache: remove the splitted VG
Peter Rajnoha [Tue, 12 Aug 2025 11:23:28 +0000 (13:23 +0200)]
WHATS_NEW: update
Peter Rajnoha [Tue, 12 Aug 2025 10:56:58 +0000 (12:56 +0200)]
tests: vgsplit-cache: also test splitting a PV not used for cachevol LV
Peter Rajnoha [Tue, 12 Aug 2025 09:32:18 +0000 (11:32 +0200)]
vgsplit: fix check for not splitting an LV between two VGs for cachevol
When cachevol was used for the cache LV, the check for not splitting an
LV between two VGs was incorrect, not allowing to split the VG in cases
it should have been possible.
For example, splitting a VG which contains the cache LV with cachevol
only on two devices (sda and sdb here) and leaving third device completely
unused (sdc here) should clearly allow us to split it into a new VG:
❯ vgcreate vg /dev/sd{a..c}
Physical volume "/dev/sda" successfully created.
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
Volume group "vg" successfully created
❯ lvcreate -l2 -n main vg /dev/sda
Logical volume "main" created.
❯ lvcreate -l2 -n fast vg /dev/sdb
Logical volume "fast" created.
❯ lvconvert -y --type cache --cachevol fast vg/main
Logical volume vg/main is now cached.
❯ lvs -a -o name,devices vg
lv_name devices
[fast_cvol] /dev/sdb(0)
main main_corig(0)
[main_corig] /dev/sda(0)
❯ lsblk -o name /dev/sd{a..c}
NAME
sda
└─vg-main_corig
└─vg-main
sdb
└─vg-fast_cvol
├─vg-fast_cvol-cdata
│ └─vg-main
└─vg-fast_cvol-cmeta
└─vg-main
sdc
Before this patch:
❯ vgsplit vg vg2 /dev/sdc
Logical volume vg/main must be inactive.
❯ vgchange -an vg
0 logical volume(s) in volume group "vg" now active
❯ vgsplit vg vg2 /dev/sdc
Can't split LV main between two Volume Groups
With this patch applied:
❯ vgsplit vg vg2 /dev/sdc
New volume group "vg2" successfully split from "vg"
Mikulas Patocka [Mon, 11 Aug 2025 16:34:57 +0000 (11:34 -0500)]
test integrity.sh use writemostly to reliably detect mismatches
The test shell/integrity.sh creates raid arrays, corrupts one of the
legs, then reads the array and verifies that the corruption was
corrected. Finally, the test tests that the number of mismatches on the
corrupted leg is non-zero.
The problem is that the raid1 implementation may freely choose which leg
to read from. If it chooses to read the non-corrupted leg, the corruption
is not detected, the number of mismatches is not incremented and the test
reports this as failure.
Fix this failure by marking the non-corrupted leg as "writemostly", so
that the kernel doesn't try to read it (it reads it only if it finds
corruption on the other leg).
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
David Teigland [Mon, 11 Aug 2025 16:27:06 +0000 (11:27 -0500)]
Revert "test integrity.sh cannot rely on mismatches being detected for raid1"
This reverts commit
e50e59ae42a5def33e7d2fa514fccdf6db2cc060.
David Teigland [Fri, 8 Aug 2025 19:06:24 +0000 (14:06 -0500)]
lvmlockd: --lockopt was mistakenly ignored when --nolocking was set
Mikulas Patocka [Thu, 7 Aug 2025 15:55:09 +0000 (10:55 -0500)]
test integrity.sh cannot rely on mismatches being detected for raid1
The test shell/integrity.sh creates raid arrays, corrupts one of the
legs, then reads the array and verifies that the corruption was
corrected. Finally, the test tests that the number of mismatches on the
corrupted leg is non-zero.
The problem is that the raid1 implementation may freely choose which leg
to read from. If it chooses to read from the non-corrupted leg, the
corruption is not detected, the number of mismatches is not incremented
and the test reports this as a failure.
Fix the test by not checking the number of integrity mismatches for
raid1.
Peter Rajnoha [Mon, 4 Aug 2025 10:51:27 +0000 (12:51 +0200)]
test: vgsplit-raid: also test RAID LVs with integrity
Peter Rajnoha [Fri, 25 Jul 2025 08:45:07 +0000 (10:45 +0200)]
vgsplit: fix check for not splitting an LV between two VGs
Fix check for not splitting an LV between two VGs in case
where the LVs contains an internal layer.
For example, integrity layer for RAIDs and splitting a PV that
is not part of the RAID LV at all (sdc here):
❯ vgcreate vg /dev/sda /dev/sdb /dev/sdc
Volume group "vg" successfully created
❯ lvcreate -l1 -m1 --type raid1 --raidintegrity y vg /dev/sda /dev/sdb
Logical volume "lvol0" created.
Before this patch:
❯ vgsplit vg vg2 /dev/sdc
Logical volume vg/lvol0_rimage_0 (part of lvol0) must be inactive.
❯ vgchange -an vg
0 logical volume(s) in volume group "vg" now active
❯ vgsplit vg vg2 /dev/sdc
Can't split LV lvol0_rimage_0 between two Volume Groups
With this patch applied:
❯ vgsplit vg vg2 /dev/sdc
New volume group "vg2" successfully split from "vg"
Zdenek Kabelac [Wed, 30 Jul 2025 22:54:23 +0000 (00:54 +0200)]
test: aux starts dmeventd with small grace period
For our tests we expect very fast reaction.
So to keep i.e. reporting for the test 'lvextend-thin-metadata-dmeventd'
fast use just 2 seconds grace period (thread reuse).
Zdenek Kabelac [Tue, 22 Jul 2025 11:52:37 +0000 (13:52 +0200)]
dmeventd: add thread grace period for monitoring
Add thread reuse mechanism to reduce overhead when devices are frequently
registered/unregistered by introducing a configurable grace period where
monitoring threads wait for potential reuse before termination.
Key changes:
- Add -g option to configure grace period (0-300 seconds, default: 10s)
- Introduce DM_THREAD_GRACE_PERIOD state for threads awaiting reuse
- Implement thread reuse for matching device/dso combinations
- Add pthread condition variables and mutexes for grace period synchronization
- Add thread usage counter and enhanced debug logging
- Add _reset_pending_signal() to handle SIGALRM cleanup on thread reuse
- Refactor _monitor_thread() to support grace period workflow
- Update timeout thread to skip non-running threads
- Simplify thin plugin logging
This optimization significantly reduces thread creation/destruction overhead
in scenarios with rapid device registration/unregistration cycles, such as
creating snapshots of thin volumes, while maintaining proper cleanup and
thread safety.
Zdenek Kabelac [Wed, 30 Jul 2025 15:03:58 +0000 (17:03 +0200)]
tests: update checked message
lvconvert output printed message was slighlty updated
Zdenek Kabelac [Wed, 30 Jul 2025 15:00:32 +0000 (17:00 +0200)]
Revert "tests: Adapt RAID test to changes"
This reverts commit
53db14171c6b516058486b2a80eaa17af32a246b.
Marian Csontos [Wed, 30 Jul 2025 13:34:41 +0000 (15:34 +0200)]
post-release
Marian Csontos [Wed, 30 Jul 2025 13:34:41 +0000 (15:34 +0200)]
pre-release 2.03.34
Zdenek Kabelac [Wed, 30 Jul 2025 09:03:26 +0000 (11:03 +0200)]
WHATS_NEW: update
Zdenek Kabelac [Wed, 30 Jul 2025 09:06:23 +0000 (11:06 +0200)]
lvconvert: add non changing conversion message
Print message about raid/mirror conversion for case,
where the raid/mirror is already in the requested state.
This case currently returns success.
Zdenek Kabelac [Wed, 30 Jul 2025 09:01:21 +0000 (11:01 +0200)]
Revert "test: adjust lvconvert-raid.sh to now erroring non-changing image raid1 request"
This reverts commit
ed139168596f1a85b81bc6bbbb7280796eb83476.
Zdenek Kabelac [Wed, 30 Jul 2025 09:01:16 +0000 (11:01 +0200)]
Revert "test: fix invalid if-then-fi logic"
This reverts commit
612a22ac0829669a5bd8d6fc171d734dce583bf5.
Zdenek Kabelac [Wed, 30 Jul 2025 08:59:10 +0000 (10:59 +0200)]
Revert "test: adjust lvconvert-mirror-basic.sh to now erroring non-changing image mirror request"
This reverts commit
8e2cdcc0067526c29197c2ba92ea6e7921a19558.
Zdenek Kabelac [Wed, 30 Jul 2025 08:58:50 +0000 (10:58 +0200)]
Revert "test: use proper if-then-fi sequence"
This reverts commit
d2a66d43435fd20f248647c78579586fa8bbb1d9.
Zdenek Kabelac [Wed, 30 Jul 2025 09:06:35 +0000 (11:06 +0200)]
Revert "lvconvert: error mirror LV non-changing request"
This reverts commit
1593a6e47c37d57f0d69ab81bc70a186be908f98.
Zdenek Kabelac [Wed, 30 Jul 2025 08:56:39 +0000 (10:56 +0200)]
Revert "lvconvert: error raid1 LV non-changing image count request"
This reverts commit
c901528053e7f63538239431480f20db8b7d4ca6.
Zdenek Kabelac [Tue, 29 Jul 2025 14:00:39 +0000 (16:00 +0200)]
dmeventd: _get_status returns success for non monitoring
No longer returning EINVAL when the dmeventd is not monitoring
any device (there are no registered devices).
This makes usable i.e. 'dmeventd -R' for the case, the dmeventd
was not monnitoring anything during this call.
Previously this actually cause refuse of 'restart' - since
restarting 'dmeventd' has seen failing resutl of a call:
DM_EVENT_CMD_GET_STATUS
David Teigland [Mon, 28 Jul 2025 18:35:16 +0000 (13:35 -0500)]
vgextend: fix dev_read_reservation message
Common vgextend commands were logging a message about
dev_read_reservation when PR was not being used.
Only attempt PR work from vgextend when either the
PR require or autostart settings are enabled on the VG.
David Teigland [Mon, 28 Jul 2025 18:34:11 +0000 (13:34 -0500)]
nvme: fix log messages in dev_find_key_nvme
they were mistakenly logging as dev_read_reservation
Peter Rajnoha [Thu, 24 Jul 2025 08:51:59 +0000 (10:51 +0200)]
man: add note about return codes for LV resize with and without FS resize
Zdenek Kabelac [Wed, 23 Jul 2025 12:47:55 +0000 (14:47 +0200)]
WHATS_NEW: update
Zdenek Kabelac [Tue, 22 Jul 2025 18:35:24 +0000 (20:35 +0200)]
dmeventd: add device existence check
Add device existence check after successful wait ioctl to prevent
processing events on removed devices.
When dm_task_run() succeeds on a WAITEVENT ioctl, the success might
actually indicate that the device was removed rather than a genuine
device event. Without this check, dmeventd would attempt to process
ERROR events on non-existent devices, leading to unnecessary error
commands and log noise.
This fix adds a _fill_device_data() call immediately after successful
wait completion to verify the device still exists. If the device is
gone, execution jumps to the existing ENXIO error path which properly
handles device disappearance.
Note: Future kernel versions may return ENXIO directly from the wait
ioctl when devices are removed, making this workaround unnecessary.
Until then, this extra INFO ioctl provides the needed verification.
Zdenek Kabelac [Tue, 22 Jul 2025 18:34:38 +0000 (20:34 +0200)]
dmeventd: check device exists
Check first whether the monitored device actually really exists,
before resolving its device name.
In the case device is not present in DM table, fail _fill_device_data().
Zdenek Kabelac [Tue, 22 Jul 2025 11:53:05 +0000 (13:53 +0200)]
dmeventd: update types in thin plugin
Use matching dm_percent_t type to store percent values.
Zdenek Kabelac [Thu, 17 Jul 2025 21:07:05 +0000 (23:07 +0200)]
scripts: refactor lvmdump directory validation
Break down complex one-liner directory check into explicit steps with
clear error messages and comments.
The original code used a dense subshell expression combining multiple
tests with logical operators, making it difficult to understand and
maintain. This refactoring separates the logic into:
1. Check directory accessibility (read/write/execute permissions)
2. Check if directory is empty (including hidden files)
Each check now has a specific error message, making it easier for users
to understand what went wrong. The functionality remains identical, but
the code is now more maintainable and debuggable.
Changes:
- Split accessibility and emptiness checks into separate if statements
- Add descriptive comments explaining each validation step
- Provide specific error messages for different failure conditions
- Maintain original behavior including dotglob/nullglob handling
Zdenek Kabelac [Wed, 23 Jul 2025 12:01:07 +0000 (14:01 +0200)]
vdo: fix 32b portability issue in vdo_header struct
Replace size_t with uint64_t in struct vdo_header to ensure consistent
64-bit size field across all architectures.
On 32-bit platforms, size_t is only 4 bytes, which causes incorrect
structure layout when reading VDO metadata that expects a 64-bit size
field. This fix ensures the VDO header structure maintains the same
binary layout regardless of target architecture.
While 32-bit architectures are not officially supported for VDO,
this change improves code correctness and prevents potential issues
during cross-compilation or when building on 32-bit development
environments.
Peter Rajnoha [Wed, 23 Jul 2025 07:24:07 +0000 (09:24 +0200)]
lvmdevices: log_error when writing devices file fails
Peter Rajnoha [Wed, 23 Jul 2025 07:17:36 +0000 (09:17 +0200)]
device_id: log_warn instead of log_error in device_ids_write
It is not always the case that the whole command fails if
device_ids_write fail so change all log_error to log_warn and let the
caller decide.
Peter Rajnoha [Tue, 22 Jul 2025 10:16:56 +0000 (12:16 +0200)]
test: lvresize-fs-crypt: test not enough space left for crypt data
Peter Rajnoha [Tue, 22 Jul 2025 07:46:39 +0000 (09:46 +0200)]
WHATS_NEW: update
Peter Rajnoha [Mon, 21 Jul 2025 11:41:32 +0000 (13:41 +0200)]
lvmdevices: return error if writing device ids fail for --delldev
Peter Rajnoha [Mon, 21 Jul 2025 11:40:30 +0000 (13:40 +0200)]
device_id: always log_error on device ids write error
Peter Rajnoha [Fri, 18 Jul 2025 13:06:36 +0000 (15:06 +0200)]
lv_manip.c: fix lvresize corruption in LV->crypt->FS stack if near crypt min size limit
If we have LV->crypt->FS stack, check that the adjustment for the crypt
data offset will left space for the crypt data itself. Fix possible underflow.
Example:
❯ lvs -o name,size vg/lvol0
lv_name lv_size
lvol0 124.00m
❯ lsblk /dev/vg/lvol0
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vg-lvol0 252:2 0 124M 0 lvm
└─a 252:4 0 108M 0 crypt
Before this patch (the incorrect resulting underflowed file system size after adjustment
for crypt data offset, crypt data then severed by the LV resize without proper
crypt resize beforehand):
❯ lvreduce --yes --resizefs -L -123M vg/lvol0
Rounding size to boundary between physical extents: 120.00 MiB.
Checking crypt device /dev/dm-4 on LV vg/lvol0.
File system size
18446744073696968704b is adjusted for crypt data offset
16777216b.
File system ext4+crypto_LUKS found on vg/lvol0.
File system size (108.00 MiB) is smaller than the requested size (<16.00 EiB).
File system reduce is not needed, skipping.
crypt device is already reduced to
113246208 bytes.
Size of logical volume vg/lvol0 changed from 124.00 MiB (31 extents) to 4.00 MiB (1 extents).
Logical volume vg/lvol0 successfully resized.
With this patch applied:
❯ lvreduce --yes --resizefs -L -123M vg/lvol0
Rounding size to boundary between physical extents: 120.00 MiB.
Checking crypt device /dev/dm-4 on LV vg/lvol0.
Crypt header requires 16.00 MiB, not enough space left for crypt data.
Zdenek Kabelac [Thu, 17 Jul 2025 19:11:28 +0000 (21:11 +0200)]
test: simplify bash
Just check directly /proc/mdstat - if it's missing or there is not
raid1 string present do 'modprobe'.
Zdenek Kabelac [Thu, 17 Jul 2025 18:02:13 +0000 (20:02 +0200)]
test: aux simplify bash condition
Zdenek Kabelac [Thu, 17 Jul 2025 18:01:00 +0000 (20:01 +0200)]
test: report possibly issue for loop device remove
Warn if there are problems when removing loop devices.
Also use slightly smaller raid arrays with smaller extent size.
Zdenek Kabelac [Thu, 17 Jul 2025 15:52:21 +0000 (17:52 +0200)]
test: use proper DM_DEV_DIR
Use correct path - if the system does not have installed lvm udev rules
these /dev/vgname/lvname symlinks are not created - but test
running in test's dev dir gets symlinks created by lvm2 itself.
Zdenek Kabelac [Thu, 17 Jul 2025 12:10:52 +0000 (14:10 +0200)]
test: simplify if logic
Easier to read set of 'if' conditions.
Zdenek Kabelac [Wed, 16 Jul 2025 14:55:58 +0000 (16:55 +0200)]
test: fix invalid if-then-fi logic
Replace incorrect test && lvconvert || lvconvert
Use simplier NOT.
Zdenek Kabelac [Wed, 16 Jul 2025 13:08:14 +0000 (15:08 +0200)]
test: raid tuning
Use slightly bigger PVs, so the raid takes a bit more time to fully
reshape arrays - so we avoid conversion to be finished to fast even
with slowered devices.
Grab blockdev size before calling 'lvs' command.
Zdenek Kabelac [Thu, 17 Jul 2025 18:00:36 +0000 (20:00 +0200)]
scripts: lvm_import_vdo simplier bash logic
Zdenek Kabelac [Thu, 17 Jul 2025 12:29:27 +0000 (14:29 +0200)]
scripts: blkdeactivate simplify bash
Use correct if-then-fi.
Use local IFS instead handling ORIG_IFS.
Peter Rajnoha [Thu, 17 Jul 2025 10:07:00 +0000 (12:07 +0200)]
revert: lv_manip: retuurn failure for LV resize without actual LV+FS resize
We have different behavior for lvreduce (contains the fs size
pre-check before calling the external script) and lvextend
(does not ave the pre-check).
Also, there's different behavior with "lvreduce --fs resize"
(contains the pre-check) and "lvreduce --fs resize_fsadm"
(does not have the pre-check).
Obvously, only "lvreduce --fs resize" does have the pre-check.
To make it consitent all across, we should remove that one
and everybody will be happy.
Peter Rajnoha [Thu, 17 Jul 2025 08:24:32 +0000 (10:24 +0200)]
lv_manip: also track if FS resize executed when using fsadm
Peter Rajnoha [Wed, 16 Jul 2025 13:16:55 +0000 (15:16 +0200)]
lv_manip: add error message for size 0 after adjusting size for LV resize
Peter Rajnoha [Wed, 16 Jul 2025 12:52:18 +0000 (14:52 +0200)]
tests: resizing to same size is considered an error
Peter Rajnoha [Tue, 15 Jul 2025 10:10:28 +0000 (12:10 +0200)]
lv_manip: return failure for LV resize without actual LV+FS resize
Also return failure if there is no change in file system size while
resizing an LV including the file system, lik with lvresize/lvreduce --fs resize'.
Zdenek Kabelac [Wed, 16 Jul 2025 10:37:48 +0000 (12:37 +0200)]
WHATS_NEW: update
Zdenek Kabelac [Wed, 16 Jul 2025 10:35:14 +0000 (12:35 +0200)]
test: some updates for valgrind run
Since execution with valgrind is much slower we need
to skip some 'race-based' tests.
Zdenek Kabelac [Tue, 15 Jul 2025 21:56:43 +0000 (23:56 +0200)]
test: skip raid resizing on buggy kernel
Kernel without commit kernel commit
9f346f7d4ea73692b82f5102ca8698e4040469ea
cannot reasize raid LV without failing the raid itself.
So skip some tests for kernels 6.13 6.13 6.15.
TODO: maybe we want to print some warning message to the users
with affected kernels ??
Zdenek Kabelac [Mon, 14 Jul 2025 14:14:55 +0000 (16:14 +0200)]
test: lvconvert-raid-reshape-size add verify udev
With the use of --noudevsync we actually need to also ensure
we verify link create - as without synchronization we are not
able to properly wait - so lvm2 needs to create links itself.
It's hack where it would be better to not use it - but so far
there is no easy fix.
Make skip variables easily overridable by setting make vars.
Also further reduce used PV sizes.
Zdenek Kabelac [Mon, 14 Jul 2025 14:14:15 +0000 (16:14 +0200)]
debug: add message for noudevsync path
To avoid confusion, there is no synchronization of device names
when option --noudevsync is used. Make it obvious from debug trace.
Zdenek Kabelac [Sun, 13 Jul 2025 21:41:57 +0000 (23:41 +0200)]
test: aux add more ignored dirs
Zdenek Kabelac [Sun, 13 Jul 2025 21:22:11 +0000 (23:22 +0200)]
test: fix skipping of this repair test
Fix the usage of delay_dev so the test is properly executed
and not skiped. For major mirror slowdown use smalled region
sizes that are cause way more frequent commits so we can go
with significantly smaller delays.
Also check repair to work for failing mirror leg and mirror log.
Zdenek Kabelac [Sun, 13 Jul 2025 20:09:41 +0000 (22:09 +0200)]
test: update for upper case warning
As WARNING consistency patch slighly change some reported messages,
update some tests (and use 'grep -i').
Zdenek Kabelac [Mon, 14 Jul 2025 00:28:05 +0000 (02:28 +0200)]
test: use same device match for btrfs testing
Copy the btrfs device matching from lvresize helper script.
Zdenek Kabelac [Mon, 14 Jul 2025 00:26:19 +0000 (02:26 +0200)]
lvresize: use major:minor to compare btrfs device
What we really do want to compare is devnode the device
name is actually using - this is uniq match.
Zdenek Kabelac [Sun, 13 Jul 2025 15:13:52 +0000 (17:13 +0200)]
WHATS_NEW: update
Zdenek Kabelac [Fri, 11 Jul 2025 12:31:47 +0000 (14:31 +0200)]
make: generate
Zdenek Kabelac [Thu, 10 Jul 2025 13:00:03 +0000 (15:00 +0200)]
configure: update autotools
Heinz Mauelshagen [Fri, 4 Jul 2025 20:11:05 +0000 (22:11 +0200)]
test: refactor lvconvert-raid-reshape-size.sh
Improve the RAID reshape size test script with the following changes:
**Code Quality Improvements:**
- Add proper shell quoting throughout the script to prevent word splitting issues
- Replace manual arithmetic with cleaner shell arithmetic syntax
- Improve variable handling and remove unnecessary local variable assignments
- Fix typo: "hilesystem" -> "filesystem"
**Test Reliability Enhancements:**
- Add EXTENSIVE_FSCK environment variable for optional additional filesystem validation
- Reduce delay times from 40ms/25ms to 20ms for all RAID types to speed up testing
- Add helper functions _delay_dev() and _restore_dev() for cleaner device delay management
- Use --noudevsync flag in lvconvert to avoid udev-related timing issues
- Remove unnecessary sleep calls and udevadm settle commands
**Functionality Improvements:**
- Improve _check_size() function to return proper exit codes instead of echo statements
- Better error handling in conditional statements using proper test syntax
- Cleaner parameter passing using "$@" instead of manual argument handling
- More robust device path handling using $DM_DEV_DIR consistently
**Code Structure:**
- Extract device delay logic into reusable helper functions
- Improve readability with better variable naming and consistent formatting
- Add explanatory comments for complex operations
Heinz Mauelshagen [Fri, 4 Jul 2025 15:04:04 +0000 (17:04 +0200)]
test: lvconvert-raid-reshape-size.sh return from _check_size
Heinz Mauelshagen [Fri, 4 Jul 2025 11:09:50 +0000 (13:09 +0200)]
test: lvconvert-raid-reshape-size.sh only create PVs+VG once
Saves a few seconds in test run.
Add --noudevsync to save big time.
Heinz Mauelshagen [Thu, 3 Jul 2025 15:09:00 +0000 (17:09 +0200)]
test: lvconvert-raid-reshape-size.sh fix test bug 2nd
Up'ed millisecnd delays.
Undelayed earlier.
Only delaying rimage allocations, not lvm2 mda or rmeta ones.
This page took 0.109163 seconds and 5 git commands to generate.