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

4503 Commits

Author SHA1 Message Date
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
Zdenek Kabelac
0b064aedb3 command: embedding strings to structs
Since we will make these struct const, we can also
embedding string content into them to avoid unnecessary
pointer relocations.
2024-05-02 11:59:42 +02:00
Zdenek Kabelac
6f8abdc978 cleanup: tab indent and typo 2024-05-02 11:58:26 +02:00
Zdenek Kabelac
c35385a1cd cleanup: drop double _ 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
26cbd4057a lvmcmdline: code update 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
e654b9cba9 command: more arrays keep static 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
45d9b2c470 command: more static const declaration
Use static const for declared arrays.
Access to arrays through get_ functions().
2024-04-29 00:13:43 +02:00
Zdenek Kabelac
d2f953c9db command: use const declaration for arrays 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
063910c54b command: refactor common code to command_enum.h
Move shared code to command_enum.h and avoid duplicating code.
2024-04-29 00:13:43 +02:00
Zdenek Kabelac
f453665f92 lvchange: constify option array 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
cd69d58fcd command: using single printf call
Use single string for 1 printf() call with \t tabs.
2024-04-29 00:13:43 +02:00
Zdenek Kabelac
0316dd7955 command: refactor loop test for end of string 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
e1211d38a4 command: refactor test for relative opt
Use _update_relative_opt to check for relative option and
update val_enum accordingly.
2024-04-29 00:13:43 +02:00
Zdenek Kabelac
ee45cd8965 man-generator: some switch case refactoring 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
6ece8b74f0 command: split man-generator code
Move code for generating man pages to man-generator.c
which is no longer a symlink to command.c and just
includes this file for the common code.
2024-04-29 00:13:43 +02:00
Zdenek Kabelac
063ade474c command: refactor if condition 2024-04-29 00:13:43 +02:00
Zdenek Kabelac
ecabdf68cf lvconvert: use cmd_context variable
Do not modify flags field from 'strcut command_name' and
instead control this via cmd_context  get_vgname_from_options.

Flag GET_VGNAME_FROM_OPTIONS is currently used only by lvconvert.
2024-04-29 00:13:43 +02:00
Zdenek Kabelac
38cc021d67 cmdlines: use OO_LVCREATE_RAID
Common options in one OO_
2024-04-26 21:37:52 +02:00
Zdenek Kabelac
41e0a93a8f cmdlines: simplify OO_LVCONVER/LVCREATE_THINPOOL
OO_LVCONVERT_THINPOOL always constains OO_LVCONVERT_POOL
OO_LVCREATE_THINPOOL always contains OO_LVCREATE_POOL

More readable description.
2024-04-26 21:37:51 +02:00
Zdenek Kabelac
57ab219d9b cov: validation
Add internal error for missing vg.
2024-04-26 00:13:34 +02:00
Zdenek Kabelac
f022da9e5f configure.ac: leave LDFLAGS resolving on make time
Use LDFLAGS separately with every use of CLDFLAGS and leave
this flag only for handling versioning.

This will reflect any LDFLAGS setting use during make.
2024-04-24 00:30:05 +02:00
David Teigland
f4911177da lvcreate: allow raidintegrity option with implicit raid type
Allow "lvcreate -m1 --raidintegrity y" when raid1 is used, but
not explicit on the command line.
2024-04-17 13:40:33 -05:00
Zdenek Kabelac
485a1961e8 clang: implicit conversion from 'long' to 'double'
implicit conversion from 'long' to 'double' changes value
from 9223372036854775807 to 9223372036854775808.

So rather compare same integer types.
2024-04-16 01:10:03 +02:00
Zdenek Kabelac
79cdfc8ca6 libdaemon: implement daemon_close_stray_fds
Refactor existing code from tools/lvmcmdline.c to
libdaemon/server/daemon-stray.h daemon_close_stray_fds()
used to close stray descriptors above some specified Fd.

This is code parses content of /proc dir to minimize 'blind' closing
of all possible descriptors within rlimits range.

As we have the same code in few other places in it's more 'trivial'
version - these were actually sensitive to high amount of descriptors,
which might be configured on some system.

With this patch we effectively resolve this reported gitlab issue:
https://gitlab.com/lvmteam/lvm2/-/issues/5

