lvm2.git
4 months agodebug: log_warn sentence begins with capital
Zdenek Kabelac [Fri, 11 Jul 2025 17:41:15 +0000 (19:41 +0200)]
debug: log_warn sentence begins with capital

Improve the consistency and readability of warning messages.
Capitalize the first word of all warning messages.
Add periods at the end of warning messages.

The changes are purely cosmetic and do not affect functionality.

4 months agoman: fix some typos and grammar issues
Zdenek Kabelac [Fri, 11 Jul 2025 09:21:42 +0000 (11:21 +0200)]
man: fix some typos and grammar issues

Drop misplaced letter 'I'.
Missing articles (a, an, the)
Incorrect prepositions (in/into, to/in)
Subject-verb agreement errors.
Awkward phrasing that needs smoothing.
Fixed prepositions ("prior to" instead of "prior the")
Corrected subject-verb agreement ("are becoming" instead of "is becoming")
Fixed word choices ("represents" instead of "presents")
Used consistent terminology ("environment" instead of "environmental")
Fixed pronoun references ("them" instead of "it" when referring to plural subjects)

Originated-by: warp-terminal
4 months agocleanup: a/an fixups
Andre Beaud [Sat, 5 Jul 2025 15:03:03 +0000 (01:03 +1000)]
cleanup: a/an fixups

Some a/an fixups along with a couple more odds and ends.
Hopefully this is useful like this as plain diff output
or let me know if something else will work better.

4 months agogcc: ensure pointer is properly initialized
Zdenek Kabelac [Wed, 9 Jul 2025 21:26:03 +0000 (23:26 +0200)]
gcc: ensure pointer is properly initialized

Fix gcc warning by ensuring pointers are properly defined and
initialized before use in man-generator code to prevent potential
undefined behavior.

4 months agocov: replace unsafe string sscanf
Zdenek Kabelac [Sun, 13 Jul 2025 18:23:06 +0000 (20:23 +0200)]
cov: replace unsafe string sscanf

Althouh here we were copying to the properly allocated space
let's just replace it with this copy code.

4 months agocov: reduce strcpy
Zdenek Kabelac [Sun, 13 Jul 2025 17:36:45 +0000 (19:36 +0200)]
cov: reduce strcpy

Copy fix we already have device_mapper through commit:
7bc5c8ac3d4c6004de24050fd51d3eaa4732822d

4 months agocov: remove unused header
Zdenek Kabelac [Thu, 10 Jul 2025 23:26:31 +0000 (01:26 +0200)]
cov: remove unused header

Remove unused header file.
Warp also identified duplicated header file inclusion.

4 months agocov: remove unused variables
Zdenek Kabelac [Thu, 10 Jul 2025 19:31:15 +0000 (21:31 +0200)]
cov: remove unused variables

Remove unused variables identified by coverity analysis to clean up
code and eliminate static analysis warnings.

4 months agocov: reduce printf format string parameters
Zdenek Kabelac [Thu, 10 Jul 2025 18:35:59 +0000 (20:35 +0200)]
cov: reduce printf format string parameters

Simplify printf format strings by removing unnecessary parameters
in libdm-report and toollib components to resolve coverity warnings
about format string mismatches.

4 months agocov: use proper enum value for bitmask operation
Zdenek Kabelac [Thu, 10 Jul 2025 15:38:27 +0000 (17:38 +0200)]
cov: use proper enum value for bitmask operation

Fix coverity warning by using the correct enum value instead of
a raw integer for bitmask operations in activation code.

4 months agocov: suppress false positive warnings
Zdenek Kabelac [Thu, 10 Jul 2025 13:21:58 +0000 (15:21 +0200)]
cov: suppress false positive warnings

Add coverity annotations to suppress false positive warnings for
unimportant results across multiple files including dmeventd,
lvmlockd, display, logging, dmsetup, and man-generator components.

4 months agoglibc: switch to standard endian conversion macros
Zdenek Kabelac [Thu, 10 Jul 2025 20:27:09 +0000 (22:27 +0200)]
glibc: switch to standard endian conversion macros

Replace all uses of Linux kernel-style endian conversion macros/functions
(e.g., le32_to_cpu, cpu_to_le32, xlate32, xlate64, etc.) with the standard
POSIX/glibc macros (e.g., le32toh, htole32, htobe32, be32toh, etc.) from
<endian.h>.

- Update all code to use le16toh, le32toh, le64toh, htole16, htole32, htole64,
  htobe16, htobe32, htobe64, be16toh, be32toh, be64toh as appropriate.
- Provide fallback macro definitions in xlate.h for systems lacking these
  standard macros, ensuring backward compatibility with older glibc and non-glibc
  systems.
- Remove or replace all project-specific xlateXX and cpu_to_leXX/cpu_to_beXX
  macros.
- No functional change intended; this is a mechanical, treewide modernization
  for clarity, portability, and future maintainability.

4 months agocov: add explicit enum casts to fix type warnings
Zdenek Kabelac [Thu, 10 Jul 2025 16:37:56 +0000 (18:37 +0200)]
cov: add explicit enum casts to fix type warnings

Add explicit casts to enum types in dmeventd and libdevmapper-event
to resolve coverity warnings about implicit type conversions.

4 months agolvresize: update code to get btrfs devid
Zdenek Kabelac [Sun, 13 Jul 2025 18:52:32 +0000 (20:52 +0200)]
lvresize: update code to get btrfs devid

