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

7271 Commits

Author SHA1 Message Date
Zdenek Kabelac
491ee5d106 cov: hide some messages
Living with these...
2023-07-12 15:18:38 +02:00
Zdenek Kabelac
857f5d6e65 lvconvert: correction for thin conversion
Updates for 39457234db.
Off-by-one for option array - need 20 fields.
Missed to clear lock_args for cachepool.
2023-07-12 15:18:38 +02:00
Zdenek Kabelac
00b5d7b037 lv: followup seg_monitor reporting
With 3596558861 it's been introduced
a more fine grained description.
However 'disabled' might be actually more confusing then empty field,
so keep only the info about 'not enabled'aka dmevend is not allowed
to monitor LV which otherwise could be monitored.
2023-07-10 17:13:33 +02:00
Zdenek Kabelac
39457234db lvconvert: support conversion to thin volume
Update pool conversion function to handle also conversion of
thick LV to thin LV by moving thick LV into thin pool data LV
and creating fully provissioned thin LV on top of this volume.

Reworking existing conversion to use insert_layer_for_lv co
the uuid is now kept with thin-pool - this should however not
really matter as we are doing full deactivation & activation cycle.

With conversion to thin LV user can use same set of arguments
to set chunk-size.

TODO: add some smart code to decide best values for chunks sizes.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
f35fa8c178 cleanup: typos 2023-07-10 17:13:32 +02:00
Zdenek Kabelac
96123b9059 cleanup: use spelling synchronize
Use single spelling form for synchronize.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
077b46e014 lv_manip: fix move_lv_segments moved bits
For proper functionality of insert_layer_for_lv we need to
move more bits to layerd LV.

Add some missing new types and correct usage of caller,
so the new LV type is set after the movement.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
e022805f1d pool: do not pass empty string in callback
When preparing cmdline to executing dmpd tool, avoid adding
empty string ("") on such line.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
e36028b7d2 cache: update validation rules
Validate cache origin in front of the prompt.
Also add some rules to command description file.