TODO: Current placement might not be ideal - however considering
existing code base constrains it's not so simple.
ATM it uses lib/misc/lvm-file.h  for custom_fds declaration
and rest of functinality is included in daemon header file.
2024-04-15 13:38:44 +02:00
Zdenek Kabelac
ecb8399005 lvm: use configure proc dir in lvm.conf
Update some code parts to use configurer /proc from lvm.conf
(so i.e. our testing can use some fake values)
2024-04-15 13:38:44 +02:00
Zdenek Kabelac
2a8c195360 cov: use dm_strncpy variant 2024-04-10 00:03:09 +02:00
Zdenek Kabelac
e7a54c1a50 cov: use safer version with size limitation
Although there is likely not much risk of having chance of overwritting
given buffers use safer variant.
Use dm_strncpy() when just copying %s.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
3ce83f923d cov: extra pointer validation
Add few more internal errors to enusure there is no use of NULL pointers
along the code path.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
f27388b5d8 toolib: skip when there is no vg and error_vg
We must skip even if the skip would be suggesting otherwise
if there is no vg and no error_vg as there is nothing to process.
2024-04-09 17:47:55 +02:00
Zdenek Kabelac
9dad6f202c reporter: correcting failure return value
This function do use ECMD_ return values,
so use ECMD_FAILED as initial value - used for internal error paths
2024-04-09 17:43:23 +02:00
Zdenek Kabelac
88ad83e3d6 makefiles: use SHOW 2024-04-08 14:52:23 +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
fa81c7561f cov: missing initializer
Ensure there is no code path with uninitialized takes_arg.
2024-04-04 19:33:58 +02:00
David Teigland
6d6e8d69eb lvmdevices: fix memleak of use_old du
missed in the the prev done_old commit
2024-04-03 15:29:17 -05:00
Zdenek Kabelac
6172db5326 lvmdevices: fix memleak of done_old du
'done_old' list missed released.
2024-03-30 00:17:07 +01:00
Zdenek Kabelac
ee496f2846 cov: validate major and minor
Check  major and minor is >= 0.
2024-03-29 01:36:48 +01:00
Zdenek Kabelac
fef49a0e86 cov: remove unnecessary sanity check
This sanity check actually confused in some way Coverity
giving it some assumption about array access.

Since these two checks basically validated compiler's capability
to add and then substract the number from char pointer we likely
don't really need them - as if this base math would not work,
compiler would be having far more troubles...

So drop them - and get rid of report:
Event overrun-call: Overrunning callee's array of size 513 by...
2024-03-29 01:34:22 +01:00
Zdenek Kabelac
4ba683bb18 debug: update some structure members
Makes pahole output look slightly better.
2024-03-28 18:18:37 +01:00
Zdenek Kabelac
f1e80f3be0 commands: reduce command structure size more
Check for internal limits, if they would ever need to be raised report
error message and fail parsing.
2024-03-28 18:18:37 +01:00
Zdenek Kabelac
8965fd18aa cov: ensure buffer always ends with nul
When we print anything out of buffer, ensure there is \0.
2024-03-28 18:18:37 +01:00
Zdenek Kabelac
4a69bacc20 gcc: use uint16_t for counters 2024-03-27 01:11:00 +01:00
Zdenek Kabelac
0dbd90d74e gcc: match signed integers 2024-03-27 01:11:00 +01:00
Zdenek Kabelac
c4b1bfa5f0 cov: use proper enum value 2024-03-25 17:17:24 +01:00
Zdenek Kabelac
4abdc5981a cov: validate return from display_lvname
Ensure strdup will not get NULL.
2024-03-25 16:59:27 +01:00
Zdenek Kabelac
4f1d89d37f cov: validate origin pointer
Add internal error for NULL origin here.
2024-03-25 16:57:53 +01:00
Zdenek Kabelac
e36c6a31e6 commands: refactor memset
Move memset() to the initialization function define_commands().

There is also not much point in clearing memory on command's exit
so drop zeroing of ~2M of RAM.
2024-03-25 11:05:05 +01:00
Zdenek Kabelac
e450ad287e commands: reduce structure sizes
Reduce slightly RAM usage of running lvm2 and use smaller fields
to count small numbers.
2024-03-25 11:05:05 +01:00
Zdenek Kabelac
b951f81db5 commands: use nul for EOL for compiled-in buffer
Use \0 as EOL in compiled-in syntax description to avoid
unnecessary line copy that just replaced \n with \0.
Also use already splitted lines when possible.
2024-03-25 11:05:05 +01:00
David Teigland
2fc66d2835 lvconvert: fix displayed lv name in convert to snapshot 2024-03-20 09:13:31 -05:00
Zdenek Kabelac
4b1664236b cmdline: some simple optimization
Some cheap parser init speedups cutting away some cpu cycles...
Use cheaper tests in if ( && )
Avoid unnecessary strchr calls.
2024-03-20 11:18:04 +01:00
Zdenek Kabelac
f93446486e makefiles: add missing cleanup targer 2024-03-19 20:08:01 +01:00
Zdenek Kabelac
3b9787d4ee lvconvert: enhance external origin conversion 2024-03-17 13:17:53 +01:00
Zdenek Kabelac
7ae9662b4e lv: swap more lv properties
When using swap_lv_identifiers() we were basiclly exchanging 'names'
and only according to the caller some more data were 'transfered'.

