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

4429 Commits

Author SHA1 Message Date
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
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
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
Zdenek Kabelac
e08e5a5a07 gcc: better initilizer for older gcc compilers
So use  { { } }.
2024-05-14 17:59:26 +02:00
Zdenek Kabelac
af983ad3d3 lvmcmdline: check for NULL
Althought this code likely never is hit with NULL, just add
check to be sure.
2024-05-13 14:49:54 +02:00
Zdenek Kabelac
60bad2f22d lv_types: sort order of types
Order is used for man page generation (although not completely).
So place  'zero & error' to the end of list.
Keep  linear,striped,snapshot in front.
For the rest use alphabetic order.
2024-05-13 12:58:37 +02:00
Zdenek Kabelac
ffdceeb982 cleanup: some missed public symbols static 2024-05-13 12:58:19 +02:00
Zdenek Kabelac
46669fe9e8 cleanup: add static _ 2024-05-13 02:21:37 +02:00
Zdenek Kabelac
5b7e30da76 lv_type: simplier macro usage
Use more simple macros - as there is likely not going to happen
any macro replacement - so use more effient structure layout.
2024-05-13 02:21:28 +02:00
Zdenek Kabelac
429ab45a1c lv_prop: simplier macro usage
Use more simple macros - as there is likely not going to happen
any macro replacement - so use more effient structure layout.
2024-05-13 02:20:29 +02:00
Zdenek Kabelac
f86bdcb6e9 command: validation code only for man-generator
Don't waste time with string order validation within command,
check within  'man-generator -c' is enough.
2024-05-13 02:18:19 +02:00
Zdenek Kabelac
25236a963f command: refactor inner loop
Move part of the 'inner' loop which is would be otherwise
always production same results for all  'opt_enum' values
out of the loop, so it can be evaluated just once.
2024-05-13 02:18:18 +02:00
Zdenek Kabelac
fd8ed7554e command: replace strcmp with enum
Here we already know 'enum' value, so compare
just those instead of calling strcmp().
2024-05-13 02:15:55 +02:00
Zdenek Kabelac
1a219c69ee lvmcmdline: runtime function resolving
Instead of resolving and storing 'command_fn'
withing 'struct command' use just funtion enum
and resolve function pointer just in place,
where it is really needed - first try to resolve
'new style' and fallback to 'old style' named.
2024-05-13 02:15:55 +02:00
Zdenek Kabelac
bebbb1e66a command: use command_id_to_enum
Instead of storing command_id as string, direcly
translate string to enum index and use 'command_enum()'
to get string when needed for printing.

This way we can easily detect error in the structure
while parsing it - and we can later avoid separate
'translation' loop.
2024-05-13 02:15:55 +02:00
Zdenek Kabelac
5840f90e82 command: refactor code for simplier lookup
We can more efficiently use command_name struct to
lookup for  lvm_command_enum and avoid many repeated
command name searches since we already know
the enum index that is now stored in 'struct command'.
2024-05-13 02:15:55 +02:00
Zdenek Kabelac
82617852a4 lvmcmdline: use strcut as const
Constity members in cmdline_context, would be nice, to replace
this static struct with couple function calls.

Also replace some 'while' loops with for loops, so code
is more readable.
2024-05-13 02:15:55 +02:00
Zdenek Kabelac
f854e3a722 command: return if already factored
We can directly return here, when we spot already counted varitants.
2024-05-13 02:15:53 +02:00
Zdenek Kabelac
abe1b49b47 command: refactor struct command_name
Split struct command_name to the constant part (keep the name)
and new 'struct command_name_args' which holds runtime computed
info.   To get to the _args part - we can easily use
lvm_command_enum as equivalent index.

Constified part 'struct command_name' is now fully stored
in .data.rel.ro segment, while command_name_args part goes
to .bss segment.