TODO:
more validation needed also for lvcreate,
more complex rules with "OR" seems to be needed.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
9bbbc1b265 cachepool: skip wipe for nonzeroeable segments
Avoid activation when going to skip zeroing of 'error' segtype
(so it's not erroring out).
Also skip zeroing for 'zero' segtype LV (already being zero).
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
558890ad0e pool: support passing data_lv for recalculation
Support data_lv to be passed as parameter when it's not yet
attached to the pool.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
d43a79eec9 segtype: add missing macros for error and zero segment
Add macros for checking error and zero segment as we do
with other segtypes.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
5154054af4 snapshot: no error when extending above max size
When lvm2 calculates the maximal usable COW size and crops the user
requested size to this value, don't return the error result from
the 'lvextend' operation.

We already apply the same logic when resizing thin-pool beyond
the supported maximal size.

FIXME: The return code error logic here is somewhat fuzzy.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
e84b00964f pool: avoid using artificial name internally 2023-06-29 13:55:27 +02:00
Zdenek Kabelac
3596558861 lv: more details about monitoring lvs
Show "not supported" when LV does not support dmeventd monitoring.
Show "disabled" for LV with disabled dmeventd monitoring.
(lvdisplay -m)
2023-06-29 13:10:42 +02:00
Zdenek Kabelac
e48c9826e3 vdo: indent for lvdisplay 2023-06-29 13:10:42 +02:00
Zdenek Kabelac
6ff65e6755 vdo: check_point_frequence is unused option
This vdo parameter existed in the early stage of integration of vdo into lvm2,
but later it's been removed from vdoformat tool - so actually if
there would be any non-zero value it would cause error on lvcreate.
Option was not stored on disk in lvm2 metadata.

Remove this vdo parameter from lvm2 sources.

(Although this vdo parameter will be still accepted on cmdline through
 --vdosettings option, but it will be ignored.)
2023-06-29 13:10:42 +02:00
Zdenek Kabelac
46fe47b8e0 debug: add backtraces 2023-06-23 18:08:03 +02:00
Zdenek Kabelac
fec3087eef thin: add cfg support for thin_restore and cache_restore
Add configurable paths for thin_restore and cache_restore.
2023-06-23 18:06:22 +02:00
David Teigland
7c3eca833f lvresize: fix multiple mounts
which was mistaken as a mounted LV that had been renamed.
2023-06-16 12:11:51 -05:00
David Teigland
228a8e8c1f device_id: ignore leading and trailing spaces for sys_wwid and sys_serial
Leading and trailing underscores are also ignored to handle device ids
written by previous versions which replaced all spaces with underscores.
2023-06-15 15:17:14 -05:00
Zdenek Kabelac
fcf2057b38 cmd_enum: correct inclusion
Ensure we use generated header file for this build from -Iinclude.

Reported-by: Anton Lundin <glance@ac2.se>
2023-06-09 18:01:16 +02:00
David Teigland
74feebdab7 device_id: fix handling of non-PV with duplicate serial number
Fix in the code that matches devices to system.devices entries when
the devices have the same serial number.  A non-PV device in
system.devices has no pvid value, and the code was segfaulting
when checking the null pvid value.
2023-06-08 12:24:05 -05:00
David Teigland
0591131a53 lvreduce: simplify _lvseg_get_stripes integrity check
Simplify unnecessary loop to avoid coverity complaint.
2023-05-25 12:09:41 -05:00
David Teigland
4cdb178968 device_id: ignore trailing underscores in t10 wwid from devices file
In previous lvm versions, trailing spaces at the end of a t10 wwid would
be replaced with underscores, so the IDNAME string in system.devices
would look something like "t10.123_".  Current versions of lvm ignore
trailing spaces in a t10 wwid, so the IDNAME string used would be
"t10.123".  The different values would cause lvm to not recognize a
device in system.devices with the trailing _.  Fix this by ignoring
trailing underscores in the IDNAME string from system.devices.
2023-05-19 14:05:10 -05:00
David Teigland
24e4b6df11 tests: integrity-caching: ensure raid redundancy
The recent fix 05c2b10c5d ensures that raid LV images are not
using the same devices.  This was happening in the lvextend commands
used by this test, so fix the test to use more devices to ensue
redundancy.
2023-05-17 14:15:25 -05:00
David Teigland
fd6e113bba raidintegrity: allow snapshots 2023-05-11 11:02:52 -05:00
heinzm
05c2b10c5d Fix "multisegment RAID1, allocator uses one disk for both legs"
In case of e.g. 3 PVs, creating or extending a RaidLV causes SubLV
collocation thus putting segments of diffent rimage (and potentially
larger rmeta) SubLVs onto the same PV.  For redundant RaidLVs this'll
compromise redundancy.  Fix by detecting such bogus allocation on
lvcreate/lvextend and reject the request.
2023-05-10 18:35:21 +02:00
Zdenek Kabelac
cc7c41abbd cov: remove unneeded header file inclusion 2023-05-10 15:27:48 +02:00
Zdenek Kabelac
7b52a663a6 cov: validate dev_get_primary_dev result
Make sure primary_dev is defined when using it.
2023-05-10 15:27:48 +02:00
Zdenek Kabelac
534269d0fb vdo: document feature option 2023-05-06 20:38:57 +02:00
Zdenek Kabelac
f038fc3b17 cov: remove unused but set variables 2023-05-06 20:38:57 +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
Zdenek Kabelac
39b2bd06b8 cov: some initializers 2023-05-06 19:22:05 +02:00
Zdenek Kabelac
4fd2f433ad cov: hide problem with 64bit time_t 2023-05-06 19:22:05 +02:00
Zdenek Kabelac
242bf56413 cov: validata top_lv
Add explicit pointer check is never NULL.
2023-05-06 19:22:05 +02:00
Zdenek Kabelac
662020c221 cov: simplier code
Avoid coverity to contruct some abstract scenarions of 'cft'
modification and simplify the code at the same time.
2023-05-06 19:22:05 +02:00
heinzm
d7e922480e Fix "lvconvert -m 0 will always take rimage_0 even if it is out-of-sync"
Bail out in case first rimage is out-of-sync.
Refresh first, i.e. "lvchange --resync $RaidLV",
then retry downgrade to linear after resynchronization.
2023-05-05 20:51:58 +02:00
David Teigland
368381fd40 lvreduce: make _lvseg_get_stripes handle integrity layer
lvreduce uses _lvseg_get_stripes() which was unable to get raid stripe
info with an integrity layer present.  This caused lvreduce on a
raid+integrity LV to fail prematurely when checking stripe parameters.
An unhelpful error message about stripe size would be printed.
2023-05-03 11:34:59 -05:00
David Teigland
6d262eaf64 lvmcache: fix valgrind error when dropping md duplicate
When lvmcache info is dropped because it's an md component,
then the lvmcache vginfo can also be dropped, but the list
iterator was still using the list head in vginfo, so break
from the loop earlier to avoid it.
2023-04-25 14:46:36 -05:00
Zdenek Kabelac
8947964f10 wipe_lv: use zeroing ioctl only for large sizes
There is no easy way to detect, whether device supports zeroing,
and kernel also zeroes device when it's not directly supported,
but with extra message:

operation not supported error, dev X, sector Y op 0x9:(WRITE_ZEROES)...

So to avoid generating such message with every 'lvcreate', use for
zeroing of upto 8K just standard write of zeroed page.
(maybe we can go with even larger sizes).
2023-04-25 00:12:31 +02:00
David Teigland
31cfcf7ce9 fix dev_name use in add_areas_line
This function was relying on dev_name() returning NULL
to indicate no device, but dev_name never returns NULL.
2023-04-24 15:49:00 -05:00
David Teigland
317071ec53 cache: fix snapshot of cache with cachevol
Creating a snapshot of a cache LV with a cachevol would fail
because cache_check was not being skipped.
2023-04-10 12:44:22 -05:00
David Teigland
8458ff9ad1 remove extra change from support 16KB page size 2023-04-07 15:57:28 -05:00
David Teigland
b443eac6ef support 16KB page size 2023-04-07 14:26:09 -05:00
Zdenek Kabelac
e8e6347ba3 vdo: use fixed size vdopool wrapper
Instead of using size of 'empty header' in vdopool use fixed size 4K
for a 'wrappeing' vdo-pool device.

This fixes the issue when user tried to activate vdo-pool after
a conversion from vdo managed device with 'vgchange -ay' - where
this command activated all LVs with 'vdo-pool' wrapping device as well,
but this converted pool uses  0-length header.

This 4k size should usually prevent other tools like 'blkid' recognize
such device as anything - so it shouldn't cause any problems with
duplicate indentification of devices.
2023-04-06 11:06:04 +02:00
Zdenek Kabelac
334117ee00 cleanup: rename function
Rename _thin_lv_has_device_id and use common function naming
with _lv_has_thin_device_id().
2023-04-06 11:06:04 +02:00
Zdenek Kabelac
1fb3e08033 cleanup: simplify 2023-04-06 11:06:04 +02:00
Zdenek Kabelac
51117b5793 integrity: hide creation of internal LVs
Creation of 'hidden' local LVs should be visible only in
verbose mode (-v) when creating a raid LV with integrity.
2023-04-06 11:06:04 +02:00
David Teigland
390ff5be2f raidintegrity: allow writecache and cache
Allow writecache|cache over raid+integrity LV.
2023-04-05 14:24:07 -05:00
David Teigland
69ea2e3f94 vg_read: keep MISSING_PV when device with no mda reappears
Remove old code that became incorrect at some point.
It's probably a fragment of an old condition that was left
behind because it wasn't understood.  We don't want to drop
the MISSING_PV flag just because the PV has no mda in use.
The device that was missing may have stale data, so the user
needs to decide if the device should be removed or restored.
2023-03-08 16:31:28 -06:00
David Teigland
1857eb9fe0 lvresize: fix check for mounted and renamed LV to handle spaces
Replace spaces with \040 in directory paths from getmntent (mtab).

The recent commit 5374a44c57 compares mount point directory paths
from /etc/mtab and /proc/mounts, in order to detect when a mounted
LV has been renamed.  The directory path comparison does not work
correctly when the path contains spaces because getmntent uses
ascii space chars and proc replaces spaces with \040.
2023-02-23 16:55:36 -06:00
Zdenek Kabelac
7bc5c8ac3d cov: avoid using strcpy
Coverity is complaining about unchecked strcpy here, which is
irelevant as we preallocate buffer to fit in copied string,
however we could actually reuse these size and use just memcpy().
So lets make some simple conversions.
2023-02-17 00:00:04 +01: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
Zdenek Kabelac
cf0dc9a13c filesystem: use PATH_MAX for linux paths 2023-02-12 23:56:29 +01:00
Zdenek Kabelac
631762d6db metadata-exported.h: correcting definition
Fixing minor mismatch between definition and declaration of
update_thin_pool_params().
2023-02-10 17:50:27 +01:00
Zdenek Kabelac
e3534d0f68 lvm: fix typos
Patch aec5e573af was fixing some
of typos only in generated file, but they need to be fixed in
the source files.
2023-02-10 17:50:27 +01:00
David Teigland
dc99f0def1 device_id: ignore quotes in device id
A t10 wwid string was found containing a " character
which breaks vg metadata parsing.  Ignore any quotation
marks in device id strings.
2023-02-06 12:24:18 -06:00
David Teigland
57ad78d436 vg_read: remove unused code for md components
This code was no longer used after ommit
87ee401eea
2023-02-02 16:15:13 -06:00
Zdenek Kabelac
f89c369a01 archive: update message
Better suggesting message as suggested by RHBZ 2123151.
2023-02-01 11:47:30 +01:00
David Teigland
6d14144d31 pvscan: recognize "pci" as a common symlink component in filters
In case the filter strings don't include "/dev/disk", and only
include "pci".
2023-01-31 15:30:35 -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
David Teigland
17a3585cbb pvscan: use alternate device names from DEVLINKS to check filter
pvscan --cache <dev> is called by our udev rule at a time when all
the symlinks for <dev> may not be created yet (by other udev rules.)
The regex filter in lvm.conf may refer to <dev> using a symlink name
that hasn't yet been created, which would cause <dev> to not match
the filter regex.  The DEVLINKS env var, set by udev, contains all
the symlink names for <dev> that have been or will be created.
So, we add all these symlink names to dev->aliases, as if we had
found them in /dev.  This allows <dev> to be recognized by a regex
filter containing a symlink for <dev>.
2023-01-31 15:30:35 -06:00
David Teigland
d9f8acb65a lvresize: fail early if crypt device is missing
If extending an LV with crypto_LUKS on it, and the crypt device
is missing, then fail the command before extending the LV.
2023-01-30 17:12:11 -06:00
David Teigland
5374a44c57 lvresize: fail early if mounted LV was renamed
If a mounted LV is renamed, then fs resizing utilities will fail,
so detect this condition and fail the command before any changes
are made.
2023-01-26 14:02:20 -06:00
David Teigland
8adfcddc35 Revert "lvresize: enable crypt resizing with --force"
It looks like force was not being used to enable crypt resize,
but rather to force an inconsistency between LV and crypt
sizes, so this is either not needed or force in this case
should have some other meaning.

This reverts commit ed808a9b54.
2023-01-25 10:10:57 -06:00
David Teigland
ed808a9b54 lvresize: enable crypt resizing with --force
Update previous commit
  "lvresize: only resize crypt when fs resize is enabled"
to enable crypt resizing when --force is set and --resizefs
is not set.  This is because it's been allowed in the past
and people have used it, but it's not a good idea.
2023-01-20 12:04:55 -06:00
David Teigland
3bb5576528 lvresize: only resize crypt when fs resize is enabled
There were a couple of cases where lvresize, without --fs resize,
was resizing the crypt layer above the LV.  Resizing the crypt
layer should only be done when fs resizing is enabled (even if the
fs is already small enough due to being independently reduced.)

Also, check the size of the crypt device to see if it's already
been reduced independently, and skip the cryptsetup resize if
it's not needed.
2023-01-19 11:52:14 -06:00
Zdenek Kabelac
c20f01a0cb vdo: resize requires active vdopool volume
ATM kernel VDO target does not handle resize of inactive VDO LVs
so prevent users corrupting such LVs and require active such LVs.
2023-01-16 12:37:40 +01:00
Zdenek Kabelac
2451bc568f vdo: fix and enhance vdo constain checking
Enhance checking vdo constains so it also handles changes of active VDO LVs
where only added difference is considered now.

For this also the reported informational message about used memory
was improved to only list consuming RAM blocks.
2023-01-16 12:37:40 +01:00
Zdenek Kabelac
1bed2cafe8 vdo: read live vdo size configuration
Introduce struct vdo_pool_size_config usable to calculate necessary
memory size for active VDO volume.

Function lv_vdo_pool_size_config() is able to read out this
configuration out of runtime DM table line.
2023-01-16 12:37:40 +01:00
Zdenek Kabelac
773b88e028 vdo: check memory only in non critical section
When we are actually resizing VDO device - we need to check size only in
non-critical section - otherwise we are checking
2023-01-16 12:37:38 +01:00
Zdenek Kabelac
f486eb60d5 lvresize: use standard extent conversion function
We need to validate whether the requested resizing size can be
expressed with given extent_size.
2023-01-16 12:35:00 +01:00
lilinjie
bb34ebd4e4 fix typo
Signed-off-by: lilinjie <lilinjie@uniontech.com>
(cherry picked from commit 81b1f5bc3bac0e2e9099b67162da7d1a4995c5f4)
2023-01-11 13:52:12 +01:00
Marian Csontos
2ab81a3513 lvmlockd: Fix syntax error in previous commit 2023-01-11 13:34:38 +01:00
David Teigland
7c9c3ba5d5 lvmlockd: fix report of lv_active_exclusively for special lv types
Cover a case missed by the recent commit e0ea0706d
"report: query lvmlockd for lv_active_exclusively"

Fix the lv_active_exclusively value reported for thin LVs.
It's the thin pool that is locked in lvmlockd, and the thin
LV state was mistakenly being queried and not found.

Certain LV types like thin can only be activated exclusively, so
always report lv_active_exclusively true for these when active.
2023-01-10 15:37:15 -06:00
Zdenek Kabelac
44a2f2df92 cov: remove unused header files 2022-12-20 15:04:36 +01:00
David Teigland
4baef0f93f lvextend: fix overprovisioning check for thin lvs
18722dfdf4 lvresize: restructure code
mistakenly changed the overprovisioning check from applying
to all lv_is_thin_type lvs to only lv_is_thin_pool lvs, so
it no longer applied when extending thin lvs.  The result
was missing warning messages when extending thin lvs.
2022-12-15 10:00:17 -06:00
David Teigland
fa7fe5cbbe writecache: support settings metadata_only and pause_writeback
Two new settings for tuning dm-writecache.
2022-12-08 16:53:36 -06:00
David Teigland
6613a61d3b device_id: fix segfault verifying serial for non-pv
The recent change that verifies sys_serial system.devices entries
using the PVID did not exclude non-PV devices from being checked.
The verification code would attempt to use du->pvid which was null
for the non-PVs causing a segfault.
2022-12-02 12:25:10 -06:00
David Teigland
a74468116e device_id: check return value of label_read_pvid
for covscan
2022-12-01 11:49:51 -06:00
David Teigland
e71b434663 device_id: _get_devs_with_serial_numbers add missing free
on malloc failure path
2022-12-01 11:43:24 -06:00
David Teigland
7552ed9010 device_id: add null id->name null check
for covscan
2022-12-01 10:38:48 -06:00
David Teigland
f80273a107 lvmcache: fix strncpy len for wwid 2022-12-01 10:03:06 -06:00
corubba
e0ea0706dc report: query lvmlockd for lv_active_exclusively
Query LV lock state in lvmlockd to report lv_active_exclusively
for active LVs in a shared VGs.  As with all lvmlockd state,
it is from the perspective of the local node.

Signed-off-by: corubba <corubba@gmx.de>
2022-11-11 13:30:25 -06:00
corubba
779fc3c045 report: adjust lv_active_remotely for shared VGs
Add a note to the manpage that lvmlockd is unable to determine
accurately and without side-effects whether a LV is remotely active.
Also change the value of the lv_active_remotely option from false to
undefined for shared VGs to distinctly communicate that inability to
users. Only for local VGs it can be definitely stated that they are not
remotely active.

Signed-off-by: corubba <corubba@gmx.de>
2022-11-11 12:08:59 -06:00
David Teigland
c98617c593 devices: factor common list functions
which were duplicated in various places
2022-11-07 11:38:46 -06:00
David Teigland
761b922178 device_id: handle duplicate serial numbers
Handle multiple devices using the same serial number as
their device id.  After matching devices to devices file
entries, if there is a discrepency between the ondisk PVID
and the devices file PVID, then rematch devices to
devices file entries using PVID, looking at all disks
on the system with the same serial number.
2022-11-07 08:56:02 -06:00
David Teigland
bdab36cf3f device_id: look for serial number in other locations
Only /sys/dev/block/major:minor/device/serial was read to find
a disk serial number, but a serial number seems to be reported
more often in other locations, so check these also:
/sys/dev/block/major:minor/device/vpd_pg80
/sys/class/block/vda/serial (for virtio disks only)
2022-11-07 08:56:02 -06:00
Zdenek Kabelac
2e79b005c2 dev_manager: accept misalined vdo pools.
Since lvm2 may create VDO pool virtual size aligned only on extent size
while VDO itself is just 4K aligned - we need to support such misalign.
2022-11-02 13:59:34 +01:00
David Teigland
f188c9e403 device_id: remove debug trace
for common case where a device id type is not used.
2022-10-24 16:20:28 -05:00
David Teigland
830ece75e8 cmd: save device_id_sysfs_dir
read and save device_id_sysfs_dir to avoid spamming
debug output from find_config_tree_str.
2022-10-24 16:20:28 -05:00
Tony Asleson
0f56c1ad12 lvmnotify.c: Check to see if dbus daemon is running
The lvm dbus daemon will auto activate on dbus API calls.  To
prevent the dbus daemon starting when lvm command line tools are
being used we will check to see if the daemon is running first.
If the daemon is not running, we will not notify the daemon.

For this check to work it requires the changes done previously
with commit: 3fdf449348

Reviewed-by: David Teigland <teigland@redhat.com>
2022-10-19 14:22:12 -05:00
David Teigland
04097d9f62 lvreduce: change error message about --fs options 2022-10-12 10:05:14 -05:00
corubba
4f4554164b lvmlockd: Fix sanlock lvmlock lv size calculation
The number of extents for the sanlock lvmlock lv is calculated using
integer division, which rounds towards zero. With a physical extent size
of 129M, instead of the requested 256M the lv is only 129M (1 extent).
With any physical extent size greater than 256M the lv creation fails
because the number of extents is zero.

This is fixed by replacing the integer division with a division macro
that rounds up and thus guarantees that the size of the lv will always
be equal or greater than the requested size. Using the examples above, a
pes of 129M will result in a 258M lv (2 extents), pes of 300M in a 300M
lv (1 extent).

The re-calculation of the lv size in bytes and megabytes is only so the
debug output shows the correct values. The size in mb there is still
not byte-perfect-accurate, but good enough for a human-readable estimate;
and the exact size in bytes and extents is right next to it.

Signed-off-by: corubba <corubba@gmx.de>
2022-10-12 09:19:01 -05:00
Peter Rajnoha
908555459f toollib: do not process just created historical LV
When executing process_each_lv_in_vg, we process live LVs first and
after that, we process any historical LVs. In case we have just removed
an LV, which also means we have just made it "historical" and so it
appears as fresh item in vg->historical_lvs list, we have to skip it
when we get to processing historical LVs inside the same process_each_lv_in_vg
call.

The simplest approach here, without introducing another LV list, is to
simply mark such historical LVs as "fresh" directly in struct
historical_logical_volume when we have just removed the original LV
and created the historical LV for it. Then, we just need to check the
flag when processing historical LVs and skip it if it is "fresh".

When we read historical LVs out of metadata, they are marked as
"not fresh" and so they can be processed as usual.

This was mainly an issue in conjuction with -S|--select use:

	#  lvmconfig --type diff
	metadata {
		record_lvs_history=1
	}

(In this example, a thin pool with lvol1 thin LV and lvol2 and lvol3 snapshots.)

	#  lvs -H vg -o name,pool_lv,full_ancestors,full_descendants
	  LV    Pool FAncestors  FDescendants
	  lvol1 pool             lvol2,lvol3
	  lvol2 pool lvol1       lvol3
	  lvol3 pool lvol2,lvol1
	  pool

	#  lvremove -S 'name=lvol2'
	  Logical volume "lvol2" successfully removed.
	  Historical logical volume "lvol2" successfully removed.

...here, the historical LV lvol2 should not have been removed because
we have just removed its original non-historical lvol2 and the fresh
historical lvol2 must not be included in the same processing spree.
2022-10-12 15:14:59 +02:00
David Teigland
f6f2737015 lvreduce: require active LV when no fs option is used
Without an --fs option set, make lvreduce of an inactive LV
fail and report that the LV must be active.
2022-10-11 12:48:31 -05:00
David Teigland
13c63f0cfa lvmdevices: use deviceidtype option strictly
Only use the device id type specified by --deviceidtype,
and fail if that type is not available for the device.
2022-10-10 11:47:29 -05:00
David Teigland
79e67fc5e4 device id: add new types using values from vpd_pg83
The new device_id types are: wwid_naa, wwid_eui, wwid_t10.
The new types use the specific wwid type in their name.
lvm currently gets the values for these types by reading
the device's vpd_pg83 sysfs file (this could change in the
future if better methods become available for reading the
values.)

If a device is added to the devices file using one of these
types, prior versions of lvm will not recognize the types
and will be unable to use the devices.

When adding a new device, lvm continues to first use sys_wwid
from the sysfs wwid file.  If the device has no sysfs wwid file,
lvm now attempts to use one of the new types from vpd_pg83.

If a devices file entry with type sys_wwid does not match a
given device's sysfs wwid file, the sys_wwid value will also
be compared to that device's other wwids from its vpd_pg83 file.
If the kernel changes the wwid type reported from the sysfs
wwid file, e.g. from a device's t10 id to its naa id, then lvm
should still be able to match it correctly using the vpd_pg83
data which will include both ids.
2022-10-10 11:47:29 -05:00
David Teigland
8de87e0207 device id: change space handling in t10 wwid
t10 wwids are now edited in the same way that multipath does,
which is replacing a series of spaces with one _.  Previously
lvm replaced every space with one _.  Devices file entries
with the old form will be converted to the new shorter form.
2022-10-10 11:47:29 -05:00