However in most cases we should swap properties like 'hostname' as
the creation information should be preserved.

So let's do the function more universal.
2024-03-17 13:17:53 +01:00
Zdenek Kabelac
27bdd038a8 thin: validate usable volume for external origin
When creating external origin via 'lvcreate --type thin'
add the validation for LV being usable as external origin
since certain LVs cannot be really used this way.
Also call this function early during lvcreate cmdline arg
validation se we do not need to do unecesary operation.
2024-03-16 10:40:54 +01:00
David Teigland
e59027e4f7 devices file: back up each version
Create backup copies of system.devices in /etc/lvm/devices/backup
named system.devices-YYYYMMDD.HHMMSS.NNNN.  NNNN is the version
counter from the file.

Each time that an lvm command writes a new system.devices file,
it also writes the same file in the backup directory.

A new comment line is added to system.devices with HASH=<num>
where <num> is a crc calculated from the uncommented lines in
system.devices.  This lets lvm detect if the file has been
modified outside of lvm itself.

If system.devices is edited directly, the next time a command
reads the file, the crc will not match the HASH value.  The
command will then rewrite system.devices with the correct HASH
value, and create a backup reflecting the edits.

A default limit of 50 backup files is kept, configurable by
lvm.conf devicesfile_backup_limit (set to 0 to disable backups.)
2024-02-15 11:40:37 -06:00
David Teigland
82f187ce88 man: fix typo in -A description 2024-02-05 12:13:44 -06:00
Zdenek Kabelac
9d9e43b87f vdo: correct vdo header size
Previous patch that introduced support for thinpool with vdo
not correctly handled header size - as this part is not fully usable
yet.  We are going to try to use the 0, but current state of code is not
yet compliant to this logic so keep vdo_header_size during conversion
and alos correctly pass through virtual_extents to vdo formating.
2024-01-17 17:30:10 +01:00
Zdenek Kabelac
4ad98540bc lvmcmdline: support --pooldatavdo
Extend definitions for lvcreate & lvconvert to support
new option  --pooldatavdo y|n  with thinpools.
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
db0de73d6e vdo: support creation of compressed thin-pools
Add code to handle creation of  thin-pool with VDO data backend
which can be seen as compressed deduplicated thin-pool.

To avoid need of changing to many internal APIs, pass the conversion
parameters for create thin-pool data volume via cmd_context.
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
6ec2f1f44b vdo: refactor conversion to vdo lv
Introduce struct vdo_convert_params {} to pass-in all the parameters
needed for the conversion of an LV to a vdopool + vdo LV.

Function convert_vdo_lv() is also able to create a new LV and swap
segments, so the passed in LV can be later on use for futher
conversion so this refactoring makes it ready for more enhanced
usage.
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
7544b9fc10 vdo: refactor vdo_params passing
Introduce vdo_convert_params and use vdo_params from this structure
also with lvcreate_params.

Later we will use this for convertion of thin-pool data volume to VDO.
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
4ccedceaa8 thin_pool: introduce --pooldatavdo
Introducing new arg --pooldatavdo y|n
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
c496f80379 pool: code refactoring
Move pool related manipulation code to pool_manip.c.
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
a176184b7d thin_pool: code refactoring
Move common code into thin_pool_set_params()
(just like we use  cache_set_params).
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
f3f7f5db89 cov: check for failing device_ids_read
TODO: not sure if here we should possibly exit from function.
2024-01-10 14:02:22 +01:00
Zdenek Kabelac
2770485737 cov: remove unneeded header 2024-01-10 14:02:22 +01:00
Zdenek Kabelac
a882878eba lvcreate: support vg profile for error_on_full 2024-01-10 14:02:22 +01:00
Heinz Mauelshagen
b69f73b13e raid: add messages to lvs command output in case RaidLVs require a refresh
If a RaidLV mapping is required to be refreshed as a result of temporarily failed
and recurred RAID leg device (pairs) caused by writes to the LV during failure,
the requirement is reported by volume health character r' in position 9 of the
LV's attribute field (see 'man lvs' about additional volume health characters).

