1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

7354 Commits

Author SHA1 Message Date
Zdenek Kabelac
295e632e81 util: add _dm_strncpy
Add internal inline function wrapper for dm_strncpy().
Use it for calls where we test the result.
Avoids emitting warnings in Coverity for unchecked usage.
2024-04-04 19:37:13 +02:00
David Teigland
c78970c0d0 lvmcache: free list of add_cache_devs 2024-04-03 15:59:25 -05:00
Zdenek Kabelac
fb80ed3143 cleanup: remove lvmcache_has_bad_metadata 2024-03-30 00:17:39 +01:00
Zdenek Kabelac
adfa16c899 cleanup: drop unused code 2024-03-30 00:17:39 +01:00
Zdenek Kabelac
d39b47d665 filtes: remove lvmetad bits from usable filter
Eliminate some dead code from usable filter, that is no longer usable
after removal of lvmetad.
2024-03-30 00:17:39 +01:00
Zdenek Kabelac
46ef562c50 device_id: simplier loop control 2024-03-30 00:17:39 +01:00
Zdenek Kabelac
d65a428f2d device_id: use dm_strncpy
Simplify code.
2024-03-30 00:17:39 +01:00
Zdenek Kabelac
b8d5744c6e deviced_id: use zalloc
While moving to dm_strncpy, in this case since pvid is also
passed to crc calc, make sure whole buffer is always initilized.
2024-03-30 00:17:39 +01:00
Zdenek Kabelac
4151df32c1 filter: zero internal structure
Valgrind noticed access to unitialized warned_filter.
2024-03-30 00:17:39 +01:00
Zdenek Kabelac
960df88621 cov: validate i before underflow
Although it can't happen in this code, ensure 'i' is not 0
before decrementing it.
2024-03-29 01:34:22 +01:00
Zdenek Kabelac
7ec7d8cf54 cov: reset FILE on error path
Although fclose() fails - we should not be retrying with
already released stucture.
2024-03-28 21:15:38 +01:00
Zdenek Kabelac
fc477192e5 cleanup: drop unused code
Code was related to long time obsoleted  vgconvert
for lvm1 to lvm2 conversion.
This code likely was missed to be removed.
2024-03-28 18:18:37 +01:00
Zdenek Kabelac
83b726e5dd gcc: move declaration into ifdef
Prevent unused warning when the ifdef code is not compiled.
2024-03-27 01:11:00 +01:00
Zdenek Kabelac
0dbd90d74e gcc: match signed integers 2024-03-27 01:11:00 +01:00
Zdenek Kabelac
f98d2ffe87 device_id: use dm_basename
Avoid problems for other libc like muslc and use dm_basename.

Prototype for basename has been removed from string.h from latest musl [1]
compilers e.g. clang-18 flags the absense of prototype as error. therefore
include libgen.h for providing it.

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Reported-by: Khem Raj <raj.khem@gmail.com>
2024-03-27 00:30:58 +01:00
Zdenek Kabelac
421afd287a cov: ensure namelist is defined
Seems coverity doesn't have good model for scandir.
Let's ensure pointer is seen as defined.
2024-03-25 17:16:00 +01:00
Zdenek Kabelac
ac90ab7736 cov: drop some unneeded continue 2024-03-25 16:54:11 +01:00
Zdenek Kabelac
ae7b59f509 cov: check for syscall resuls 2024-03-25 16:38:52 +01:00
Zdenek Kabelac
b84702349f cov: ensure buffer is nul ended
Use dm_strncpy() to ensure ending nul.
2024-03-25 16:37:04 +01:00
Zdenek Kabelac
46e013988f cov: check for strftime result 2024-03-25 14:45:09 +01:00
Zdenek Kabelac
3b47ce0a37 devices_id: add some syscall checks
Add debug tracing for syscall failures.
Also switch some log_error to log_warn when command does not exit
with 'error' result and only warns user.
Easier error path handling.
Initialize some vars at declaration time.
2024-03-25 14:43:33 +01:00
Zdenek Kabelac
1ba2d40473 gcc: ensure num has always initilized value 2024-03-25 11:44:36 +01:00
Zdenek Kabelac
bca6f58848 cov: ensure string ends with \0
Use dm_strncpy() that ensures \0 termination.
2024-03-25 11:18:29 +01:00
Zdenek Kabelac
835e8f9d7a cov: fix incorrect error check
Check for NULL pointer.
Fix missing release on error path.
Also dir_fd might be just != -1.
2024-03-25 11:18:29 +01:00
Zdenek Kabelac
ab3c690077 dev-cache: change locales just once 2024-03-25 11:05:05 +01:00
Zdenek Kabelac
b47b66ebff dev_manager: pending traces only existing LV
Before adding LV to the dtree, check whether it's already
in dtree.
2024-03-21 22:35:47 +01:00
Zdenek Kabelac
622884d67a dev_manager: open_count not needed
We do not need to check for open_count in these _info calls.
2024-03-21 22:35:47 +01:00
Zdenek Kabelac
363e8888ae dev_manager: implement _cached_dm_tree_node 2024-03-21 22:35:47 +01:00
Zdenek Kabelac
a985d5c63d dev_manager: fix table for cache with cachevol
When using cached LV with cachevols (so not with cachepool),
the loaded table could have been using more then one mapping line
for sub devices - resulting into data corruption in some cases
when i.e. taking snapshot of such cached LV with and instead of
single line - 2 lines were generated into DM table as the code
skipped protection again repeated addition.