Let's try different mechanism to obtain devid when
resizing btrfs filesystem spread across multiple volumes.

Using patch from https://github.com/lvmteam/lvm2/issues/180

Originated-by: Damenly Su <l@damenly.org>
4 months agolvconvert: error mirror LV non-changing request
Zdenek Kabelac [Sat, 12 Jul 2025 14:16:51 +0000 (16:16 +0200)]
lvconvert: error mirror LV non-changing request

To have the very same matching logic to raid1 commit:
c901528053e7f63538239431480f20db8b7d4ca6
we add similar check for mirror where we check if mirror leg and
log count is not changing which will now return also an error.

4 months agotools: simplify LVM_DID_EXEC environment variable
Zdenek Kabelac [Thu, 10 Jul 2025 19:40:14 +0000 (21:40 +0200)]
tools: simplify LVM_DID_EXEC environment variable

Set LVM_DID_EXEC to "1" instead of using the command name string,
avoiding potential issues with unusual command names and improving
consistency in environment variable handling.

4 months agotools: add arg_force_value() for enum handling
Zdenek Kabelac [Thu, 10 Jul 2025 17:09:22 +0000 (19:09 +0200)]
tools: add arg_force_value() for enum handling

Add arg_force_value() function that returns the correct force_t enum
type, replacing direct string comparisons. Update lvconvert and
pvremove to use this new function for better type safety.

This is cleaner solution over just plain cast to force_t as we can
validate force level in use.

4 months agocommand: replace manual binary search with bsearch
Zdenek Kabelac [Thu, 10 Jul 2025 10:39:13 +0000 (12:39 +0200)]
command: replace manual binary search with bsearch

Replace custom binary search implementation with the standard library's
bsearch() function for better maintainability.
Also convert command_name from pointer to char array and simplify name
ordering validation logic.

4 months agocommand: fix alignment in help output formatting
Zdenek Kabelac [Thu, 10 Jul 2025 10:05:45 +0000 (12:05 +0200)]
command: fix alignment in help output formatting

Fix inconsistent spacing in command help output by introducing
_print_opt_with_align() function that properly handles alignment
for options with and without short forms. This resolves the extra
spaces that were being printed in --longhelp output.

Fixes regression introduced in commit:
491c6652ae39b4a22f79dc47dbebd40495ed03c2.

4 months agocommand-lines: fix typo in configurable name
Zdenek Kabelac [Fri, 11 Jul 2025 12:29:41 +0000 (14:29 +0200)]
command-lines: fix typo in configurable name

Fix type in lvm.conf option name used for lvcreate
and replace global/mirror_segfault_default with correct
name global/mirror_segtype_default.

4 months agosanlock: fix file descriptor leak in error path
Zdenek Kabelac [Thu, 10 Jul 2025 13:13:18 +0000 (15:13 +0200)]
sanlock: fix file descriptor leak in error path

Add proper cleanup of file descriptor in the error handling path
to prevent resource leaks when sanlock operations fail.

4 months agosanlock: fix struct copy to avoid aliasing issues
Zdenek Kabelac [Thu, 10 Jul 2025 13:11:30 +0000 (15:11 +0200)]
sanlock: fix struct copy to avoid aliasing issues

Replace direct structure assignment with explicit copying to prevent
potential undefined behavior from structure aliasing. This ensures
proper memory handling when working with sanlock structures.

This possibly fixes regression introduced with commit: e9640e5178769
as unintended side effect.

4 months agoudev: fix autoactivation on top of loop dev PVs 1915928259
Peter Rajnoha [Wed, 9 Jul 2025 10:48:48 +0000 (12:48 +0200)]
udev: fix autoactivation on top of loop dev PVs

We already check loop devices for LVM_LOOP_PV_ACTIVATED="1" in udev
rules to see if have executed pvscan before. If that is the case, we
don't want to execute it again to avoid VG reactivation.

However, the rules missed the IMPORT{db}="LVM_LOOP_PV_ACTIVATED" rule
to actually get the value already stored in udev db from previous event.
As a result, the pvscan executed on each CHANGE udev event, hence the
VG autoactivation triggered each time as well.

Fix this by adding the missing IMPORT{db}="LVM_LOOP_PV_ACTIVATED" rule
(just like we already do for MD devices).

Note: Keep the behavior for ADD events. That is, we still want the
autoactivation to trigger each time, otherwise coldplug will not work
(again, we have the same principle used for MD devices).

5 months agotest: adjust lvconvert-mirror-basic.sh to now erroring non-changing image mirror... 1902307019
Heinz Mauelshagen [Wed, 2 Jul 2025 12:04:40 +0000 (14:04 +0200)]
test: adjust lvconvert-mirror-basic.sh to now erroring non-changing image mirror request

See commit c901528053e7f63538239431480f20db8b7d4ca

5 months agosanlock: add function only for newer SANLOCK 1901931238
Zdenek Kabelac [Wed, 2 Jul 2025 09:48:53 +0000 (11:48 +0200)]
sanlock: add function only for newer SANLOCK

Avoid adding unused static function with older SANLOCK.

5 months agosanlock: match lm_lock_sanlock prototype
Zdenek Kabelac [Wed, 2 Jul 2025 09:46:20 +0000 (11:46 +0200)]
sanlock: match lm_lock_sanlock prototype

