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

19375 Commits

Author SHA1 Message Date
Zdenek Kabelac
9207bae33b device_id: use faster dm_strncpy 2024-05-27 21:34:25 +02:00
Zdenek Kabelac
fbdd26a4a3 device_mapper: solve no devices path
Malloc needs to use sane value when names would be NULL.
Also for devices without 'uuid' return empty string instead of NULL.
2024-05-27 21:33:59 +02:00
Zdenek Kabelac
533a87d0ea lvremove: initilize struct list 2024-05-27 18:23:26 +02:00
Zdenek Kabelac
80fa3511be lvremove: check for handle
Get lvremove_params from non NULL handle.
Introduced in commit 47f8bda05.
TODO: any more thing needed ?
2024-05-27 17:03:37 +02:00
Zdenek Kabelac
c496cfa99a WHATS_NEW: update 2024-05-27 16:35:23 +02:00
Zdenek Kabelac
d825e8887c make: generate 2024-05-27 16:35:23 +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
3b649c3076 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.
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
1b90865843 cleanup: remove blank spaces 2024-05-27 16:35:23 +02:00
Zdenek Kabelac
88e0060aa8 cleanup: refactor common code
Refactor shared code from _get_rootvg_dev() between vgchange
and vgimportdevices to get_rootvg_dev_uuid() in toollib.c
2024-05-27 16:35:00 +02:00
Zdenek Kabelac
2e6e752c3a tests: add some lvm shell testing
Check lvm shell for autocomplete functionality and error reporting.
2024-05-27 15:35:58 +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
cdcd482fa4 libdm: use 'unsigned' for major minor
Although linux uses 'dev_t' as 'unsigned long int' on 64bit,
it's easier to print with just '%u' instead of '%lu'.
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
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
93115ef91d libdm: drop allocation
Use structure allocated on local stack.
2024-05-27 15:35:57 +02:00
Zdenek Kabelac
fdfe80f024 mirror: drop unneeded call
Major,minor,patchlevel are already set from previous call.
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
b63e54d0ed dev_manager: remove disable_dm_dev flag
Lvm currenly drops cache before first table manipulation
there is no need for this flag ATM.
2024-05-27 15:35:57 +02:00
Zdenek Kabelac
e211768d1c dev_manager: drop cache for dm tree manipulation
We've got cached DM list before grabbing lock, so there
is some chance, that DM table has changed and we would
need to refresh this info.

TODO: benchmark, whether it would even make sense to refresh cache
and keep it content instead of using individual ioctl() for tree build.
2024-05-27 15:35:57 +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
dac2bfe6a4 device_manager: add device_get_uuid
Function that is working with DM target is located within
lib/activate directory.

This function is able to use cached  dm_device_list when possible
to quickly resolve checks for device's UUID.

Function can fully replace get_dm_uuid_from_sysfs() and instead
of syscalls for open/read/close get the UUID with single ioctl.

When there is cached dm devs list, we can get many UUID from
a single syscall.
2024-05-27 15:35:56 +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
1712845ab5 device_mapper: use const for this API
Allow using constified version of devs_list.
Internal loop does not need to modify anythin in this stucture.
2024-05-27 15:35:17 +02:00
Zdenek Kabelac
36691b9844 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.
2024-05-27 15:34:16 +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
aad1add77f command: reorder vals order
Keep most frequently used val names in front.
2024-05-27 15:16:26 +02:00
Zdenek Kabelac
314c759a09 command: store val_name with its size
Compile length of val_name during compilation.
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
Zdenek Kabelac
2e0ac97903 error: try with modprobe
If the error target would be built as module,
ask modprobe to load it if the target is not present.
2024-05-27 15:16:26 +02:00
Zdenek Kabelac
9a371639fc cleanup: relocate section
Move _features[] structure from .data.rel.ro to .rodata.
2024-05-27 15:16:26 +02:00
Zdenek Kabelac
83c0b19f61 cleanup: use ALTERNATIVE_EXTENTS
Instead of comparing string of command names,
introduce ALTERNATIVE_EXTENTS command flags.
2024-05-27 15:16:25 +02:00
Zdenek Kabelac
93918a1990 cleanup: use ARG_LONG_OPT
Just like with _VAL strings, also _ARG strings do not need to
be present - as we can easily check for LONG opt version just
by adding attribute.

With attribute ARG_LONG_OPT string arg name[] becomes unused
and can be safely removed.

Also within _find_command_id_function() we do not need to handle
'command_enum == CMD_NONE' as separate case and just use single loop.
2024-05-27 15:16:25 +02:00
Zdenek Kabelac
59345da03f cleanup: do not store _VAL name string
String enum_name[] is unused so remove is with
all generated strings.

Reoder struct members, so there are no holes.
2024-05-27 15:16:25 +02:00
Zdenek Kabelac
dd78573073 libdm: parse only block section for proc_devices
Check for begining of 'B'lock section in /proc/devices file
before starting to sscanf() for major.
2024-05-27 15:16:25 +02:00
Zdenek Kabelac
38d34dbe75 lvmcmdline: use known lvm_command_enum
lvm command is already decoded (when found),
so use lvm_command_enum directly and avoid
comparing all strings again...
2024-05-27 15:16:25 +02:00
Zdenek Kabelac
5173b0c222 command: return proper unsigned value
Use better 'unsigned' value, so we don't have any 'casting' troubles.
2024-05-27 15:16:25 +02:00
Zdenek Kabelac
73298635b9 lvm: fix shell completion
Previous commit 82617852a4
introduce bug in complession - as the rl_completion_matches()
needs to always advance to next element where the index
is held in static variable.

Add comment about this usage.
2024-05-27 15:16:25 +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
Marian Csontos
6fdc8787eb post-release 2024-05-16 12:17:02 +02:00