David Teigland [Fri, 28 Jun 2024 23:04:25 +0000 (18:04 -0500)]
devices: simpler bcache invalidation of PVs on LVs
When a PV is stacked on an LV, the PV needs to be
dropped from bcache before the LV is processed.
The LV can be found in dev-cache using its name
rather than the devno.
David Teigland [Fri, 28 Jun 2024 22:57:00 +0000 (17:57 -0500)]
dev-cache: unify dm uuid cache struct lifetimes
The list of dm devs was in the cmd struct and had a
different lifetime than the radix trees referencing
those dm devs. Now the list and radix trees are
created and destroyed together.
David Teigland [Fri, 28 Jun 2024 18:35:12 +0000 (13:35 -0500)]
devices: dm uuid related function names
In the context of dm, 'device' refers to a dm device, but
in the context of lvm, 'device' refers to struct device.
Change some lvm function names to make that difference clearer.
David Teigland [Thu, 27 Jun 2024 17:46:15 +0000 (12:46 -0500)]
lvmlockd: vgchange systemid doen't need global lock
The comment explained that the ex global lock was just
used to trigger global cache invalidation, which is no
longer needed. This extra locking can cause problems
with LVM-activate when local and shared VGs are mixed
(and the incorrect exit code for errors was causing
problems.)
David Teigland [Wed, 26 Jun 2024 18:57:30 +0000 (13:57 -0500)]
lvmlockd: skip LV unlocking with no lvmlockd or no lockspace
vgchange -an vg is permitted when the vg lockspace
is not available, because LVs could still be active
for some reason, and they should be inactive when not
properly locked. In case lvmlockd was not running, or
the lockspace was not started, the command was
unnecessarily trying and failing to unlock every LV,
printing errors for every LV. We can skip this when
the lockspace is known to not be available.
David Teigland [Wed, 26 Jun 2024 17:06:02 +0000 (12:06 -0500)]
lvmlockd: let vgchange lockstop fail with EBUSY for orphans
vgchange --lockstop will fail with EBUSY if orphan locks in the
lock manager prevent stopping the lockspace. The orphan locks
can then be adopted and released, and the lockspace then stopped
cleanly.
David Teigland [Tue, 18 Jun 2024 18:26:09 +0000 (13:26 -0500)]
lvmlockd: adopt options
Lock adoption is not part of standard command behavior, but can
be used for manual recovery or cleanup from unexpected failure
cases. Like other lockopt values, they are hidden options for
--lockopt. Different lock managers will behave differently.
Adopting locks with lvmlockd -A1 is more accurate and automatic.
--lockopt adoptls
. for vgchange --lockstart
. adopt existing ls, or fail if no existing lockspace is found
--lockopt adoptgl | adoptvg | adoptlv
. for commands using lvmlockd locks
. adopt orphan gl/vg/lv lock, or fail the lock request if
no orphan lock is found
. will fail if orphan lock exists with a different lock mode
. command may still continue with a failed shared lock request
--lockopt adopt
. for lockstart or any command using lvmlockd locks
. adopt existing lockspace, or start lockspace if none exists
. adopt orphan gl/vg/lv lock, or acquire new lock if no orphan found
. will fail if orphan lock exists with a different lock mode
. command may still continue with a failed shared lock request
. with dlm this option only works for ls
David Teigland [Mon, 17 Jun 2024 21:38:19 +0000 (16:38 -0500)]
vgchange: improve some lvmlockd lockstart messages
Stop printing "Skipping global lock: lockspace not found or started"
for vgchange --lockstart, since it's generally an inherent limitation
that the global lock isn't available until after locking is started.
Update the start delay warning to "a few seconds".
David Teigland [Fri, 14 Jun 2024 15:59:35 +0000 (10:59 -0500)]
lvmlockd: disable lvb for sanlock
The lvb is used to hold lock versions, but lock verions are
no longer used (since the removal of lvmetad), so the lvb
is not actually useful. Disable their use for sanlock to
avoid the extra i/o required to maintain the lvb.
David Teigland [Thu, 13 Jun 2024 20:50:36 +0000 (15:50 -0500)]
lvmlockd: skip more vgremove steps with lockopt force
vgremove with --lockopt force should skip lvmlockd-related
steps and allow a forced vg cleanup, in addition to using
--nolocking to skip normal locking calls.
David Teigland [Wed, 12 Jun 2024 20:36:45 +0000 (15:36 -0500)]
lvmlockd: avoid lockd_vg for local VGs
Previously, a command would call lockd_vg() for a local VG,
which would go to lvmlockd, which would send back ENOLS,
and the command would not care when it saw the VG was local.
The pointless back-and-forth to lvmlockd for local VGs can
be avoided by checking the VG lock_type in lvmcache (which
label_scan now saves there; this wasn't the case back when
the original lockd_vg logic was added.) If the lock_type
saved during label_scan indicates a local VG, then the
lockd_vg step is skipped.
Zdenek Kabelac [Sun, 2 Jun 2024 20:50:11 +0000 (22:50 +0200)]
filter-persistent: convert to use radix_tree
Convert the persisten filter to use more memory compact radix_tree as
dm_hash is bound to preallocated number of slots and stores whole
key together with value.
Zdenek Kabelac [Sun, 2 Jun 2024 21:10:05 +0000 (23:10 +0200)]
device_mapper: refactor code to lvm library
Move the code around caching active dm device devno, name and uuid
from device_mapper/libdm-iface to dev_cache file - as libdm layer
cares about 'decoding' ioctl data from kernel and caching for use by
lvm stays within lvm.
Zdenek Kabelac [Fri, 21 Jun 2024 09:08:30 +0000 (11:08 +0200)]
dev_manager: no layer suffix for component
Do not attach layer suffix to the UUID when activating component LV.
In this case we want to see allow this LV to be public, thus
such LV should not be using -layer suffix in its UUID.
This also requires that our 'cached' access will check for
both UUID (with & without suffix) which was unnoticed issue before.
This change is now necesssary since our udev rule automatically expects
any LV with -layer suffix is private and will prevent generaring
any systemd unit even when there are no 'DM' flags bits passed via
cookie mechanism while creating such LV.
raid_manip: prevent reshape with freed component SubLVs
In order to free SubLVs after a stripe removing reshape, lvconvert has
to be run without layout changes. Prevent a layout changing request
in case any such freed SubLVs exist and inform the user about the fact
requesting to release them first.
Calculates expected size before/after reshapes adding/removing stripes
to/from RaidLVs with levels 4/5/6/10 and compares it with the actual
one the block layer shows. Stripes reshaped to are listed in the
tst_stripes variable. mkfs/fsck/resize2fs the respective RaidLVs
to confirm ext4 can be resized accordingly without issues.
Peter Rajnoha [Mon, 3 Jun 2024 10:07:07 +0000 (12:07 +0200)]
udev: ignore private LVM devs in udev and systemd
We automatically ignore these devs, when lvm2 create devs,
whoever when lvm2 database is dropped or someone just
created these devs with such formated UUID, there is no
other informantion then to check DM UUID.
Zdenek Kabelac [Mon, 3 Jun 2024 11:41:06 +0000 (13:41 +0200)]
tests: fix wrong pos with CONFIG_PRINTK_CALLER
SUSE kernels distribution enables CONFIG_PRINTK_CALLER by default.
One line of cat /dev/kmsg is like:
6,904,9506214456,-,caller=T24012;loop8: detected capacity change from 0
to 354304
If CONFIG_PRINTK_CALLER is off:
6,721,53563833,-;loop0: detected capacity change from 0 to 354304
',caller=T24012' is the redundant part needed to be handled.
Otherwise pos will be lager than buf size causing sz underflowed.
Then constructor of std::string will throw a exception to break
tests:
$ make check_local T=shell/000-basic.sh
VERBOSE=0 ./lib/runner \
--testdir . --outdir results \
--flavours ndev-vanilla --only shell/000-basic.sh --skip @
Zdenek Kabelac [Sun, 2 Jun 2024 12:11:37 +0000 (14:11 +0200)]
radix_tree: add radix_tree_values
To more easily adopt radix_tree over existing code base, add
abstraction over 'radix_tree_iterate' which basically builds
an array of all traversed values, and then it's just easy to
go over all array elements.
TODO: code should be converted to use radix_tree_iterate()
directly as it's more efficient.
Note: it can be possibly to rewrite recursive _iterate() usage
to linear travesal, not sure whether it's worth the effort
as conversion to 'radix_itree_iterator' is relatively simple.
Zdenek Kabelac [Sat, 1 Jun 2024 17:30:33 +0000 (19:30 +0200)]
radix_tree: add radix_tree_lookup/insert_ptr
Add simple 'wrapper' inline functions to insert or return ptr lookup value.
(So the user doesn't need to deal with 'union radix_value' locally and
also it makes easier to translage some lvm2 functions to use radix_tree).
Note: If the stored 'value' would NULL, it cannot be recognized
from a case of 'not found'. So usable only when 'values' stored with
tree are not NULL.
Zdenek Kabelac [Fri, 31 May 2024 19:46:19 +0000 (21:46 +0200)]
radix_tree: api change
Instead of using 'key state & key end' uint8_t* switch to use
void* key, & size_t keylen. This allows easier adaptation with
lvm code base with way too much casting with every use of function.
Also correctly mark const buffers to avoid compiled warnings and
casting.
David Teigland [Thu, 30 May 2024 19:51:22 +0000 (14:51 -0500)]
vgimportdevices: skip global lockd locking
Fix commit b65a2c3f3a767 "vgimportdevices: skip lvmlockd locking"
which intended to disable lvmlockd locking, but the lockd_gl_disable
flag was mistakenly set after lock_global() so it wasn't effective.
This caused vgimportdevices to fail unless locking was started.
Zdenek Kabelac [Mon, 27 May 2024 11:48:57 +0000 (13:48 +0200)]
cov: cleanup mask from enum to unsigned
Enums are single 'values' so not a proper type for bitfields.
(Probably better to use such values as defines).
Although here 'daemon_talk()' is part of library API, it's hidden
non-public API call - and moreover 'enum' and 'unsigned' are
using the same size, so linker shouldn't have any issue with
this symbol usage.
For this reason there are no 'versioning' tricks applied.
Zdenek Kabelac [Sat, 25 May 2024 22:33:16 +0000 (00:33 +0200)]
hash: increase some default hash table size
Size of these hashes was quite small, so raise the size of
hashed entries to reduce amount of hash collistion.
Select some unique/unused number for hash_create below 8192.
Zdenek Kabelac [Thu, 23 May 2024 23:07:47 +0000 (01:07 +0200)]
device: use device_get_uuid
Replace call to get_dm_uuid_from_sysfs() with use of
device_get_uuid() which gets the same information,
but instead of several syscalls it need either 1 or even 0
when the information is cached with newer kernels.
Zdenek Kabelac [Thu, 23 May 2024 21:03:05 +0000 (23:03 +0200)]
device: propagate struct cmd_context
For better use of cached data located within cmd_context,
pass this structure from the top level function.
Also add missing '_' for static _dev_cache_index_devs.
No other change here.
Zdenek Kabelac [Mon, 27 May 2024 13:34:16 +0000 (15:34 +0200)]
device_mapper: add dm_device_list_find_by_dev
Introduce function to find device's name and uuid for
a given major:minor.
This information is cached with dm_device_list which reads all the
info from single ioctl(DM_DEVICE_LIST).
Lvm keeps major:minor name & uuid for active devices in the system.