1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-05 12:19:48 +03:00
Commit Graph

311 Commits

Author SHA1 Message Date
Zdenek Kabelac
39b7d1ba8f cleanup: typos in comments
Collection of typos in code comments.
Should have no runtime effect.
2024-08-30 16:51:15 +02:00
Zdenek Kabelac
7da47cea35 cleanup: typos in logging
Fixes various typos in printed/logged messages.
2024-08-30 16:51:15 +02:00
David Teigland
f8aa073a8d Revert "dev-cache: move global variables into cmd struct"
This reverts commit 77be3250d9.
2024-07-08 15:32:41 -05:00
David Teigland
39e65c8f59 Revert "bcache: move from global variable to cmd struct"
This reverts commit 5bf4efbab5.
2024-07-08 15:32:35 -05:00
David Teigland
5bf4efbab5 bcache: move from global variable to cmd struct 2024-07-03 12:58:18 -05:00
David Teigland
77be3250d9 dev-cache: move global variables into cmd struct
The cmd struct is now required in many more functions, and
it's added as a function arg for most direct dev-cache function
calls.  The cmd struct is added to struct device (dev->cmd) so
that it can be accessed in many other cases where dev-cache
functions are being called from places where getting the cmd
struct is too difficult.
2024-07-03 11:52:32 -05: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
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
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
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
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
e1fd179dc5 cleanup: replace strlen with sizeof
Use the string size from compile time.
2024-05-27 15:35:58 +02:00
Zdenek Kabelac
d192477ae6 label: cache dm dev list earlier
Cache (when possibly with newer kernel) earlier within label
scanning loop, so the cache information can be also used by
hints file.
2024-05-27 15:35:57 +02:00
Zdenek Kabelac
5da282fa23 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.
2024-05-27 15:35:17 +02:00
Zdenek Kabelac
74e487f3a9 label: make scan_bcache local
Seems there are no users of scan_bcache, so make it local.
TODO: such variable should be ideally in cmd_context.
2024-05-13 02:21:37 +02:00
Zdenek Kabelac
e6f46fafe7 const: use arrays of strings 2
Next set of changes.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
41ffa8c74d const: _ops labeler _text_ops 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
8545621d39 cov: replace strcpy with memcpy
When we know the size we can avoid using strcpy.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
f9fefaaabe refactor: update dm_strncpy to _dm_strncpy
For checked versions of dm_strncpy use inline wrapper _dm_strncpy.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
995ff58903 refactor: remove (void) from dm_strncpy usage
Start to use dm_strncpy() as unchecked version within source tree.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
c534cf3bca label: simplify code 2024-02-19 14:20:39 +01:00
David Teigland
a5628cf782 device_id: improve validate debug messages
Make the device_ids_validate messages consistent.

Consistently use "noupdate" and "update_needed" args.
2023-11-02 11:46:31 -05:00
David Teigland
e6c6713a1b hints: correct fix for hints with device ids
Fixes commit 63b469c160
"device_id: fix hints with device ids"

It's not correct for internal filtering to be a factor
in validating the set of devs that are the basis for hints.

Instead, look for inconsistencies between a hint entry and
the corresponding devices file entry.
2023-10-16 14:13:27 -05:00
David Teigland
63b469c160 device_id: fix hints with device ids
Fix some interactions between device IDs and hints.  Hints
may limit the scanned devices which should not always trigger
a search for the PVs that were intentionally not scanned.
Hints should also be invalidated if they contain a device
that's become excluded by an internal filter such as the
device_id filter.
2023-10-10 11:47:29 -05:00
David Teigland
1901a47df1 device_id: fix conditions for device_ids_refresh
Fix commit 847f1dd99c
"device_id: rewrite validation of devname entries"

which began calling device_ids_refresh() in cases where it
was unnecessary, leading to extra PV searches and warnings.
Specifically, a command like "lvs <vg>" would use the hints
file to scan only devices for the named VG.  This means that
scanning other PVs would be skipped, and device IDs of those
PVs could not be validated because there are no PVID values
to verify.  This missing info would cause messages about
the missing info, and would cause device_ids_refresh to
search for the PVs that had been intentionally skipped.
2023-10-05 15:33:55 -05:00
David Teigland
88aa285a79 devices: refresh device ids if the system changes
If the system changes, locate PVs that appear on different devices,
and update the device IDs in the devices file.  A system change is
detected by saving the DMI product_uuid or hostname in the devices
file, and comparing it to the current system value.  If a root PV
is restored or copied to a new system with different devices, then
the product_uuid or hostname should change, and trigger lvm to
locate PVIDs from system.devices on new devices.
2023-09-27 15:22:11 -05:00
Zdenek Kabelac
5ce236a691 gcc: correct signess comparation
Compare int to int and unsigned to unsigned...
2023-07-13 21:31:18 +02:00
Zdenek Kabelac
cc7c41abbd cov: remove unneeded header file inclusion 2023-05-10 15:27:48 +02:00
Zdenek Kabelac
c451d7925d cleanup: correcting some log_print
Correcting to log_print_unless_silent(),
so -qq can do some work.
2023-05-06 20:38:49 +02:00
David Teigland
bd05318ba2 pvscan: filter does not need to be checked for symlink names
With the recent use of DEVLINKS, there is no longer any real
point in checking the filter for symlink names.  Removing
this check should not change behavior with or without symlinks
in the filter.
2023-02-15 10:19:57 -06:00
David Teigland
c9fdc828ff vgchange autoactivation: skip regex filter containing symlinks
"vgchange -aay --autoactivation event" is called by our udev rule.
When the udev rule runs, symlinks for devices may not all be created
yet.  If the regex filter contains symlinks, it won't work correctly.
This command uses devices that already passed through pvscan.  Since
pvscan applies the regex filter correctly, this command inherits the
filtering from pvscan and can skip the regex filter itself.

