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

7607 Commits

Author SHA1 Message Date
Zdenek Kabelac
cb87e184bc configure.ac: add support for libnvme
Add 2 new options for linking  libnvme with lvm2.
Option  --without-libnvme, --disable-nvme-wwid
2024-12-09 16:04:53 -06:00
David Teigland
d952358636 device_id: nvme devices may use alternate wwids
Device quirks may cause sysfs wwid file to change what it
displays, from a bogus eui... string to an nvme... string.

The old wwid may be saved in system.devices, so recognizing
the device requires finding the old value from libnvme.

After matching the old bogus value using libnvme, system.devices
is updated with the current sysfs wwid value.
2024-12-09 16:03:43 -06:00
Zdenek Kabelac
45344262cc debug: missing stack 2024-12-04 16:14:22 +01:00
Zdenek Kabelac
c2f41c1a59 raid: fix name rotation
Since we now keep lv names valid all the time (as they are part
of radix_tree) - there is a problem with this renaming code, that
for a moment used duplicated name in vg struct.

Fix it by interating LVs backwared - which avoids breaking consitency
and also actually makes code more simple.
2024-11-13 13:00:42 +01:00
Zdenek Kabelac
e4b5f8a485 debug: remove unused define 2024-11-08 19:41:50 +01:00
Peter Rajnoha
1d8a4c4817
lv_manip: use the same param validation for RAID 0 as for RAID 1/4/5/6
This actually reverts commit 83ae675f8d.
2024-11-07 07:57:34 +01:00
Peter Rajnoha
b5249fa3c2
lv_manip: fix stripe count and size validation for RAID LVs
Fix stripe count and size parameter validation for RAID LVs and
include existing automatic setting of these parameters based
on current shape of the RAID LV in case these are not set
on command line fully.

Previously, this was done only to a certain subset given by this
condition (where the 'stripes' is the '-i|--stripes' cmd line arg
and  the 'stripe_size' is actually the '-I|--stripesize' cmd line arg):

  !(stripes == 1 || (stripes > 1 && stripe_size))

This condition is a bit harder to follow at first sight and there
are no comments around with explanation for why this one is used,
so let's analyze it a bit more.

First, let's convert this to an equivalent condition (De Morgan law)
so it's easier to read for humans:

  stripes != 1 && !(stripes > 1 && stripe_size)

Note: Both stripe and stripesize are unsigned integers, so they can't be negative.

Now, based on that condition, we were running the code to deduce the
stripe/stripesize and do the checks ("the code") only if both of these
are true:

  - stripes is different from 1

  - we don't have stripes > 1 and stripe_size defined at the same time

But this is not correct in all cases, because:

  A) if someone uses stripes = 0, then "the code" is executed
    (correct)

  B) if someone uses stripes = 1, then "the code" is not executed
    (wrong: we still need to be able to check the args against
            existing RAID LV stripes whether it matches)

  - if someone uses stripes > 1, then "the code" is:

     C) if stripe_size = 0, executed
       (correct)

     D) if stripe_size > 0, not executed
       (wrong: we still want to check against existing RAID LV stripes)

Current issues with this condition:
  The B) ends up with segfault.

    ❯ lvextend -i 1 -l+1 vg/lvol0
      Rounding size 4.00 MiB (1 extents) up to stripe boundary size 8.00 MiB (2 extents).
    Segmentation fault (core dumped)

  The D) ends up with errors like:

    ❯ lvextend -i 3 -l+1 -I128k vg/lvol0
      Rounding size 4.00 MiB (1 extents) up to stripe boundary size 8.00 MiB (2 extents).
      Rounding size (4 extents) up to stripe boundary size for segment (5 extents).
      Size of logical volume vg/lvol0 changed from 8.00 MiB (2 extents) to 20.00 MiB (5 extents).
      LV lvol0: segment 1 with len=5  has inconsistent area_len 3
      Couldn't read all logical volumes for volume group vg.
      Failed to write VG vg.

