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

773 Commits

Author SHA1 Message Date
Peter Rajnoha
9d6a3ee547
filesystem: add note about swap devices 2024-10-02 13:31:54 +02:00
Peter Rajnoha
e009becd73
dev-type: get swap device size from blkid using FSSIZE
blkid does not report FSLASTBLOCK for a swap device. However, blkid
does report FSSIZE for swap devices, so use this field (and including
the header size which is of FSBLOCKSIZE for the swap) instead to
set the "filesystem last block" which is used subsequently for
further calculations and conditions.
2024-10-02 13:31:54 +02:00
Peter Rajnoha
d5d2c98980
dev-type: add prefix to differentiate msdos and gpt constants 2024-10-02 12:02:34 +02:00
Peter Rajnoha
84cabd068b
filter: partitioned: also detect non-empty GPT partition table
We already detect msdos partition table. If it is empty, that is, there
is just the partition header and no actual partitions defined, then the
filter-partitioned passes, otherwise not.

Do the same for GPT partition table.
2024-10-02 11:54:01 +02:00
zkabelac
7447634c26 cleanup: replace use of alloced with allocated 2024-09-27 13:42:45 +02:00
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
Zdenek Kabelac
aa75e1f0bf cov: annotate known case 2024-08-09 15:10:24 +02:00
Zdenek Kabelac
22672be97d cov: check for dev_iter_create result
dev_iter_create() may fail in malloc so check
for its error code.
2024-08-09 15:10:18 +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
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
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
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
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
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
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
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
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
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
eaa4882924 cleanup: use const for sizeof values 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
bbe1b93ed9 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.
2024-05-27 15:35:57 +02:00
Zdenek Kabelac
01e014a246 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.
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
5c24d6d4db dev-type: use if..else if...
Compare strings till the first match.
2024-05-27 15:16:26 +02:00
Zdenek Kabelac
a198224666 dev-cache: skip scanning known blockless dirs
Skip scan and stat() for dirs and nodes within known /dev/ paths,
where no block devices are located.

Also strlen(_cache.dev_dir) just once.

TODO: add more dirs to _no_scan (configurable via lvm.conf ?)
2024-05-27 15:16:26 +02:00
Zdenek Kabelac
d8e639ecba dev-cache: collapsing slashes counts string size
_collapse_slashes() already goes through the whole string,
so just return now already known string length.
2024-05-27 15:16:26 +02:00
Zdenek Kabelac
caa0e08738 cleanup: use single array for idtype string
Share string array for de/coding idtype.
2024-05-27 15:16:26 +02:00
David Teigland
47f8bda051 lvremove: remove device_id for PVs on LVs
When PVs are created on LVs, remove the devices file entries
for the PVs when the LVs are removed.  In general, the devices
file entries should be removed with lvmdevices --deldev when
the LVs are removed (lvremove is the equivalent of detaching
a device from the system when layering PVs on LVs.)
This change is effectively an automatic lvmdevices --deldev
command that is built into lvremove when the LV has a PV on it.
2024-05-22 15:32:17 -05:00
David Teigland
c609dedc2f Allow system.devices to be automatically created on first boot
An OS installer can create system.devices for the system and
disks, but an OS image cannot create the system-specific
system.devices.  The OS image can instead configure the
image so that lvm will create system.devices on first boot.

Image preparation steps to enable auto creation of system.devices:
- create empty file /etc/lvm/devices/auto-import-rootvg
- remove any existing /etc/lvm/devices/system.devices
- enable lvm-devices-import.path
- enable lvm-devices-import.service

On first boot of the prepared image:
- udev triggers vgchange -aay --autoactivation event <rootvg>
- vgchange activates LVs in the root VG
- vgchange finds the file /etc/lvm/devices/auto-import-rootvg,
  and no /etc/lvm/devices/system.devices, so it creates
  /run/lvm/lvm-devices-import
- lvm-devices-import.path is run when /run/lvm/lvm-devices-import
  appears, and triggers lvm-devices-import.service
- lvm-devices-import.service runs vgimportdevices --rootvg --auto
- vgimportdevices finds /etc/lvm/devices/auto-import-rootvg,
  and no system.devices, so it creates system.devices containing
  PVs in the root VG, and removes /etc/lvm/devices/auto-import-rootvg
  and /run/lvm/lvm-devices-import

Run directly, vgimportdevices --rootvg (without --auto), will create
a new system.devices for the root VG, or will add devices for the
root VG to an existing system.devices.
2024-05-21 16:29:12 -05:00
Zdenek Kabelac
e59c84ca3a gcc: clean cast with -Wbad-function-cast
Makes gcc happier.
2024-05-14 17:59:26 +02:00
Zdenek Kabelac
8da0ab6fc1 cleanup: drop unused declared struct 2024-05-13 02:21:37 +02:00
Zdenek Kabelac
8168b5e71d clenaup: update local static with _ 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
09f70dbb87 cov: avoid TOCTOU
Use just opendir() call and produce error message from errno state.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
9f4dc4170b cov: sanitize string for file path 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
04b407674c cov: use sscanf buffer size limits
String parsing with buffer size limit.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
e6f46fafe7 const: use arrays of strings 2
Next set of changes.
2024-05-04 01:01:57 +02:00