5 months agolvmlockd-sanlock: remove info file when vg is removed 1900884930
David Teigland [Tue, 1 Jul 2025 18:36:23 +0000 (13:36 -0500)]
lvmlockd-sanlock: remove info file when vg is removed

5 months agolvmlockd-sanlock: check lock_lv_offset_from_args result 1900712746
David Teigland [Tue, 1 Jul 2025 16:23:16 +0000 (11:23 -0500)]
lvmlockd-sanlock: check lock_lv_offset_from_args result

5 months agolvmlockd: check adopt file fflush and fclose 1900704942
David Teigland [Tue, 1 Jul 2025 16:17:06 +0000 (11:17 -0500)]
lvmlockd: check adopt file fflush and fclose

5 months agolvmlockd: check sscanf results when reading file values 1900697067
David Teigland [Tue, 1 Jul 2025 16:11:59 +0000 (11:11 -0500)]
lvmlockd: check sscanf results when reading file values

5 months agolvmlockd: free structs in adopt error path 1900659247
David Teigland [Tue, 1 Jul 2025 15:53:33 +0000 (10:53 -0500)]
lvmlockd: free structs in adopt error path

5 months agolvmlockd-sanlock: fix size in dm_snprintf 1900604529
David Teigland [Tue, 1 Jul 2025 15:27:55 +0000 (10:27 -0500)]
lvmlockd-sanlock: fix size in dm_snprintf

5 months agolvmlockd-sanlock: fix uninitialized time value
David Teigland [Tue, 1 Jul 2025 15:25:48 +0000 (10:25 -0500)]
lvmlockd-sanlock: fix uninitialized time value

5 months agolvmlockd-sanlock: fix struct pointer in release_rename
David Teigland [Tue, 1 Jul 2025 15:22:50 +0000 (10:22 -0500)]
lvmlockd-sanlock: fix struct pointer in release_rename

5 months agoconfigure: update 1900591918
Zdenek Kabelac [Tue, 1 Jul 2025 10:34:19 +0000 (12:34 +0200)]
configure: update

5 months agoWHATS_NEW: update 31/head 1900425768
Heinz Mauelshagen [Tue, 1 Jul 2025 14:33:18 +0000 (16:33 +0200)]
WHATS_NEW: update

5 months agotest: adjust lvconvert-raid.sh to now erroring non-changing image raid1 request 1900410974
Heinz Mauelshagen [Tue, 1 Jul 2025 14:29:02 +0000 (16:29 +0200)]
test: adjust lvconvert-raid.sh to now erroring non-changing image raid1 request

See commit c901528053e7f63538239431480f20db8b7d4ca.

5 months agolvconvert: error raid1 LV non-changing image count request 1900303270
Heinz Mauelshagen [Tue, 1 Jul 2025 13:51:42 +0000 (15:51 +0200)]
lvconvert: error raid1 LV non-changing image count request

In case a Raid1LV has e.g. 3 images already, running "lvconvert --mirrors 2 $Raid1LV"
results in success even though the image count didn't change.
Make it fail in such case.

Related issue: https://issues.redhat.com/browse/RHEL-82138

5 months agolvmlockd: add repair option to reinitialize sanlock leases 1898499112
David Teigland [Mon, 30 Jun 2025 17:59:49 +0000 (12:59 -0500)]
lvmlockd: add repair option to reinitialize sanlock leases

If sanlock leases become corrupted, adding --lockopt repair
to the command will let lvmlockd reinitialize them.

5 months agoWHATS_NEW: update 1898194616
Zdenek Kabelac [Mon, 30 Jun 2025 14:55:54 +0000 (16:55 +0200)]
WHATS_NEW: update

5 months agogcc: fix signness warnings with explicit casts
Zdenek Kabelac [Sun, 29 Jun 2025 14:52:51 +0000 (16:52 +0200)]
gcc: fix signness warnings with explicit casts

Add explicit type casts to resolve GCC signness comparison warnings:
- Cast dest_size to int in lvmlockctl.c
- Cast NVME_IDENTIFY_DATA_SIZE to int in nvme.c
- Cast bitwise AND results to int in nvme.c and persist.c
- Cast DM_STATS_GROUP_NOT_PRESENT to int in libdm-stats.c

5 months agogcc: clean cast from size_t to void ptr
Zdenek Kabelac [Sun, 29 Jun 2025 15:00:43 +0000 (17:00 +0200)]
gcc: clean cast from size_t to void ptr

5 months agogcc: for C90 don't mix declaration and code
Zdenek Kabelac [Sun, 29 Jun 2025 14:45:49 +0000 (16:45 +0200)]
gcc: for C90 don't mix declaration and code

This commit fixes C90 compatibility issues by ensuring variable declarations
are placed at the beginning of code blocks before any executable statements.

5 months agocov: ensure nsid is defined
Zdenek Kabelac [Fri, 27 Jun 2025 10:18:30 +0000 (12:18 +0200)]
cov: ensure nsid is defined

5 months agocov: check for potential empty row list
Zdenek Kabelac [Mon, 30 Jun 2025 12:14:01 +0000 (14:14 +0200)]
cov: check for potential empty row list

Skip potential 0 length allocation and return early for empty list.

5 months agocov: check for potential empty registry list
Zdenek Kabelac [Mon, 30 Jun 2025 12:11:16 +0000 (14:11 +0200)]
cov: check for potential empty registry list

Check early for empty thread_registry list and return EINVAL
instead of doing zero length allocation.