As this character can be overlooked, this patch adds messages to the top
of the lvs command output informing the user explicitely about the fact.
2023-12-06 13:11:23 +01:00
David Teigland
d68c227aad man: update readonly description 2023-12-05 12:42:38 -06:00
Heinz Mauelshagen
f4edd87ffc raid: lvcreate and lvchange fail if --min_recovery_rate is defined
Fix typos in previous commit 3589e515d.

Both commands default [raid_](min|max)recoveryrate to 0 but ensure
min_recovery_rate is not larger than max_recoveryrate.  This results
in command failure without requesting the user to also define
max_recovery_rate >= min_recovery_rate.

Fix both commands by defining max_recovery_rate = min_recoveryrate
in case "lvcreate/lvchange --minrecoveryrate Size ..." requests a
larger value than current maxrecoveryrate without also giving option
2023-11-21 14:19:30 +01:00
Heinz Mauelshagen
3589e515dc raid: lvcreate and lvchange fail if --min_recovery_rate is defined
Both commands default [raid_](min|max)recoveryrate to 0 but ensure
min_recovery_rate is not larger than max_recoveryrate.  This results
in command failure without requestinng the user to also define
max_recovery_rate >= min_recovery_rate.

Fix both commands by defining max_recovery_rate = min_recoveryrate
in case "lvcreate/lvchange --minrecoveryrate Size ..." requests a
larger value than current maxrecoveryrate without also giving option
"--maxrecoveryrate Size ..." with a size greater or equal than min.
2023-11-20 17:14:01 +01:00
David Teigland
622284740a pvs, pvscan: new option -A to show PVs outside the devices file
pvs -A|--allpvs
	Show PVs that would otherwise be excluded by the devices file.

pvscan -A|--allpvs
	Show PVs that would otherwise be excluded by the devices file.
	For those devices that are included by the devices file,
	their device ID is displayed in place of the usual "lvm2"
	format and size.

(pvs -a|--all is unchanged, and shows devices not formatted as PVs.)
2023-11-16 08:45:46 -06:00
David Teigland
631b8edefb device_id: ensure pvid buffers are ID_LEN+1
A pvid string read from system.devices could be less
then ID_LEN since system.devices fields can be edited.
Ensure the pvid buffer is ID_LEN+1 even if the string
read from the file is shorter.
2023-11-09 13:15:02 -06:00
David Teigland
2b7c832847 lvmdevices: print changes for product_uuid or hostname
used by the recently added refresh feature
2023-11-07 14:30:48 -06:00
David Teigland
e38d974b50 lvmdevices: handle empty fields in new check and update
Expand the recent commit 37773c1055
"lvmdevices: new output and options for check and update"
to specifically cover entries with empty fields.
2023-11-03 15:28:26 -05:00
David Teigland
37773c1055 lvmdevices: new output and options for check and update
- add new comparison between old and new entries, and use this
  as the basis for new dedicated output for check and update
- add new --refresh option to search for missing PVIDs on all
  devices, and possibly update the device ID
- internally, only use the term "refresh" for cases where a
  new device ID may be found and assigned for a missing PVID
2023-11-02 11:46:31 -05: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
Zdenek Kabelac
493af2bb16 lvm: fix reporting path with HOME envvar
When envvar HOME is not present we were using invalid path with (null).
2023-10-17 16:49:23 +02:00
Zdenek Kabelac
afe1b2bef7 debug: initialize empty string 2023-10-14 01:04:10 +02:00
Adam Joseph
dc8837f079 configure.ac: handle --disable-shared flag
Since LVM 2.02 it appears that compiling LVM on a platform which
lacks a shared library linker/loader will fail to produce any
binaries (dmsetup, lvm2, etc).

Adds support for the standard --disable-shared flag, and
use it to disable attempts at building shared libraries.

Modified-by: zkabelac
2023-10-13 14:25:02 +02: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
Zdenek Kabelac
d7b4a4ce01 debug: stacktracing failure 2023-10-02 14:13:12 +02: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
e2f29c4989 pvmove: fix building sibling raid lv name
Make a local copy of the 'idx' string to avoid
overlapping during the rebuild of name.

This fixes cases where users specified raid
component LVs for moving.

