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

7489 Commits

Author SHA1 Message Date
David Teigland
76bd678ce3 devices: isolate fake device setup for config file
Freeing dev-cache from dumb fake device usage.
2024-07-02 16:18:09 -05:00
David Teigland
92fd2cb498 devices: isolate fake dev use for mirror checks
Freeing dev-cache from dumb fake device usage.
2024-07-02 15:07:43 -05:00
Zdenek Kabelac
82d145a372 lvmlockd: fix compilation with disabled lvmlockd
With updated functionality for lvmlockd some prototypes
needs to be updated for builds without lvmlockd.
2024-07-02 16:58:03 +02:00
David Teigland
ad1d688734 devices: simpler dm devs cache naming
The dm devs cache is separate from the ordinary dev cache,
so give the function names distinct prefixes, using
"dm_devs_cache" to prefix dm devs cache functions.
2024-07-01 11:50:59 -05:00
David Teigland
8b4701d7c4 devices: redo bcache invalidation of PVs on LV 2024-07-01 11:30:51 -05:00
David Teigland
5551e4a1e9 devices: update dm uuid cache naming
replace "dm uuid" with "dm devs" in case it begins
caching more than dm uuids.
2024-07-01 10:59:16 -05:00
David Teigland
5f26c05bf2 Revert "devices: simpler bcache invalidation of PVs on LVs"
This reverts commit 200b05cec0.

Doesn't work to depend on lv name.
2024-07-01 10:59:16 -05:00
David Teigland
200b05cec0 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.
2024-06-28 18:19:15 -05:00
David Teigland
b8869e2d4e 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.
2024-06-28 18:01:29 -05:00
David Teigland
24943fe9d3 devices: update function name to dm_device_is_usable 2024-06-28 14:05:57 -05:00
David Teigland
990f4f7c4f 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.

dev_manager_get_device_list() -> dev_manager_get_dm_active_devices()
get_device_list() -> get_dm_active_devices()
device_get_uuid() -> dev_dm_uuid(), devno_dm_uuid()
2024-06-28 14:05:53 -05:00
David Teigland
f1d88007b0 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.
2024-06-27 13:29:03 -05:00
David Teigland
f32fd1fcb9 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
2024-06-27 13:29:03 -05:00
David Teigland
943e979079 lvmlockd: parse lockopt string into flags 2024-06-27 13:29:03 -05:00
David Teigland
9ea5ff3db5 lvmlockd: remove unused paramater
start_init option has never been used
2024-06-27 13:29:03 -05:00
David Teigland
4d8fb10af2 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".
2024-06-27 13:29:03 -05:00
David Teigland
55687b6656 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.
2024-06-27 13:29:03 -05:00
David Teigland
58e75f6178 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.
2024-06-27 13:29:03 -05:00
David Teigland
bf60cb4da2 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.
2024-06-27 13:29:03 -05:00
Zdenek Kabelac
21b215ee63 udev: disable suffix handling
The idea in the patch 6e6d4c62b for handling -suffix as
indication of private device needs to be disabled.

Some problematic cases are currently not resolvable and some
more thinking is needed.

Once fixed, we can revert this patch.
2024-06-25 23:18:07 +02:00
Zdenek Kabelac
336cb32884 device_mapper: empty string for missing uuid
Constify name & uuid within dm_active_device.
Set uuid to "" for case the DM device has no uuid.
Do not store "empty" device uuid in radix tree.
2024-06-21 14:51:25 +02:00
Zdenek Kabelac
88fb07b669 label: use dev iterator directly
Avoid preparing 'extra' dm_list with devices, and just
use the iterator result directly.
2024-06-21 11:28:54 +02:00
Zdenek Kabelac
cc344c3e69 dev_cache: replace dm_hash with radix_tree
For large device sets our dm_hash can produce larger amounf of mapping
collision and we would need to further increase our has size.

So instead use the radix_tree code which is immune agains growing size
of devices and uses memory more effiecently to store all the paths.
2024-06-21 11:28:54 +02:00
Zdenek Kabelac
e0537559c6 dev-cache: replace btree with radix_tree usage
Instead of less efficient 'btree' switch dev_cache to use
radix_tree, that is generating more efficient tree mapping.

