IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
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
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
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
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.
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.
- 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.
alphasort was replaced with versionsort in 09e508cd43 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);
| ^
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.
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.
Override LC_NUMERIC part of the locale to "C" if we detect that the
radix character interferes with JSON_STD format. If that's the case,
override LC_NUMERIC locale to "C" in report_format_init, that is,
before any reporting is executed (including log reporting). Restore
it back in report_format_destroy, that is, once we're sure that all
reporting is finished.
Related: https://gitlab.com/lvmteam/lvm2/-/issues/33
This commit adds lvresize/lvextend/lvreduce support for btrfs.
'btrfs filesystem resize [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max <path>'
is used to resize one device only when it's mounted.
The code pattern is like xfs but it supports shrink.
For multi-devices btrfs, There is one difficulty to be handled:
If `lvreduce --fs resize` is given, lvm2 will check newsize vs current fs size
to judge if it's need to shrink fs or not.
For one device btrfs, fslastblock * fsblocksize/FSSIZE is the correct value like
ext* and xfs. But for multi-devices btrfs, the two values are whole fs size.
There is no other way without relying btrfs superblock parse. It's too
complicated and inproper to implemnt the logic in lvm2.
So here just sets fs_last_byte to 0 for btrfs and skips boundary check in
_fs_reduce_allow(). It's safe as btrfs will handle it well.
The another complicated part is how to get mount point info if multi-devices.
There is only one mnt entry per mounted fs in /etc/mtab even it's a
multi-devices btrfs. So we first get uuid from lv device then traverse devices
under /sys/fs/btrfs/$uuid/devices and compare them to the mnt entry to get the
mount point.
Signed-off-by: Su Yue <glass.su@suse.com>
Add new field fs_info::uuid to record device uuid when calling
fs_get_blkid() for further use.
No functional change.
Signed-off-by: Su Yue <glass.su@suse.com>
Count or clear transiently failed devices as of dm-raid superblocks.
Updated debuging.
Use lvconvert --repair to repair transiently failed legs.
Activating all 'meta' LVs with single sync_local_dev_names().
Using proper DM path for meta LV.
Modified-by: zkabelac@redhat.com
Use the new sanlock_acquire2() which returns info about the owner
of a lease. Pass this info back to the lvm command, where it's
initially used to print the host_id of a host holding a lock
when it cannot be acquired.
See Linux source Documentation/admin-guide/blockdev/zram.rst .
zram devices offer a good performance and efficient resource utilization
through the use of compression.
Signed-off-by: David Disseldorp <ddiss@suse.de>
If lvresize is given a size > the maximum COW size for a given origin
the command will fail with an internal error and no error message:
# lvresize --size 1.6g fedora/snaptest-snap
Rounding size to boundary between physical extents: <1.59 GiB.
Reached maximum COW size <1.01 GiB (258 extents).
Command failed with status code 5.
With -vvv:
Found snapshot target v1.16.0.
Getting target version for snapshot-origin
dm versions [ opencount flush ] [2048] (*1)
Found snapshot-origin target v1.9.0.
Reached maximum COW size <1.01 GiB (258 extents). <<<
Unlock: Memlock counters: prioritized:0 locked:0 critical:0 daemon:0 suspended:0
Syncing device names
Unlocking /run/lock/lvm/V_fedora
_undo_flock /run/lock/lvm/V_fedora
Freeing VG fedora at 0x55781b142890.
Freeing VG fedora at 0x55781b136860.
global/notify_dbus not found in config: defaulting to 1
Destroy lvmcache content
Completed: lvresize -vvv --debug --size 1706243072b fedora/snaptest-snap
Internal error: Failed command did not use log_error
This happens because in this case _lvresize_adjust_extents() returns
early without setting lp->resize to either LV_EXTEND or LV_REDUCE after
capping lp->extents to the maximum COW size.
Fix this by just capping lp->extents and relying on the existing code in
_lvresize_adjust_extents() to fixup lp->resize in the case that
lp->extents == existing_logical_extents. This is consistent with the
no-op case where -l is given as the existing size:
root@localhost:~/src/git/lvm2# LD_LIBRARY_PATH="$PWD/tools" ./tools/lvm lvresize -L 1.6g fedora/snaptest-snap
Rounding size to boundary between physical extents: 1.60 GiB.
Reached maximum COW size <1.01 GiB (258 extents).
New size (258 extents) matches existing size (258 extents).
No size change.
Initialization of union is somewhat tricky as it initialize only
the first member + padding, but in our case this does not clear
the whole size of union so explicitly set \0 after 2 'struct id'
and make sure DM uuid is not using random characters from stack.
Also add explicit .id designators (c99).
After detecting that a VG has wrongly claimed a PV, unpair
the pv->dev setting. This will cause the usual "missing PV"
message to appear for that VG. Make this message, and some
others, clearer by using the VGID rather than the VG name
when there are multiple VGs with the same name.
_vg_read() calls lvmcache_update_vg_from_read() which detects
that the VG metadata is incorrectly claiming the PV. Flag this
condition in the PV status as WRONG_VG. Later, vg_read() can
simply check the WRONG_VG flag rather than repeating the same
PV/VG checks that were already done in lvmcache_update_vg_from_read.
Outdated VG metadata that appears when an old device is attached
to the system can result in PVs appearing to belong to the
old/wrong VG, and commands are allowed to use (corrupt) the PVs.
- vgcreate old /dev/sda /dev/sdb /dev/sdc
- offline /dev/sda
- vgreduce --removemissing old
- vgremove old
- vgcreate new /dev/sdb /dev/sdc
- online /dev/sda
When sda is reattached, sdb and sdc will appear to be
in VG old again. An attempt to correct the problem,
e.g. with vgremove old or vgreduce old, would modify
sdb and sdc, removing them from the new VG.
To fix this, check that sdb and sdc contain metadata for
VG old before allowing VG old to claim ownership of them.
With the fix, sdb and sdc are not displayed as part of
VG old, and commands to change VG old will fail as long
as it references incorrect PVs.
To fix VG old (sda), remove the incorrect PVs from VG old
while limiting the command to see only the correct PVs:
vgreduce --removemissing --devices /dev/sda old
If an inactive LV is being cached in writeback mode, then
removing the cache does a temporary activation to flush
the cache back to the main LV. However, it forgot to
deactivate the LV again, so the temporary activation
was left in place.
Previous commit 874a8ab4d0 missed 'IGNORE' mode.
Fix it by adding rather 'explicit' test for this value,
so the code is better readable.
Also unlock memory earlier and drop unneeded <backtrace>
from return since we already logged error in this function.