Code will be further reduced with next refactoring.
2024-05-12 23:53:19 +02:00
Zdenek Kabelac
433154fc8a command: better const usage for struct cmd_name
No need to store _CMD string - as it's not used anywhere.
Use LVM_COMMAND_COUNT as end of array.
2024-05-12 23:53:19 +02:00
Zdenek Kabelac
8ac1cc593e command: reduce struct size
Reduce memory usage for parser.
If the sizes would need to be bigger, man-generator warns.
For struct command_name  use just uint8_t to keep 1|0.
2024-05-12 23:49:09 +02:00
Zdenek Kabelac
d85c9728fb command: no need to duplicate const mem
No need to duplicate const char* here as
we refer already constant string in .rodata segment.
2024-05-12 22:17:46 +02:00
Zdenek Kabelac
1c396598ff command: futher move to single struct
Refactor code to not allocate memory for rule->opts,
instead use uint16_t array of MAX_RULE_OPTS within cmd_rule.

Also print more info if array would not be enough (>= 8).
2024-05-12 22:15:15 +02:00
Zdenek Kabelac
868bd3b51e commands: move tabs to eol
Make the source code a bit easier to read.
2024-05-10 01:15:55 +02:00
Zdenek Kabelac
5aff63c07b commands: enable more options for vdo conversion
Update definitions to add support for some more VDO options
when converting volumes to be used as thin-pool with vdo data volume.

Split some option in existing OO_LVCONVERT_VDO to OO_LVCONVERT_VDO_POOL
and reused then with OO_LVCONVERT_THINPOOL.
2024-05-10 01:15:55 +02:00
Zdenek Kabelac
8a323082ef lvconvert: vdo support conversion options
When convert already existing vdopool to be used as
thin-pool backend and user is passinng option for VDO configuration
process them - as we know converted LV is offline, we can do such
change easily instead of telling user to run separate lvchange later.
2024-05-10 01:15:55 +02:00
Zdenek Kabelac
04d9f13fa6 lvconvert: vdo control for signature wiping
When converting volumes to be used for thin-pool with VDO, allow
users to control wipesingature behaviour.
By default volumes should be checked against signature, and if
they are present, we promt user whether he wants to process with
conversion and lose i.e. filesystem present on such volume.

Users that want to bypass prompt in script can use either --yes
or they can disable wipe signature -Wn.
2024-05-10 01:15:55 +02:00
Zdenek Kabelac
edbc0ed447 man-generator: remove unused declarations 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
383d7c4413 cov: remove dead code 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
5818fbfbcf cov: enum matching type 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
5c7d6083a9 cov: annotate to silent some coverity warning 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
a07bf7b90b cov: wrap pvck call
Resolve reported leak by renaming existing pckk() to pvck_mf()
and wrapping pvck() over this. This function can easily
free allocated buffer within the subfunction.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
dae792baad cov: strcpy mempcy 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
0eb6a59299 const: report_name 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
9cf127b429 const: suffixes 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
6430a6ca63 const: _fns poll_function 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
e02695cb45 lvonvert: support control over wipingsignature
When converting volume to a thin-pool allow control over
signature wiping.

TODO: likely should become more commonly supported option...
2024-05-04 00:57:52 +02:00
Zdenek Kabelac
1f92fc2af7 lvcreate: --yes option for thin-pool vdo creation
Correct typo and accept proper --yes option instead
of misplaced --force option.
2024-05-04 00:56:32 +02:00
Zdenek Kabelac
a98f908c23 command: correct lvresize
Code for supporting size reduction of pool metadata is not yet present
so don't pretend the option can work as pushed in previous commit.
2024-05-02 13:18:08 +02:00
Zdenek Kabelac
1ab66f37ae command-lines: improve spec for thin snapshot
man-generate --check actually noticed 2 same definitions
for snapshot create  with 'lvreate -T [--snapshot]'
and 'lvcreate --snapshot [-T]'.
So drop the '-T' from second alternative variant as
thin type is already implied here.
2024-05-02 12:04:07 +02:00
Zdenek Kabelac
611975c51b use LVM_COMMAND_COUNT 2024-05-02 12:04:07 +02:00
Zdenek Kabelac
eeffc1d52b man-generator: code reformating 2024-05-02 12:04:07 +02:00
Zdenek Kabelac
b4670db008 command: refactor to use const command structure
Refactor code so the definitions may become 'static const'
and with configure_command_option_values() we update options
val_enum for actually running command option when used.

Also update _update_relative_opt() which is used for
generating man pages and command help.

Introduce enumeration for lvm2 commands - so we may
use enum cmd_COMMAND instead of string checking.

So running command now does not modified opt_names.
2024-05-02 12:01:06 +02:00