Bug 204136 - lvconvert splits allocation unnecessarily
lvconvert splits allocation unnecessarily
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: lvm2 (Show other bugs)
5.2
All Linux
medium Severity medium
: rc
: ---
Assigned To: LVM and device-mapper development team
:
Depends On:
Blocks: 1049888
  Show dependency treegraph
 
Reported: 2006-08-25 15:52 EDT by Jun'ichi Nomura (Red Hat)
Modified: 2014-04-07 10:30 EDT (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-04-07 10:30:49 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Reproducer test script (1.98 KB, application/x-shellscript)
2006-08-25 15:52 EDT, Jun'ichi Nomura (Red Hat)
no flags Details

  None (edit)
Description Jun'ichi Nomura (Red Hat) 2006-08-25 15:52:27 EDT
Description of problem:
lvconvert splits newly allocated mirror unnecessarily
if the original LV spans to multiple segments

Version-Release number of selected component:
lvm2-2.02.06-6.0.RHEL4

How reproducible:
Always

Steps to Reproduce:
 1. Create a VG with 5 or more PVs
      # vgcreate testvg /dev/sdb[1-5]
 2. Create a linear LV which spans multiple PVs but smaller than one PV
      # lvcreate -L<PV size / 2> -nlv1 testvg /dev/sdb1
      # lvcreate -L<PV size / 2> -nlv2 testvg /dev/sdb2
      # lvcreate -L<PV size> -nlv0 testvg /dev/sdb1 /dev/sdb2
      # lvremove testvg/lv1
      # lvremove testvg/lv2
    As a result, testvg/lv0 uses both /dev/sdb1 and /dev/sdb2
    while its size can be fit within one PV.
 3. Convert it to mirror
      # lvconvert -m1 testvg/lv0
 4. Check how the mirror image is allocated
      # lvs -o+devices

Actual results:
Newly allocated mirror image is splitted to 2 PVs.

Expected results:
Newly allocated mirror image is allocated within 1 PV.

Additional info:

Attached script does the above steps and show what happens.

# sh /root/lvconvert-multiseg2.sh
...
INFO: Create linear LV spanning multiple PVs.
...
  LV   Devices
  lv0  /dev/dm-0(2)
  lv0  /dev/dm-1(2)
INFO: Convert the LV to mirrored.
  Logical volume lv0 converted.
  LV             Devices                         SSize
  lv0            lv0_mimage_0(0),lv0_mimage_1(0) 16.00M
  [lv0_mimage_0] /dev/dm-0(2)                     8.00M
  [lv0_mimage_0] /dev/dm-1(2)                     8.00M
  [lv0_mimage_1] /dev/dm-2(0)                     8.00M
  [lv0_mimage_1] /dev/dm-3(0)                     8.00M
  [lv0_mlog]     /dev/dm-4(0)                     4.00M
  PV         VG      Fmt  Attr PSize  PFree
  /dev/dm-0  testvg0 lvm2 a-   16.00M  8.00M
  /dev/dm-1  testvg0 lvm2 a-   16.00M  8.00M
  /dev/dm-2  testvg0 lvm2 a-   16.00M  8.00M
  /dev/dm-3  testvg0 lvm2 a-   16.00M  8.00M
  /dev/dm-4  testvg0 lvm2 a-   16.00M 12.00M
...

Expected result was:
  LV             Devices                         SSize
  lv0            lv0_mimage_0(0),lv0_mimage_1(0) 16.00M
  [lv0_mimage_0] /dev/dm-0(2)                     8.00M
  [lv0_mimage_0] /dev/dm-1(2)                     8.00M
  [lv0_mimage_1] /dev/dm-2(0)                    16.00M
  [lv0_mlog]     /dev/dm-4(0)                     4.00M
  PV         VG      Fmt  Attr PSize  PFree
  /dev/dm-0  testvg0 lvm2 a-   16.00M  8.00M
  /dev/dm-1  testvg0 lvm2 a-   16.00M  8.00M
  /dev/dm-2  testvg0 lvm2 a-   16.00M     0
  /dev/dm-3  testvg0 lvm2 a-   16.00M 16.00M
  /dev/dm-4  testvg0 lvm2 a-   16.00M 12.00M
Comment 1 Jun'ichi Nomura (Red Hat) 2006-08-25 15:52:28 EDT
Created attachment 134955 [details]
Reproducer test script
Comment 3 RHEL Product and Program Management 2008-05-28 23:03:48 EDT
This request was previously evaluated by Red Hat Product Management
for inclusion in the current Red Hat Enterprise Linux release, but
Red Hat was unable to resolve it in time.  This request will be
reviewed for a future Red Hat Enterprise Linux release.
Comment 5 RHEL Product and Program Management 2008-09-05 13:19:19 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.
Comment 6 Alasdair Kergon 2008-09-23 18:00:59 EDT
Does the cling policy make any difference now?
Comment 8 Milan Broz 2009-03-05 08:07:31 EST
Moving that bug to RHEL5 product for future tracking of the problem.
Comment 12 Peter Rajnoha 2014-04-07 10:30:49 EDT
This seems to be working with lvconvert --alloc cling now:


[root@localhost ~]# lvcreate -L 400m vg /dev/sda
  Logical volume "lvol0" created

[root@localhost ~]# lvcreate -L 400m vg /dev/sdb
  Logical volume "lvol1" created

[root@localhost ~]# lvcreate -L 400m vg /dev/sda /dev/sdb
  Logical volume "lvol2" created

[root@localhost ~]# lvdisplay --maps vg
  --- Logical volume ---
  LV Name                /dev/vg/lvol0
  VG Name                vg
  LV UUID                zR8j42-DK1R-zLgO-ZdXK-nlVS-wg5C-TyPcob
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                400.00 MB
  Current LE             100
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2
   
  --- Segments ---
  Logical extent 0 to 99:
    Type		linear
    Physical volume	/dev/sda
    Physical extents	0 to 99
   
   
  --- Logical volume ---
  LV Name                /dev/vg/lvol1
  VG Name                vg
  LV UUID                0T26qE-1sLk-I7Wq-goHS-23Au-rBtO-YihTl0
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                400.00 MB
  Current LE             100
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:3
   
  --- Segments ---
  Logical extent 0 to 99:
    Type		linear
    Physical volume	/dev/sdb
    Physical extents	0 to 99
   
   
  --- Logical volume ---
  LV Name                /dev/vg/lvol2
  VG Name                vg
  LV UUID                1bE3wS-b72I-iD3w-74oq-wB4S-lYBt-hjK9EH
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                1000.00 MB
  Current LE             250
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:4
   
  --- Segments ---
  Logical extent 0 to 154:
    Type		linear
    Physical volume	/dev/sda
    Physical extents	100 to 254
   
  Logical extent 155 to 249:
    Type		linear
    Physical volume	/dev/sdb
    Physical extents	100 to 194
   
[root@localhost ~]# lvremove -ff vg/lvol0
  Logical volume "lvol0" successfully removed

[root@localhost ~]# lvremove -ff vg/lvol1 
  Logical volume "lvol1" successfully removed


[root@localhost ~]# lvconvert -m1 vg/lvol2 --alloc cling
  vg/lvol2: Converted: 0.0%
  vg/lvol2: Converted: 26.4%
  vg/lvol2: Converted: 52.0%
  vg/lvol2: Converted: 75.2%
  vg/lvol2: Converted: 96.8%
  vg/lvol2: Converted: 100.0%

[root@localhost ~]# lvs -a -o lv_name,vg_name,lv_size,devices vg
  LV               VG   LSize    Devices                            
  lvol2            vg   1000.00M lvol2_mimage_0(0),lvol2_mimage_1(0)
  [lvol2_mimage_0] vg   1000.00M /dev/sda(100)                      
  [lvol2_mimage_0] vg   1000.00M /dev/sdb(100)                      
  [lvol2_mimage_1] vg   1000.00M /dev/sdc(0)                        
  [lvol2_mlog]     vg      4.00M /dev/sdb(0)

Note You need to log in before you can comment on or make changes to this bug.