vg-fast_cvol-cdata: 0 16384 linear 253:2 16384
vg-fast_cvol-cdata: 16384 16384 linear 253:2 16384

New code is also refactoring to use _add_new_cvol_subdev_to_dtree
(similar _add_cvol_subdev.. ) and also the addition of subdev has
been moved after check for already processed node.
Also the cachevol sub devices are now added with the insertion
of cachevol with cached LV.
2024-03-21 22:35:47 +01:00
Zdenek Kabelac
ad582da3ca dev_manager: relocate code
Use better place to search for cvol subdev mappings.
Add them with cachevol that is used for cache LV.
2024-03-21 22:35:47 +01:00
Zdenek Kabelac
abc1b44d8d dev_manager: refactor
Use struct initilizer to setup lvid.
2024-03-21 22:35:47 +01:00
Zdenek Kabelac
9718fd2496 debug: print names of tracked LVs
Debug was printing passed in LV name, but it's more usable to see
names of LVs 'tracked' for removal.
2024-03-21 22:35:47 +01:00
Zdenek Kabelac
8c7400121e debug: trace when ignoring origin_only suspend
Add log debug message when origin_only suspend would be ignored.
2024-03-17 13:17:53 +01:00
Zdenek Kabelac
457bd1392a thin: support chaining of external origins
Improve support for building DM tree when there is a chain
of external origins used for LV.

For this we cannot use track_external_lv_deps as this works
only for LV with just one external origin in its device tree.

Instead add directly 'dev' to the instead of add whole LV.
This avoid possibly recurive endless loop, however we may eventally
have some problems with undiscovered/missing devices in DM tree.
2024-03-17 13:17:53 +01:00
Zdenek Kabelac
a0776fe409 thin: remove stack external origins
Ensure external origin is deactivated during removal.
Only unused external origins can be deactivated.
2024-03-17 13:17:53 +01:00
Zdenek Kabelac
386f0bfb4f thin: lock fs when converting to external origin
Ensure suspend is locking fs, when converting LV to external origin.
2024-03-17 13:16:35 +01:00
Zdenek Kabelac
edc91caffb thin: external origins across thin-pool
Fix/support creation and usage of the external origin
across thin-pools - so thin LV can use thin LV from
some other thin-pool as external origin (read-only).
2024-03-16 10:40:54 +01:00
Zdenek Kabelac
27bdd038a8 thin: validate usable volume for external origin
When creating external origin via 'lvcreate --type thin'
add the validation for LV being usable as external origin
since certain LVs cannot be really used this way.
Also call this function early during lvcreate cmdline arg
validation se we do not need to do unecesary operation.
2024-03-16 10:40:54 +01:00
Zdenek Kabelac
9e2870cc9f activation: reduce table preloading
Over the time the code for preloading detached LVs got unnecessarily
complicate. But actually we need to preload only LVs that
were previously non-toplevel (invisible) LVs and became visible
toplevel LVs in the precommitted metadata.

