1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/lib/metadata
Peter Rajnoha 4a34959c1c 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).

(cherry picked from commit b5249fa3c2)
2024-11-13 10:57:02 +01:00
..
cache_manip.c cache_manip: reset sigint handler 2024-10-30 12:57:34 +01:00
integrity_manip.c cov: avoid expression overflow 2024-08-09 13:20:44 +02:00
lv_alloc.h build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
lv_manip.c lv_manip: fix stripe count and size validation for RAID LVs 2024-11-13 10:57:02 +01:00
lv.c metadata: lv_set_name use uniq_insert 2024-10-30 12:59:08 +01:00
lv.h metadata: use radix_tree for find_lv_in_vg 2024-10-31 17:55:31 +01:00
merge.c clang: check segment lv is defined 2024-10-25 01:26:40 +02:00
metadata-exported.h metadata: use radix_tree for find_lv_in_vg 2024-10-31 17:55:31 +01:00
metadata.c lvmlockd: optimize new lv lease search 2024-10-31 20:29:00 -05:00
metadata.h metadata: use radix tree to find lv_names 2024-10-24 17:38:09 +02:00
mirror.c cov: ensure detached_log_lv exists before use 2024-10-25 01:26:40 +02:00
pool_manip.c cleanup: typos in comments 2024-08-30 16:51:15 +02:00
pv_alloc.h doc: change fsf address 2016-01-21 12:11:37 +01:00
pv_list.c devices: fix dev_name assumptions 2022-02-24 17:22:04 -06:00
pv_manip.c check_pv_segments: resolve pv name once 2024-10-24 17:38:09 +02:00
pv_map.c build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
pv_map.h build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
pv.c cov: clean up pvid and vgid usage 2021-08-16 11:31:15 -05:00
pv.h cov: clean up pvid and vgid usage 2021-08-16 11:31:15 -05:00
raid_manip.c clang: ensure pointer is defined 2024-10-25 01:26:40 +02:00
segtype.c segtype: add linear 2018-06-05 16:23:18 +02:00
segtype.h metadata: use radix tree to find lv_names 2024-10-24 17:38:09 +02:00
snapshot_manip.c cleanup: typos in comments 2024-08-30 16:51:15 +02:00
takeover_matrix.h const: raid takover arrays 2024-05-04 01:01:57 +02:00
thin_manip.c thin: check only for profiled config vars 2024-10-22 19:36:00 +02:00
vdo_manip.c metadata: add lv_set_name 2024-10-24 17:38:09 +02:00
vg.c vg: add radix_tree for lv uuids 2024-10-31 17:55:31 +01:00
vg.h vg: add radix_tree for lv uuids 2024-10-31 17:55:31 +01:00
writecache_manip.c metadata: missed lv_set_name users 2024-10-24 21:24:26 +02:00