5 months agocov: fix warn for variable-sized dm_ulog_request structure
Zdenek Kabelac [Mon, 30 Jun 2025 11:53:08 +0000 (13:53 +0200)]
cov: fix warn for variable-sized dm_ulog_request structure

Change kernel_send() function signature from accepting struct dm_ulog_request*
to void* to properly handle variable-sized data access.

The dm_ulog_request structure contains a flexible array member (data[0])
that allows variable-sized payloads to be appended. When accessing data
beyond the base structure size, Coverity correctly flags this as a
potential buffer overrun since the structure size doesn't account for
the variable data.

By using void* as the parameter type, we make it explicit that we're
working with a memory region that may extend beyond the base structure,
eliminating the false positive while maintaining type safety through
proper casting within the function.

5 months agocov: explicitly zero allocated mem for array
Zdenek Kabelac [Mon, 30 Jun 2025 12:32:10 +0000 (14:32 +0200)]
cov: explicitly zero allocated mem for array

Replace malloc() with calloc() when allocating the string pointer array
for regex pattern matching in _create_field_selection(). This ensures
all array elements are initialized to NULL pointers, preventing potential
use of uninitialized memory objected by Coverity.

Existing code sets all elements in the follow up loop.

5 months agocov: add explicit check for 0 size
Zdenek Kabelac [Mon, 30 Jun 2025 11:55:11 +0000 (13:55 +0200)]
cov: add explicit check for 0 size

5 months agocov: explicitly ignore return of _lv_types_match()
Zdenek Kabelac [Mon, 30 Jun 2025 12:32:25 +0000 (14:32 +0200)]
cov: explicitly ignore return of _lv_types_match()

Add explicit (void) cast to ignore the return value of _lv_types_match()
in _check_lv_rules() function. This addresses Coverity warning about
unused return values and maintains consistency with other similar
function calls in the codebase that properly handle return values.

5 months agocov: add annotations to suppress fp warnings
Zdenek Kabelac [Sun, 29 Jun 2025 18:43:31 +0000 (20:43 +0200)]
cov: add annotations to suppress fp warnings

Add Coverity annotations to suppress false positive warnings in several
files where the static analysis tool incorrectly flags potential issues
that are actually safe due to proper validation or intentional behavior.

The annotations address the following false positives:

- daemons/dmeventd/dmeventd.c: overflow_sink warnings for 'current' variable
  that is validated to be positive before use in buffer operations

- daemons/lvmlockd/lvmlockd-core.c: overflow_sink warning for 'ret' variable
  that is validated to be positive before use

- lib/config/config.c: overflow_sink warning for 'sz' variable that is
  validated to be positive before use in read operations

- libdm/dm-tools/dmsetup.c: overflow_sink, overflow, and deref_overflow
  warnings for 'n' variable that is validated to be positive before use
  in buffer operations and string termination

- libdm/libdm-stats.c: overflow_sink warning for 'i & j' variables that are
  validated to be positive before use in array indexing

5 months agocov: add checked variants for mda_is_ignored and rlocn_is_ignored
Zdenek Kabelac [Mon, 30 Jun 2025 13:31:10 +0000 (15:31 +0200)]
cov: add checked variants for mda_is_ignored and rlocn_is_ignored

Introduce _mda_is_ignored() and _rlocn_is_ignored() wrapper functions
with warn_unused_result attribute to enforce return value checking.

This follows the established pattern used by dm_strncpy() and _dm_strncpy():
- Functions without underscore prefix can be used without checking return values
- Functions with underscore prefix must have their return values checked

The change improves static analysis coverage by ensuring that critical
metadata area and raw location ignored state checks are properly validated,
reducing the risk of unhandled error conditions in metadata processing.

5 months agocov: fix va_end resource leak in szscanf()
Zdenek Kabelac [Sat, 28 Jun 2025 20:42:17 +0000 (22:42 +0200)]
cov: fix va_end resource leak in szscanf()

- Fix potential resource leak by ensuring va_end() is called on error path
- Set matched = -1 and break from while loop instead of immediate return
- This ensures proper cleanup of va_list when unsupported format
  specifiers are encountered in lvmlockctl.

The szscanf function is a custom string scanner used for parsing lvmlockd
status information. Previously, encountering an unsupported format
specifier would cause an immediate return without calling va_end(),
leading to undefined behavior and potential resource leaks.

This fix ensures proper cleanup of variable argument lists in all code paths.

5 months agocov: replace unsafe strcpy
Zdenek Kabelac [Sun, 29 Jun 2025 13:16:48 +0000 (15:16 +0200)]
cov: replace unsafe strcpy

Replace potentially unsafe strcpy() with bounds-checked memcpy()
and proper null termination in the _sysfs_get_dm_name() function.
This prevents buffer overflow vulnerabilities when copying device
mapper names from sysfs.

Also replace another strcpy() with _dm_strncpy() which also checks
whether copied string with into a given buffer in the function
_sysfs_get_kernel_name().

Changes:

- Replace strcpy(buf, temp_buf) with memcpy(buf, temp_buf, len) + buf[len] = '\0'
- Use stack-allocated buffers instead of malloc/dm_malloc for better performance
- Improve error handling logic for ENOENT vs other errors
- Add proper newline stripping with bounds checking
- Remove memory allocation failure paths and cleanup code

This addresses potential security issues identified by static analysis
tools while also improving performance by avoiding dynamic memory allocation.