See the previous commit
"pvscan: use alternate device names from DEVLINKS to check filter"
2023-01-31 15:30:35 -06:00
Zdenek Kabelac
5c463584f6 cov: remove unused headers 2022-07-11 01:18:24 +02:00
David Teigland
92b4fcf57f exit with error when --devicesfile name doesn't exist 2022-07-06 10:10:58 -05:00
David Teigland
8db3b11e4e change messages about filtered devices
Change messages that refer to devices being "excluded by filters"
to say just "excluded".  This will avoid mistaking the word
"filters" with the lvm.conf filter setting.
2022-04-01 13:38:21 -05:00
David Teigland
cc73d99886 devices: only close PVs on LVs when scan_lvs is enabled
This code is only needed when lvm scans PVs that are stacked on LVs.
2022-03-01 14:11:05 -06:00
David Teigland
7b1a857d5a devices: use dev-cache aliases handling from label scan functions
The label scan functions where doing some device alias validation
which is now better handled by the dev-cache layer, so just use
that.
2022-02-28 17:37:12 -06:00
David Teigland
4eb04c8c05 devices: fix dev_name assumptions
dev_name(dev) returns "[unknown]" if there are no names
on dev->aliases.  It's meant mainly for log messages.

Many places assume a valid path name is returned, and
use it directly.  A caller that wants to use the path
from dev_name() must first check if the dev has any
paths with dm_list_empty(&dev->aliases).
2022-02-24 17:22:04 -06:00
David Teigland
1126be8f8d devices: simplify dev_cache_get_by_devt
remove unused args, and no callers need or want a
repeated dev_cache_scan if there is no dev from the
lookup.
2022-02-24 17:21:58 -06:00
David Teigland
d59382c772 devices file: do not clear PVID of unread devices
In a certain disconnected state, a block device is present on
the system, can be opened, reports a valid size, reports the
correct device id (wwid), and matches a devices file entry.
But, reading the device can still fail.  In this case,
device_ids_validate() was misinterpreting the read error as
the device having no data/label on it (and no PVID).
The validate function would then clear the PVID from the
devices file entry for the device, thinking that it was
fixing the devices file (making it consistent with the on disk
state.)  Fix this by not attempting to check and correct a
devices file entry that cannot be read.  Also make this case
explicit in the hints validation code (which was doing the
right thing but indirectly.)
2022-02-10 14:16:04 -06:00
Zdenek Kabelac
04fbffb116 label: cache dm device list
Since we check for present DM devices - cache result for
futher use of checking presence of such device.

lvm2 uses cache result for label scan, but also when
it tries to activate or deactivate LV - however only simple
target 'striped' is reasonably supported.

Use disable_dm_devs to be able to control when lv_info()
get cache or uncached results.

TODO: support more type, however this is getting very complicated.
2021-12-20 16:13:28 +01:00
David Teigland
5c4ce4669e device_id: searched_devnames improvements
Remove the searched_devnames file in a couple more places:
. When hints need refreshing it's possible that a missing
  devices file entry could be found by searching devices
  again.
. When a devices file entry devname is first found to be
  incorrect, a new search for missing entries may be
  useful.
2021-11-16 14:29:17 -06:00
David Teigland
89c54db16c vgchange autoactivation: error path cleanup
If the optimized label scan fails (using online files),
then clear the device state prior to falling back to the
standard label_scan.  This avoids printing output about
unexpected state.
2021-11-15 11:07:11 -06:00
David Teigland
0e0faf30e0 vgchange autoactivation: lock vg early to avoid second label scan
Copy another optimization from pvscan -aay to vgchange -aay.
When using the optimized label scan for only one VG, acquire the
VG lock prior to the scan.  This allows vg_read to then skip the
repeated label scan that normally happens after locking the vg.
2021-11-10 16:50:50 -06:00
David Teigland
73b4602f21 pvs_online: include devname in pvid files
Include the device name in the /run/lvm/pvs_online/pvid files.
Commands using the pvid file can use the devname to more quickly
find the correct device, vs finding the device using the
major:minor number.  If the devname in the pvid file is missing
or incorrect, fall back to using the devno.
2021-11-09 11:26:26 -06:00
David Teigland
024ce50f06 vgchange -aay: improve unexpected command variations
For completeness and consistency, adjust the behavior
for some variations of:

  vgchange -aay --autoactivation event [vgname]

The current standard use is with a VG name arg, and the
command is only called when all pvs_online files exist.
This is the optimal case, in which only pvs_online devs
are read.  This remains the same.

Clean up behaviors for some other unexpected uses of the
command:

. With no VG name arg, the command activates any VGs
  that are complete according to pvs_online.  If no
  pvs_online files exist, it does nothing.

. If a VG name is used but no PVs online files exist for
  the VG, or the PVs online files are incomplete, then
  consider there could be a problem with the pvs_online
  files, and fall back to a full label scan prior to
  attempting the activation.
2021-11-08 15:19:25 -06:00