Reported-by: kotarou3@github.com
2023-09-19 14:47:27 +02:00
Zdenek Kabelac
e75ac1b4c0 gcc: warning: missing braces around initializer
Fix warning emitted by some older gcc...
2023-09-13 13:38:15 +02:00
Zdenek Kabelac
b1b60887f0 debug: missing dots 2023-09-12 14:39:14 +02:00
Zdenek Kabelac
aa7f2ac954 lvconvert: thin conversion accept passed PVs
When creating thin pool or check pool there is allocated LV
for metadata and for such allocation user should be able to
specify list of PVs on cmdline.

Also fix unused passed list of PV for thick to thin conversion,
where the code was using whole PV set from a VG (but since it's
been not enabled on cmdline, user could not hit this issue).
Also remove unneeded initialization of use_pvh.
2023-09-03 22:03:33 +02:00
wangzhiqiang
65d23a1d75 vgchange: acquire an exclusive VG lock for refresh
Concurrent vgchange --refresh commands can lead to hung
tasks in dm code.

Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com>
2023-08-30 15:47:42 -05:00
Peter Rajnoha
14d0a9eef6
report: support printing full column names in report headings
Reuse existing report/headings config setting to make it possible to
change the type of headings to display:
  0 - no headings
  1 - column name abbreviations (default and original functionality)
  2 - full column names (column names are equal to exact names that
      -o|--options also accepts to set report output)

Also, add '--headings none|abbrev|full|0|1|2' command line option
so we are able to select the heading type for each LVM reporting
command directly.
2023-08-28 15:44:57 +02:00
Zdenek Kabelac
71ff21f57c gcc: initialize variables 2023-08-23 15:10:40 +02:00
Zdenek Kabelac
61499e870a debug: common error handling 2023-08-17 22:52:08 +02:00
Zdenek Kabelac
ba36ba8853 cleanup: move allocation code
Allocate new memory after validation passed.
2023-08-17 22:52:08 +02:00
Zdenek Kabelac
dde5b81079 lvconvert: run error path code only for shared VG
Error path for locking only for share VG.
2023-08-17 22:52:08 +02:00
Zdenek Kabelac
ad73f571b8 lvconvert: move _pmspare handling before conversion 2023-08-17 20:14:47 +02:00
David Teigland
6ca97e6e62 lvmlockd: fix lvconvert to thin-pool 2023-08-16 15:29:20 -05:00
David Teigland
696ee52ffd lvmlockd: let lockd_init_lv_args set lock_args
Set the lock_args string in addition to doing initialization.
lvconvert calls lockd_init_lv_args() directly, skipping
the normal lockd_init_lv() which usually sets lock_args.
2023-08-16 15:29:20 -05:00
David Teigland
096196281e lvmlockd: fix thick to thin lv conversion 2023-08-16 15:29:19 -05:00
Zdenek Kabelac
728617d25d gcc: cleanup warnings
Correcting signess comparation.
Also use standalone /* fall through */ comment as that's
the only one supported by gcc to quiet warning.
2023-08-16 15:13:25 +02:00
Zdenek Kabelac
085c3821a8 cleanup: no longer used
Previous commit made this var unused.
2023-08-16 15:13:00 +02:00
Zdenek Kabelac
54617805b8 lvconvert: use vg mempool
Keep allocation for a VG within vg memory pool.
2023-08-16 13:31:01 +02:00
Zdenek Kabelac
13225f1371 lvconvert: fix regresion from integrity check
Testing code sliped into commit and cause regression in testing for
a raid with integrity.
2023-08-16 11:25:54 +02:00
David Teigland
e548afd175 lvconvert swapmetadata: update lvmlockd locking for uuid exchange
lvmlockd locking for swapmetadata adjusted for commit
ac36153e99 lvconvert: preserve UUID for swapped metadata

Now that the LV uuid is swapped between LVs, the lvmlockd lock can
simply be moved between them, and the same lock can continue to be
used for the LV outside of the pool.
2023-08-15 13:13:06 -05:00
Zdenek Kabelac
ee6519f8e2 debug: use just single label 2023-08-14 17:02:11 +02:00
Zdenek Kabelac
741a166f3c debug: use common error exit path 2023-08-14 17:02:11 +02:00
Zdenek Kabelac
23019946c2 lvconvert: vdo needs writable LV 2023-08-14 17:02:11 +02:00
Zdenek Kabelac
2f3d8659b1 commands: add lv_is_writable 2023-08-14 17:02:11 +02:00
Zdenek Kabelac
0b7239ebc7 lvconvert: fix ret values fro integrity remove
Fix return value from _lvconvert_integrity_remove()
as it is expected to match _add() and be 0/1.