5 months agocov: reduce strcpy usage
Zdenek Kabelac [Fri, 27 Jun 2025 20:17:12 +0000 (22:17 +0200)]
cov: reduce strcpy usage

Coverity does not like strcpy() calls...

5 months agocov: improve page size validation and calculation
Zdenek Kabelac [Sat, 28 Jun 2025 20:50:29 +0000 (22:50 +0200)]
cov: improve page size validation and calculation

- Add bounds checking for sysconf(_SC_PAGESIZE) return value
- Validate page size is positive and reasonable (< 16MB)
- Use size_t for page_size variable to match usage context
- Simplify page calculation with ceiling division
- Fix potential integer overflow in page count calculation

This improves robustness when handling edge cases in clustered
mirror log disk operations.

5 months agocov: prevent unsigned underflow
Zdenek Kabelac [Sat, 28 Jun 2025 07:58:46 +0000 (09:58 +0200)]
cov: prevent unsigned underflow

Use signed int instead of size_t for loop counter to prevent reporting
unsigned underflow when decrementing from 0 in Coverity.
Loops itself worked just fine.

5 months agocov: prefer snprintf
Zdenek Kabelac [Fri, 27 Jun 2025 20:17:52 +0000 (22:17 +0200)]
cov: prefer snprintf

5 months agocov: ensure read got some bytes
Zdenek Kabelac [Fri, 27 Jun 2025 11:08:27 +0000 (13:08 +0200)]
cov: ensure read got some bytes

5 months agocov: check error return from mktime
Zdenek Kabelac [Sat, 28 Jun 2025 07:53:49 +0000 (09:53 +0200)]
cov: check error return from mktime

Handle mktime() error path value -1 and for such invalid time_t value
return 0 tz offset.

5 months agocov: simplify obtaining value
Zdenek Kabelac [Fri, 27 Jun 2025 12:00:08 +0000 (14:00 +0200)]
cov: simplify obtaining value

Function arg_str_value() calls arg_is_seg() to check whether arg is set.
At the same time Coverity can see check for non NULL of 'op'.

5 months agocov: fix integer underflow in _count handling
Zdenek Kabelac [Fri, 27 Jun 2025 11:46:01 +0000 (13:46 +0200)]
cov: fix integer underflow in _count handling

The _count variable was declared as uint64_t but used in arithmetic operations
that could result in underflow when subtracting from smaller values. This
could cause issues when calculating interval numbers or handling count-based
reporting.

Changes:
- Change _count variable type from uint64_t to int64_t
- Update _interval_num() to use proper casting for arithmetic
- Change UINT64_MAX to INT64_MAX for default count value
- Remove unnecessary casting in count assignment

This prevents potential underflow issues when _count is decremented or used
in subtraction operations, ensuring proper behavior for interval-based
reporting and count tracking in dmsetup commands.

The fix maintains compatibility while providing safer integer arithmetic
for the reporting loop logic.

5 months agocov: fix double-close bug in _btrfs_get_mnt function
Zdenek Kabelac [Fri, 27 Jun 2025 10:22:24 +0000 (12:22 +0200)]
cov: fix double-close bug in _btrfs_get_mnt function

Ensure file descriptor is closed only once by moving close() call
to immediately after read() and setting fd = -1 to prevent reuse.

5 months agocov: prevent potential negative array index
Zdenek Kabelac [Sun, 29 Jun 2025 18:47:13 +0000 (20:47 +0200)]
cov: prevent potential negative array index

The _stats_map_extents() function processes file extents returned
by FIEMAP ioctl calls. When handling the case where a file has
only a single extent, the code accesses fm_ext[i - 1] to check
if the logical offset is 0.

However, when i is 0 (no extents processed yet), this results in a negative
array index access which can cause undefined behavior or crashes.

So check early whether there are fm_mapped_extents to process.
This avoids using negative index array.

Existing code already checks fm_mapped_extents == 0 before calling
this function so the patch is not fixing any real bug.

5 months agodebug: add missing error path traces
Zdenek Kabelac [Fri, 27 Jun 2025 09:27:05 +0000 (11:27 +0200)]
debug: add missing error path traces

Trace failures of close() and unlink() syscalls.

5 months agolvmlockd: optimize lock_type access in lockd_start_vg
Zdenek Kabelac [Fri, 27 Jun 2025 09:44:19 +0000 (11:44 +0200)]
lvmlockd: optimize lock_type access in lockd_start_vg

Store vg->lock_type in a local variable to avoid repeated null checks
and string comparisons throughout the function. This improves code
readability and eliminates redundant conditional evaluations.

5 months agolvconvert: refactor counting of failed mirrors
Zdenek Kabelac [Sun, 29 Jun 2025 15:55:45 +0000 (17:55 +0200)]
lvconvert: refactor counting of failed mirrors

Change return value semantics:
- Previously returned -1 for non-mirrored segments (error condition)
- Now returns 0 for non-mirrored segments (no failed mirrors) and
  reports INTERNAL_ERROR for such case.
- This makes the function more consistent as it counts failures, not errors

Simplify recursive calls:
- Remove unnecessary intermediate variable 'r' in both functions
- Directly add recursive call results to return value
- Eliminates redundant error checking for recursive calls

Code cleanup:
- Remove unused variable declarations
- Improve code readability and reduce compiler warnings