Some direct use of btree iteration replace with our dev_iter code.
2024-06-21 11:28:54 +02:00
Zdenek Kabelac
4b126fd953 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.
2024-06-21 11:28:54 +02:00
Zdenek Kabelac
ed440367b9 dev_manager: check if uuid isn't already in cache
When DM uuid cache is available, we can possibly avoid unnecessary
status ioctl() when we check the device for 'usable' uuid.

If this test passes the existing code will got through the full check.
2024-06-21 11:28:54 +02:00
Zdenek Kabelac
e30bc9b179 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.

Introduce:
dev_cache_update_dm_devs
dev_cache_get_dm_dev_by_devno
dev_cache_get_dm_dev_by_uuid

Use radix_tree for searching.
2024-06-21 11:28:54 +02:00
Zdenek Kabelac
14f782c5a7 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.
2024-06-21 11:25:33 +02:00
Zdenek Kabelac
b1d80a0ffd gcc: pipe error path
Close opened descriptors on failed fork path.
2024-06-19 14:28:02 +02:00
Zdenek Kabelac
64ccbc4b52 gcc: check cv pointer when needed
As 'cv' was already dereferenced, check for NULL with do {} while();
loop.
2024-06-19 14:28:02 +02:00
Zdenek Kabelac
a98beb8ee3 gcc: ensure all fmt struct element are initialized 2024-06-19 14:28:02 +02:00
Heinz Mauelshagen
d01e5ec126 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.
2024-06-18 14:14:24 +02:00
Zdenek Kabelac
88681f05f1 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.

Adapt the only bcache user ATM for API change.

Adapt unit test to match changed API.
2024-06-03 15:30:05 +02:00
Zdenek Kabelac
76ca20a9af gcc: drop const specifier from allocated string
Use nornal (char*) for pointers we should free().
2024-06-03 15:30:05 +02:00
Zdenek Kabelac
896410b393 cleanup: use _ for static var
Add missing '_' for some static vars.
2024-06-03 15:30:05 +02:00
Zdenek Kabelac
13e0222ba2 device_id: more use of device_get_uuid
Use function that is caching UUID if kernel provides functionality
from a single ioctl() call.
2024-06-03 15:30:05 +02:00
Zdenek Kabelac
fffff2c2a2 dev-mpath: check uuid with device_get_uuid 2024-06-03 15:30:05 +02:00
Zdenek Kabelac
915dd18361 typo: fix typos
Typo and indent.
2024-06-03 15:30:05 +02:00
Zdenek Kabelac
85e0636623 cleanup: some more MAJOR MINOR unsigned
Finish remaing missing cases where MAJOR/MINOR was casted to (int)
while we can now use it directly as 'unsigned'.
2024-06-03 15:30:05 +02:00
Zdenek Kabelac
9207bae33b device_id: use faster dm_strncpy 2024-05-27 21:34:25 +02:00
Zdenek Kabelac
9dfe5ce2bc cov: replace enum report_type_t with unsigned
Another enum used as bitfield mask.
2024-05-27 16:35:23 +02:00
Zdenek Kabelac
90c6c421cd cov: convert some more enternal field masks
Some more 'internal' masks misusing enums for bitfields.
2024-05-27 16:35:23 +02:00
Zdenek Kabelac
403ecb46fa cov: annotate known use of validated lv name 2024-05-27 16:35:23 +02:00
Zdenek Kabelac
cd56b04ef6 cleanup: print MAJOR and MINOR as unsigned
Print directly as %u instead of %d with (int) casting.
2024-05-27 15:35:58 +02:00
Zdenek Kabelac
e1fd179dc5 cleanup: replace strlen with sizeof
Use the string size from compile time.
2024-05-27 15:35:58 +02:00
Zdenek Kabelac
eaa4882924 cleanup: use const for sizeof values 2024-05-27 15:35:58 +02:00
Zdenek Kabelac
ddf3b6e5e3 cleanup: simplier loop condition
Check char for != 0.
2024-05-27 15:35:58 +02:00
Zdenek Kabelac
9ab2607c7f cleanup: use correct log_sys_debug 2024-05-27 15:35:58 +02:00
Zdenek Kabelac
40cf4ce1e1 cleanup: struct reorder
Better alignments.
2024-05-27 15:35:58 +02:00
Zdenek Kabelac
45c06025da cleanup: some typos
Collection of some typos or invalid uppercase or doublespace cases.
2024-05-27 15:35:57 +02:00