Conclusion:
  The condition needs to be removed so we always run "the code" to check
  given striping args given on command line against existing RAID LV
  striping. The reason is that we don't want to allow changing stripe
  count for RAID LVs through lvextend and we need to end up with the
  error:
    "Unable to extend <RAID segment type> segment type with different number of stripes"

  (We do support changing the striping by lvconvert's reshaping functionality only).
2024-11-07 07:57:23 +01:00
Zdenek Kabelac
2a1a7a863d gcc: make older compilers happier
Use {{}} for array initializer to quite warning for older gcc.
2024-11-06 00:04:54 +01:00
Zdenek Kabelac
057314ff8d lvmlockd: update prototype for non-lvmlockd build
Match prototype to last updates of lockd_init_lv_args().
2024-11-01 11:27:02 +01:00
David Teigland
88a085c485 lvmlockd: optimize new lv lease search
When converting a VG to locktype sanlock, a new
lease is allocated for each existing lv.  Finding
a new lease location involved searching the lvmlock
LV from the start for an unused location, which
would be very slow with many LVs.  Improve this by
starting each search from the last used location.
2024-10-31 20:29:00 -05:00
Zdenek Kabelac
c2afa7a116 vg: add radix_tree for lv uuids
When searching for committed LV by uuid, this search can
be expensive for commands like 'vgremove' - so for
this part introduce  'lv_uuids' radix_tree that is
build with first access to lv_committed().
2024-10-31 17:55:31 +01:00
Zdenek Kabelac
db0f1b799f metadata: use radix_tree for find_lv_in_vg
Since there is a group of commands that need to access 'lv_list'
while still need to search for LV by its name, make the whole
struct lv_list a member of logical_volume structure.
This makes it easy to return also 'lv_list' this list this LV
within VG.
Also the patch should not use more memory, since we were allocating
lv_list for each LV anyway when linkin LV to VG.

Since find_lv_by_name() is now using radix_tree(),
use the same 'search for /' in LV in name for both
find_lv() & find_lv_in_vg().

TODO: Possibly refactor code and use only dm_list
instead of lv_list and dereference LV with container_of()
(thus saving pointer within struct logical_volume) - but
we use 'lv_list' currently in many places...
2024-10-31 17:55:31 +01:00
Zdenek Kabelac
0e5beb92c5 config: introduce validate_metadata
Add lvm.conf  config/validate_metadata  configurable setting.
Allows to disable validation of volume_group structure before
writing to disk.
Call of vg_validate() is supposed to catch any inconsistency
of in-memory volume group structure and possibly early aborting
commnand before making any more 'damage' in case the VG struct
is found insistent after some metadata manipulation.

This is almost always useful for devel - and also for normal user
as for small metadata size this doesn't add too much overhead.

However if the volume_group size is large and operations are just
adding removing simple LVs - this validation time may add noticable
to final command running time.

So if the user seeks the highest perfomance of command and does
not do any 'complex' metadata manipulation - it's reasonably safe
to disable validation (with the use of setting "none") here.
2024-10-31 17:55:31 +01:00
Zdenek Kabelac
7bf404db3b validate_lvname: early exit
If the LV name does not any have '_' chr,
there is no point trying to call 'strstr()' to look for "_suffix".
Also we can search from _.
2024-10-31 17:55:31 +01:00
Zdenek Kabelac
ae8ba49142 cov: validate string with lock mode
Check the dev_mode string is not NULL before use.
2024-10-30 13:09:31 +01:00
Zdenek Kabelac
6ebcb0015e cov: add stacktraces
Add stacktraces for unexpected paths.
2024-10-30 13:08:56 +01:00
Zdenek Kabelac
8095a6c14c metadata: pahole logical_volume
Shuffle some variables to remove 'extra' alignment holes
within the structure thus making it smaller.
2024-10-30 12:59:08 +01:00
Zdenek Kabelac
9e8bd57e15 metadata: lv_set_name use uniq_insert
With presence of uniq_insert, use this function also
here for extra protection and check for duplicate lv_name
when inserting a new name into radix_tree.
2024-10-30 12:59:08 +01:00
Zdenek Kabelac
b66b72b115 get_alloc_string: compare only enum
Instead of possibly checking for cling_by_tags string twice,
just compare resulting alloc number from search loop.
2024-10-30 12:57:34 +01:00
Zdenek Kabelac
30adf7e91c toolcontext: use the striped string first 2024-10-30 12:57:34 +01:00
Zdenek Kabelac
e2a5715a60 cache_manip: reset sigint handler
After processing interrupt, reset the interrupt counter,
so further code is not mislead and continues processing
in 'locked' section as expected.
2024-10-30 12:57:34 +01:00
Zdenek Kabelac
608418e4f2 debug: missing stacktrace 2024-10-28 20:07:37 +01:00
Zdenek Kabelac
16241b2dc7 lv_manip: init major minor in alloc_lv
Move initialization of major and minor to alloc_lv().
2024-10-28 20:07:37 +01:00
Zdenek Kabelac
5a293968ec lvresize: fix regression when resizing with fs
When 'lvresize -r' is used to resize the volume, it's valid to
resize even to the same size of an LV, as the command then runs
fs-resize utility to eventually upsize the fs to the current
volume size.

Return code of such command then reflects the return value
of this fs-resize tool.

This fixes the regression introduced when the support
for option --fs was added (2.03.17).
2024-10-25 15:06:39 +02:00
Peter Rajnoha
aa0200c3ff
dev-type: update comment about swap info from blkid 2024-10-25 12:53:07 +02:00
Zdenek Kabelac
0fbcb3b308 clang: check segment lv is defined 2024-10-25 01:26:40 +02:00
Zdenek Kabelac
5ec8f744d0 clang: ensure pointer is defined
Check for new_segtype and lv is defined
before dereferencing.
2024-10-25 01:26:40 +02:00
Zdenek Kabelac
ea4daeb28e cov: use 64bit arithmentic 2024-10-25 01:26:40 +02:00
Zdenek Kabelac
1363a5ffb2 cov: ensure detached_log_lv exists before use 2024-10-25 01:26:40 +02:00
Zdenek Kabelac
5a3375f958 debug: use major:minor
Print major:minor as in other places.
2024-10-25 01:26:40 +02:00
Zdenek Kabelac
edfa4955d8 device_id: close only opened dir
After more of opendir, make sure 'dir' is closed
only when it's been opened.
2024-10-25 01:26:40 +02:00
Zdenek Kabelac
a5e3f0e6dd metadata: check for mda_device existance 2024-10-25 01:26:39 +02:00
Zdenek Kabelac
f61572eef2 dev-cache: ensure list has elements
When updating DM cache, check whether the list even has entries
before comparing it with old cached instance.
2024-10-25 01:26:39 +02:00
Zdenek Kabelac
87f68f443c metadata: fallback search without radix_tree
If we use some dummy vg struct, allow fallback
plain dm_list search.
2024-10-25 01:26:39 +02:00
Zdenek Kabelac
188dd3c357 device_mapper: check for pv before use in error msg 2024-10-25 01:26:39 +02:00
David Teigland
875012fb5d lvmlockd: enable lockopt nodelay for lockstart
Avoid the sanlock add_lockspace delay in vgchange --lockstart
by adding --lockopt nodelay.  This is for testing, and is not
safe to use in general.
2024-10-24 17:15:16 -05:00
Zdenek Kabelac
2c5bf25187 devicesfile: move opendir after fclose
Call opendir() after new file is stored within dir,
otherwise this new file would not accounted.
2024-10-24 21:24:26 +02:00
Zdenek Kabelac
b88cbc7f17 metadata: missed lv_set_name users
Missed when introduced lv_set_name().
2024-10-24 21:24:26 +02:00
Zdenek Kabelac
c27d6695c1 lv: add lv_set_vg
To keep vg->lv_names up-to-date also for merge & split,
add function lv_set_vg() the will update also radix tree
reference for a VG.
2024-10-24 21:23:49 +02:00
Zdenek Kabelac
21517c2bd5 metadata: use radix tree to find lv_names
Replace usage of dm_hash with radix_tree to quickly find LV name
with a vg and also index PV names with set of available PVs.
This PV index is only needed during the import, but instead
of passing 'radix_tree *' everywhere, just keep this within
a VG struct as well and once the parsing is finished, release
this PV index radix_tree.

This also makes it easier to replace this structure
in the future if needed.

lv_set_name now uses  radix_tree remove+insert to keep lv_names
tree in-sync and usable for  find_lv queries.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
1825e782cc revert "metadata: use lv_hash in segment-specific metadata parsing"
This reverts commit f42aef4706.

Going to replace dm_hash with radix_tree and use 'find_lv()'
to abstract lookup for LV with VG.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
956b2c568f metadata: use lv_set_name for raid and mirror
Use lv_set_name API also for raid and mirror LV manipulation.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
c681d4e61a metadata: add lv_set_name
Add function to set lv->name.
Also when creating empty LV, first add this LV
to linked list in a VG and just after that allocate lv name.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
73f24443e5 check_pv_segments: resolve pv name once 2024-10-24 17:38:09 +02:00
Zdenek Kabelac
eb4b307d0c log: postpone some initialization
Clear buffers when really logging.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
dee8bc9ae4 lv_manip: remove duplicate check for max lv
This check is always performed with call to link_lv_to_vg().
2024-10-24 17:37:30 +02:00
Zdenek Kabelac
d62170d646 flags: drop no longer needed header
After code refactoring, this header is not needed here anymore.
2024-10-24 17:35:33 +02:00
Zdenek Kabelac
668c185949 vg_validate: use uniq_insert
Enhance usage with uniq_insert and also try to better
utilize CPU cache and do a smaller loop for individual
hashing of lvname and separately lvid.

Also correcting usage of 'continue' within validation of
historical names as it should report as much errors
as it can within a loop.
2024-10-24 17:35:33 +02:00
Zdenek Kabelac
dd856edaab vgcfgrestore: validate complete VG
Avoid finding problems in vg_validate when restoring
invalid VG metadata as that would lead to internal error.
i.e. adding unsupported METADATA_FLAG to zero segtype
can trigger such thing.
2024-10-23 20:16:14 +02:00
Zdenek Kabelac
2916a8a1f3 read_lvflags: keep flag reading focused on flags
Previous update needed to add handling segtype within flag.c
which somewhat breaks API separition and also had bug in hanlding
actual flags.

So instead keep segtype code in _read_segtype_and_lvflags() within
import_vsn1.c and handle purly flags in read_lvflags() from const
string.
2024-10-23 20:16:14 +02:00