The refactoring makes the functions more robust and easier to understand
while preserving their core behavior of counting failed mirror images
and logs across logical volume segments.

5 months agolibdm-stats: fix type mismatch in bit operations
Zdenek Kabelac [Fri, 27 Jun 2025 09:38:24 +0000 (11:38 +0200)]
libdm-stats: fix type mismatch in bit operations

The stats implementation was using uint64_t for group_id and loop variables
while calling dm_bit_* functions that return int types. This created a
potential issue where large values could be incorrectly handled due to
implicit casting between signed and unsigned types.

Changes:
- Change loop variables from uint64_t to int in _stats_group_tag_len()
- Change loop variable from uint64_t to int in _stats_clear_group_regions()
- Change loop variables from uint64_t to int in dm_stats_get_counter()
- Change loop variable from uint64_t to int in dm_stats_get_region_len()
- Fix _stats_create_group() to properly handle dm_bit_get_first() return value

This ensures consistent type usage and prevents potential issues with
values exceeding INT_MAX (2^31 - 1). Also this limitats group_id to 31 bits
as a constraint that may need addressing in the future.

FIXME: Maybe consider implementing 64-bit variants of dm_bit functions or
documenting this limitation more prominently is this ever become an
issue...

5 months agolvmlockd: allow 1 more extra character
Zdenek Kabelac [Fri, 27 Jun 2025 09:15:05 +0000 (11:15 +0200)]
lvmlockd: allow 1 more extra character

Function dm_strncpy() ensures the last character is \0,
so pass whole array size for buffer size.

This give 1 extra character for use to store owner state and name.

5 months agotests: check lvcreate thin with setautoactivation
Zdenek Kabelac [Mon, 30 Jun 2025 14:55:02 +0000 (16:55 +0200)]
tests: check lvcreate thin with setautoactivation

5 months agolvcreate: accept --setautoactivation flag for all volumes
Friedrich Weber [Fri, 27 Jun 2025 15:23:40 +0000 (17:23 +0200)]
lvcreate: accept --setautoactivation flag for all volumes

lvcreate accepts --setautoactivation for thick logical volumes, but
not for e.g. thin volumes (see linked bug report). Currently, in such
cases, a subsequent lvchange invocation is necessary to change the
autoactivation flag.

To fix this, make lvcreate accept the flag for all volumes by adding
it to LVCREATE_ARGS.

Fixes: https://gitlab.com/lvmteam/lvm2/-/issues/32
Fixes: 0a28e3c44 ("Add metadata-based autoactivation property for VG and LV")
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
5 months agoaux: missed _executable in config name 1893428517
Zdenek Kabelac [Thu, 26 Jun 2025 20:56:59 +0000 (22:56 +0200)]
aux: missed _executable in config name

5 months agoWHATS_NEW: update
Zdenek Kabelac [Thu, 26 Jun 2025 19:41:50 +0000 (21:41 +0200)]
WHATS_NEW: update

5 months agomake: generate
Zdenek Kabelac [Thu, 26 Jun 2025 19:10:34 +0000 (21:10 +0200)]
make: generate

5 months agogcc: keep code compilable with std=c99
Zdenek Kabelac [Thu, 26 Jun 2025 19:48:42 +0000 (21:48 +0200)]
gcc: keep code compilable with std=c99

5 months agogcc: ensure proper value initialization
Zdenek Kabelac [Thu, 26 Jun 2025 20:09:47 +0000 (22:09 +0200)]
gcc: ensure proper value initialization

5 months agoman: install lvmpersist page
Zdenek Kabelac [Thu, 26 Jun 2025 20:02:48 +0000 (22:02 +0200)]
man: install lvmpersist page

5 months agotests: configure lvresize_fs_helper_executable_CFG
Zdenek Kabelac [Thu, 26 Jun 2025 19:25:00 +0000 (21:25 +0200)]
tests: configure lvresize_fs_helper_executable_CFG

Update test infrastructure to use the lvresize_fs_helper script
from the LVM2 codebase instead of relying on the system-installed
version. This ensures consistent testing behavior and avoids
issues when the system version doesn't exist or differs from
the expected implementation.

- Add lvresize_fs_helper to LVM_SCRIPTS in test/Makefile.in
  for installation
- Configure global/lvresize_fs_helper in test/lib/aux.sh
  to point to the test version

5 months agoconfig: add lvresize_fs_helper_executable option
Zdenek Kabelac [Thu, 26 Jun 2025 18:56:28 +0000 (20:56 +0200)]
config: add lvresize_fs_helper_executable option

- Add global_lvresize_fs_helper_executable_CFG config option to allow
  specifying the path to the lvresize_fs_helper script.
- Add DEFAULT_LVRESIZE_FS_HELPER_PATH macro for default value.
- Update _get_lvresize_fs_helper_path() in lib/device/filesystem.c
  to read the path from configuration using find_config_tree_str,
  similar to _fsadm_cmd().
- This allows users to override the helper path via configuration,
  improving flexibility and consistency with fsadm_executable handling.
- Avoid using static variable to get helper path just once, since
  it may change between commands via lvm.conf in lvm2 shell.

5 months agolvmlockd: fix missing free in vg_status
David Teigland [Thu, 26 Jun 2025 18:42:38 +0000 (13:42 -0500)]
lvmlockd: fix missing free in vg_status

and add more checking of get_hosts result.

used by lockd_vg_is_started() for the PR feature.