If there would be needed some other rule, it would likely be a bug in
conversion code forgetting to set visibility flag on detached LV.

This reduces number of unnecessary repeated DM tree preloading.
2024-03-16 10:34:31 +01:00
Zdenek Kabelac
9d145c17c3 snapshots: avoid monitoring of inactive origins
External origins for thin volumes can be also used at the same time
as old(thick) snapshot origins. However in this case it's possible
the LV is only active as being 'external' origin, but old snapshot LVs
are not active. For this case before handling these
LVs for un/monitoring check the active state of origin LV.

This should prevent warnings of monitoring failures.
2024-03-16 10:23:55 +01:00
David Teigland
d1aacae0f7 lvm.conf: update scan_lvs description
to better reflect the devices file existence, and
to mention layered autoactivation in lvm udev rules.
2024-02-21 11:08:02 -06:00
Zdenek Kabelac
66be32fbc1 cleanup: remove unused code 2024-02-19 14:20:39 +01:00
Zdenek Kabelac
4f936f2312 devices: refactor recursive dir create
Make recursive directory path creation reusable via
dir_create_recursive.

While we already have dm_create_dir() - it's not taking mode arg,
so let's make lvm's internal file helper function.
2024-02-19 14:20:39 +01:00
Zdenek Kabelac
c534cf3bca label: simplify code 2024-02-19 14:20:39 +01:00
Zdenek Kabelac
d486b379d0 bcache: remove duplicate _wait_all call
Since the  bcache_flush() is supposed to already use _wait_all()
remove duplicated invoce of this function.
2024-02-19 14:20:39 +01:00
Zdenek Kabelac
d19235993e cache: check module in modules builtin
Instead of parsing the whole /proc/kallsyms use faster variant
of using modprobe tool logic.

lvm2 here wants to know whether the particular DM cache policy is
present in the kernel - however since the cache policy does not have
any kernel module parameters and it can be built-in to a kernel
there is no /sys/modules directory in such case and we would need to call
modprobe everytime we want detect such case.

The old solution tried to look for particular kernel symbol
(and like not the right way, as smq_exit might be actually ommitted).

New version checks MODULES_PATH/`uname -r`/modules.builtin for
whether is present cache policy module instead of CPU expensive parsing
of kallsyms.
2024-02-19 14:20:39 +01:00
Zdenek Kabelac
55937f9c8e vdo: read VDO stats via dm message
As the sysfs interface is seen somewhat obsolete, swith code
to prefer using DM 'stats' message to get our currently needed
info for VDO pool target.
2024-02-19 14:20:39 +01:00
David Teigland
4f9215e70f devices file: rename unused system.devices
If lvm.conf has use_devicesfile=0 and /etc/lvm/device/system.devices
exists, then rename it to system.devices-unused.YYYYMMDD.HHMMSS.
This prevents an old, incorrect system.devices from being used in
the future if lvm.conf is changed to use_devicesfile=1.
2024-02-15 11:40:37 -06:00
David Teigland
e59027e4f7 devices file: back up each version
Create backup copies of system.devices in /etc/lvm/devices/backup
named system.devices-YYYYMMDD.HHMMSS.NNNN.  NNNN is the version
counter from the file.

Each time that an lvm command writes a new system.devices file,
it also writes the same file in the backup directory.

A new comment line is added to system.devices with HASH=<num>
where <num> is a crc calculated from the uncommented lines in
system.devices.  This lets lvm detect if the file has been
modified outside of lvm itself.

If system.devices is edited directly, the next time a command
reads the file, the crc will not match the HASH value.  The
command will then rewrite system.devices with the correct HASH
value, and create a backup reflecting the edits.

A default limit of 50 backup files is kept, configurable by
lvm.conf devicesfile_backup_limit (set to 0 to disable backups.)
2024-02-15 11:40:37 -06:00
Andre Klärner
fe822f7043 system_id: explain the reason for choosing appmachineid over machineid
Since understanding the reason for choosing the appmachineid over the
direct use of machineid is not easily found, I extended to help text to
clarify this a bit.
2024-02-05 14:01:22 -06:00