[linux-lvm] bug? shrink lv by specifying pv extent to be removed does not behave as expected

Roger Heflin rogerheflin at gmail.com
Sun Apr 9 17:32:59 UTC 2023


On Sun, Apr 9, 2023 at 10:18 AM Roland <devzero at web.de> wrote:
>
> hi,
>
> we can extend a logical volume by arbitrary pv extends like this :
>
>
> root at s740:~# lvresize mytestVG/blocks_allocated -l +1 /dev/sdb:5
>    Size of logical volume mytestVG/blocks_allocated changed from 1.00
> MiB (1 extents) to 2.00 MiB (2 extents).
>    Logical volume mytestVG/blocks_allocated successfully resized.
>
> root at s740:~# lvresize mytestVG/blocks_allocated -l +1 /dev/sdb:10
>    Size of logical volume mytestVG/blocks_allocated changed from 2.00
> MiB (2 extents) to 3.00 MiB (3 extents).
>    Logical volume mytestVG/blocks_allocated successfully resized.
>
> root at s740:~# lvresize mytestVG/blocks_allocated -l +1 /dev/sdb:15
>    Size of logical volume mytestVG/blocks_allocated changed from 3.00
> MiB (3 extents) to 4.00 MiB (4 extents).
>    Logical volume mytestVG/blocks_allocated successfully resized.
>
> root at s740:~# lvresize mytestVG/blocks_allocated -l +1 /dev/sdb:20
>    Size of logical volume mytestVG/blocks_allocated changed from 4.00
> MiB (4 extents) to 5.00 MiB (5 extents).
>    Logical volume mytestVG/blocks_allocated successfully resized.
>
> root at s740:~# pvs --segments
> -olv_name,seg_start_pe,seg_size_pe,pvseg_start  -O pvseg_start
>    LV               Start SSize  Start
>    blocks_allocated     0      1     0
>                         0      4     1
>    blocks_allocated     1      1     5
>                         0      4     6
>    blocks_allocated     2      1    10
>                         0      4    11
>    blocks_allocated     3      1    15
>                         0      4    16
>    blocks_allocated     4      1    20
>                         0 476917    21
>
>
> how can i do this in reverse ?
>
> when i specify the physical extend to be added, it works - but when is
> specifcy the physical extent to be removed,
> the last one is being removed but not the specified one.
>
> see here for example - i wanted to remove extent number 10 like i did
> add it, but instead extent number 20
> is being removed
>
> root at s740:~# lvresize mytestVG/blocks_allocated -l -1 /dev/sdb:10
>    Ignoring PVs on command line when reducing.
>    WARNING: Reducing active logical volume to 4.00 MiB.
>    THIS MAY DESTROY YOUR DATA (filesystem etc.)
> Do you really want to reduce mytestVG/blocks_allocated? [y/n]: y
>    Size of logical volume mytestVG/blocks_allocated changed from 5.00
> MiB (5 extents) to 4.00 MiB (4 extents).
>    Logical volume mytestVG/blocks_allocated successfully resized.
>
> root at s740:~# pvs --segments
> -olv_name,seg_start_pe,seg_size_pe,pvseg_start  -O pvseg_start
>    LV               Start SSize  Start
>    blocks_allocated     0      1     0
>                         0      4     1
>    blocks_allocated     1      1     5
>                         0      4     6
>    blocks_allocated     2      1    10
>                         0      4    11
>    blocks_allocated     3      1    15
>                         0 476922    16
>
>
> how can i remove extent number 10 ?
>
> is this a bug ?
>

Well, if the LV is being used for anything real, then I don't know of
anything where you could remove a block in the middle and still have a
working fs.   You can only reduce fs'es (the ones that you can reduce)
by reducing off of the end and making it smaller.

It makes zero sense to be able to remove a block in the middle of a LV
used by just about everything that uses LV's as nothing supports being
able to remove a block in the middle.

What is your use case that you believe removing a block in the middle
of an LV needs to work?

Now if you really need to remove a specific block in the middle of the
LV then you are likely going to need to use pvmove with specific
blocks to replace those blocks with something else.



More information about the linux-lvm mailing list