5 months agonvme: match header prototype for dev_find_key_nvme
Zdenek Kabelac [Thu, 26 Jun 2025 16:11:22 +0000 (18:11 +0200)]
nvme: match header prototype for dev_find_key_nvme

Missed to synchronize with previous commit.

5 months agodevice_id: Fix compiling when versionsort not found
Biswapriyo Nath [Fri, 28 Feb 2025 13:55:39 +0000 (13:55 +0000)]
device_id: Fix compiling when versionsort not found

alphasort was replaced with versionsort in 09e508cd438c755d293e4085ec584d87e7e7ea2e commit.

This commit fixes the following compiler error.

device/device_id.c:1608:65: error: use of undeclared identifier 'versionsort'
1608 |         sort_count = scandir(dirpath, &namelist, _filter_backup_files, versionsort);
     |                                                                        ^

5 months agoconfigure: autoreconf
Zdenek Kabelac [Thu, 26 Jun 2025 15:59:40 +0000 (17:59 +0200)]
configure: autoreconf

5 months agoconfigure: Use portable string comparison
A. Wilcox [Mon, 2 Jun 2025 04:08:08 +0000 (04:08 +0000)]
configure: Use portable string comparison

= and == are equivalent in Bash for strings, but = is the only portable
operator for compatibility with other shells.  Before this change,
running ./configure with Dash as /bin/sh resulted in:

./configure: 14558: test: yes: unexpected operator

and the test did not work (i.e. --enable-cmdlib --disable-shared allowed
a failed build to continue).  Now, the test works in Bash and Dash.

5 months agopersistent reservations
David Teigland [Thu, 14 Nov 2024 22:20:54 +0000 (16:20 -0600)]
persistent reservations

Enable lvm to use persistent reservations on a VG, which
are applied to each PV in the VG.

. lvmpersist is a low level script, which uses commands
  sg_persist, mpathpersist, and nvme to do PR operations
  on devices. This script is used by higher level lvm
  commands, and would not often be run by users.

. vgchange --setpersist is a VG metadata configuration command
  that specifies how PR should be started and enforced for a VG
  relative to other lvm commands.

. vgchange --persist is a command to change PR state of PVs in
  the VG, e.g. start PR to register and reserve.

The lvmpersist man page contains a complete description.

5 months agodevices: add dev_is_scsi and dev_is_mpath
David Teigland [Fri, 16 May 2025 18:50:51 +0000 (13:50 -0500)]
devices: add dev_is_scsi and dev_is_mpath

5 months agopost-release
Marian Csontos [Fri, 27 Jun 2025 08:14:33 +0000 (10:14 +0200)]
post-release

5 months agopre-release 2.03.33 1893428868 v2_03_33
Marian Csontos [Fri, 27 Jun 2025 08:14:33 +0000 (10:14 +0200)]
pre-release 2.03.33

5 months agoWHATS_NEW: update 1890649736
Peter Rajnoha [Thu, 26 Jun 2025 08:50:20 +0000 (10:50 +0200)]
WHATS_NEW: update

5 months agolibdm: Escape all literal control characters in report strings 30/head 1890642143
Adrian Astley [Wed, 25 Jun 2025 16:04:56 +0000 (12:04 -0400)]
libdm: Escape all literal control characters in report strings

LVM objects (like pv_device_id) can sometimes contain literal control characters. The JSON spec disallows control characters. So we need to escape them for output.

Closes https://gitlab.com/lvmteam/lvm2/-/issues/35

5 months agoWHATS_NEW: update 1889790107
Zdenek Kabelac [Wed, 25 Jun 2025 20:46:06 +0000 (22:46 +0200)]
WHATS_NEW: update

5 months agocodespell: fix various typos across codebase
Zdenek Kabelac [Wed, 25 Jun 2025 19:07:28 +0000 (21:07 +0200)]
codespell: fix various typos across codebase

- lib/device/filesystem.c: 'avaiable' -> 'available' in btrfs comment
- lib/format_text/export.c: 'sting' -> 'string' in comment
- lib/log/log.c: 'expectes' -> 'expects' in coverity comment
- lib/metadata/metadata.c: 'damanging' -> 'damaging' in comment
- lib/metadata/metadata.h: 'Aditional' -> 'Additional' in comment
- test/shell/000-basic.sh: 'supression' -> 'suppression' in comment
- test/shell/pvcreate-partition.sh: 'lable' -> 'label' in comment
- test/shell/topology-support.sh: 'standart' -> 'standard' in comment
- WHATS_NEW:
  * 'propperly' -> 'properly'
  * 'cachable' -> 'cacheable'

5 months agotests: switch to new skip options for test scripts
Zdenek Kabelac [Sat, 21 Jun 2025 21:39:03 +0000 (23:39 +0200)]
tests: switch to new skip options for test scripts

Update test scripts to use new command-line options for skipping tests,
replacing the previous use of environment variables. The following options
are now supported:

  --skip-root-dm-check
  --skip-with-devices-file
  --skip-with-lvmpolld
  --skip-with-lvmlockd

- Add command-line option parsing to lib/inittest.sh.
- Replace SKIP_ROOT_DM_CHECK=1 with --skip-root-dm-check.
- Replace SKIP_WITH_DEVICES_FILE=1 with --skip-with-devices-file.
- Replace SKIP_WITH_LVMPOLLD=1 with --skip-with-lvmpolld.
- Replace SKIP_WITH_LVMLOCKD=1 with --skip-with-lvmlockd.
- Update 410 test files to use the new syntax.