Also add some missing log_error() messages.
2023-08-14 17:02:11 +02:00
Zdenek Kabelac
80377eeb13 lvconvert: preserve UUID on pool repair
Once lvm2 repairs pool's metadata LV and preserves the original metadata LV
with unmodified metadata, for such LV in VG use newly created UUID for new
_pmspare and actually preserve UUID for this hidden _pmspare (if it
exists).
2023-08-14 17:02:11 +02:00
Zdenek Kabelac
ac36153e99 lvconvert: preserve UUID for swapped metadata
When swapping metadata LV for a pool volume, preserve UUID for metadata
LV during the swap - this allows to better utilise locks with lvmlockd.
2023-08-14 17:02:09 +02:00
David Teigland
2928891bd0 lvconvert swapmetadata: fix lvmlockd locking
The lockd lock needs to be freed for the LV that is becoming
the new metadata LV, and a new lockd lock needs to be created
for the old metadata LV that is becoming an independent LV.
Fixes b3e45219c2
2023-08-08 16:57:22 -05:00
David Teigland
7cc414135a lvmdevices: add --delnotfound to delete entries for missing devices
Used with update: lvmdevices --update --delnotfound.
Removes all devices file entries for which no matching device is found.
2023-07-24 14:56:32 -05:00
Zdenek Kabelac
09e17f99c5 cleanup: remove double //
dev_dir ends with /.
2023-07-17 12:44:23 +02:00
Zdenek Kabelac
d6771e513e lvconvert: code shuffle
Use cachepool name for create name for metadata backup LV.
(so we do not generate 2 'sequences' of metadata filenames.)
Move path preparion before handling _pmspare.
Also drop extra call to sync_local_dev_names() as it's
already got in sync with call of exec_cmd().
2023-07-17 12:44:23 +02:00
Zdenek Kabelac
f078ffc5e6 lvconvert: add support --setactivationskip
When repair thinpool or cachepool, lvm2 leaves original metadata
volume backup. To avoid potential damage of those data, mark such
volume as 'read-only' and also allow user to use --setactivationskip
option for this volume.

TODO: likely better default would be to automatically skip, but
that might need some more thinking about recovery reporting doc.
2023-07-17 12:44:23 +02:00
Zdenek Kabelac
d040b68aee lvconvert: use public LVs for recovery
Replace the use of internal /dev/mapper names with the use of
public LV names /dev/vg/lv for use with repair tools.
For this make the activation of _pmspare LV to be handled as
a component activation with public name.
Metadata is already atomatically activated this way (as readonly).

So if there is any 'error' happening, we leave public LVs in
system.
2023-07-17 12:44:23 +02:00
Zdenek Kabelac
4d2311655b lvm-exec: refactor code
Add prepare_exec_args() for reading option list for
thin/cache_repair, thin/cache_check.
2023-07-17 12:44:23 +02:00
Zdenek Kabelac
81ef1fd0cc debug: print WARNING:
Add WARNING: in front of log_warn() messages.
2023-07-15 11:05:35 +02:00
Zdenek Kabelac
b3e45219c2 lvconvert: hanle metadataswap with lvmlockd 2023-07-15 11:05:35 +02:00
Zdenek Kabelac
b89fc0564b cleanup: indent 2023-07-14 16:52:51 +02:00
Zdenek Kabelac
a2b2ae35b2 lvresize: improve usepolices
lvresize --usepolicy requires resized LVs to be active.
(So it's not only required for shared VG).

The test for active pool needs to use lv_info to query 'layer'
otherwise the pool is considered inactive if it was not activated
explicitely - thun 'implicit' activation with VDO or ThinLV was
not managed by --usepolicy option.
2023-07-14 16:52:51 +02:00
Zdenek Kabelac
8cbba1d164 lvmlockd: enable vdo conversion
As we turn 'already' active/locked LV into a data LV of vdopool,
we just keep active lock for such volume (uuid is preserved).
2023-07-14 16:52:51 +02:00
Zdenek Kabelac
8eb3a5b557 lvconvert: thin convert locking
Fix locking when converting thick to thin LV, ensure
we take pool lock for shared VG.
2023-07-14 16:51:46 +02:00
Zdenek Kabelac
93484c2a62 man-generator: ensure p is defined
In error path, p pointer could have been undefined.
2023-07-13 21:56:47 +02: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
64b28e0839 lvchange: add log_error for failure path
When change of monitoring fails, ensure there is log_error() printed.
2023-07-13 21:31:18 +02:00