This change provides a cleaner, more consistent, and maintainable
way to handle test skipping across the test suite.
Also eliminates number of shellcheck errors.

TODO: convert couple more remaining.

5 months agobuild: fix include paths for out-of-source builds
Zdenek Kabelac [Wed, 25 Jun 2025 19:46:01 +0000 (21:46 +0200)]
build: fix include paths for out-of-source builds

Fix include paths in cmd_enum.h and command.c by removing the "include/"
prefix from #include directives. This resolves build failures when
building from a directory different from the source directory.

The include paths were incorrectly referencing "include/cmds.h" instead
of "cmds.h", causing compilation errors in out-of-source builds.

5 months agoman: fix ellipsis formatting
Zdenek Kabelac [Wed, 25 Jun 2025 17:52:54 +0000 (19:52 +0200)]
man: fix ellipsis formatting

(use \&... instead of ... for proper troff rendering)
in lvmlockd, lvmreport, lvmvdo man pages

5 months agoman: remove quotes from section headers
Zdenek Kabelac [Wed, 25 Jun 2025 17:46:53 +0000 (19:46 +0200)]
man: remove quotes from section headers

Remove unnecessary quotes from section headers in man pages:
- lvm_import_vdo.8_main: .SH "NAME" -> .SH NAME
- fsadm.8_main: .SH "NAME" -> .SH NAME

This improves consistency and follows man page conventions.

Originated-by: Cursor AI
5 months agoman: fix company name formatting (missing comma)
Zdenek Kabelac [Wed, 25 Jun 2025 17:38:26 +0000 (19:38 +0200)]
man: fix company name formatting (missing comma)

Fix company name format in .TH headers by adding missing comma:
- dmeventd.8_main: 'Red Hat Inc' -> 'Red Hat, Inc.'
- cmirrord.8_main: 'Red Hat Inc' -> 'Red Hat, Inc.'
- lvmpolld.8_main: 'Red Hat Inc' -> 'Red Hat, Inc.'
- lvmdbusd.8_main: 'Red Hat Inc' -> 'Red Hat, Inc.'
- lvm_import_vdo.8_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmlockctl.8_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmcache.7_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmvdo.7_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- blkdeactivate.8_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmthin.7_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmreport.7_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmsadc.8_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmautoactivation.7_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmlockd.8_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- fsadm.8_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmraid.7_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmsystemid.7_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'
- lvmsar.8_main: 'Red Hat, Inc' -> 'Red Hat, Inc.'

This ensures consistent company name formatting across all man pages.

Originated-by: Cursor AI
5 months agoman: fix English grammar and style issues
Zdenek Kabelac [Sat, 21 Jun 2025 19:22:21 +0000 (21:22 +0200)]
man: fix English grammar and style issues

- cmirrord.8_main: Remove unnecessary article 'the' before 'corosync'
- dmsetup.8_main: Fix multiple grammar and punctuation issues
  * Add missing 'to' in 'Set this to zero to continue'
  * Fix 'eg,' -> 'e.g.,' and add missing comma
  * Add missing 'the' in 'for the live device'
  * Fix 'customised by following options' -> 'customised by the following options'
  * Fix 'comma-separate' -> 'comma-separated'
- fsadm.8_main: Improve sentence structure for dm-crypt description
- lvm.8_main: Fix capitalization 'volume Groups' -> 'Volume Groups'
- lvm_import_vdo.8_main: Fix header title and multiple grammar issues
  * Fix header title 'FSADM' -> 'LVM_IMPORT_VDO'
  * Fix 'LV a backend device' -> 'LV as a backend device'
  * Fix 'the of volume group' -> 'the name of the volume group'
  * Remove extra 'with' in 'with within volume group'
- lvmsystemid.7_main: Fix punctuation 'e.g.' -> 'e.g.,' and 'i.e.' -> 'i.e.,'

These changes improve grammatical correctness, consistency, and readability.

Originated-by: Cursor AI
5 months agoman: fix grammar and spelling issues
Zdenek Kabelac [Sat, 21 Jun 2025 19:43:19 +0000 (21:43 +0200)]
man: fix grammar and spelling issues

- dmeventd.8_main: Fix verb form 'present' -> 'presents' and spelling
  'free recover' -> 'recover free'
- dmfilemapd.8_main: Fix missing preposition
  'mode the daemon' -> 'mode of the daemon'
- dmstats.8_main: Fix American spelling 'Capitalise' -> 'Capitalize'
- lvmcache.7_main: Fix missing article
  'writecache block size' -> 'a writecache block size'

These changes improve grammatical correctness and consistency.

Originated-by: Cursor AI
5 months agotools: fix English grammar and spelling issues in args.h
Zdenek Kabelac [Sat, 21 Jun 2025 19:31:25 +0000 (21:31 +0200)]
tools: fix English grammar and spelling issues in args.h

- Fix typo: writethough -> writethrough in cachemode description
- Fix grammar: 'enabled or disable' -> 'enabled or disabled' for VDO options
- Fix typo: 'user date' -> 'user data' in RAID nosync description
- Fix grammar: 'a an LV' -> 'an LV' in poolmetadata description

These changes improve documentation clarity and correctness.

Originated-by: Cursor AI
This page took 0.108916 seconds and 5 git commands to generate.