Bug 1269533
Summary: | lvcreate with %FREE/%VG option should not fail when creating mirrors | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Roman Bednář <rbednar> | ||||
Component: | lvm2 | Assignee: | Heinz Mauelshagen <heinzm> | ||||
lvm2 sub component: | Command-line tools | QA Contact: | cluster-qe <cluster-qe> | ||||
Status: | CLOSED ERRATA | Docs Contact: | |||||
Severity: | low | ||||||
Priority: | unspecified | CC: | agk, cmarthal, heinzm, jbrassow, lmiksik, mcsontos, msnitzer, prajnoha, prockai, rbednar, thornber, zkabelac | ||||
Version: | 7.2 | ||||||
Target Milestone: | rc | ||||||
Target Release: | --- | ||||||
Hardware: | x86_64 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | lvm2-2.02.175-2.el7 | Doc Type: | If docs needed, set a value | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2018-04-10 15:16:02 UTC | Type: | Bug | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | |||||||
Bug Blocks: | 1469559 | ||||||
Attachments: |
|
Description
Roman Bednář
2015-10-07 14:01:10 UTC
Solved in upstream Created attachment 1205500 [details]
verbose lvcreate attempt
3.10.0-510.el7.x86_64
lvm2-2.02.165-4.el7 BUILT: Thu Sep 22 01:47:19 CDT 2016
lvm2-libs-2.02.165-4.el7 BUILT: Thu Sep 22 01:47:19 CDT 2016
lvm2-cluster-2.02.165-4.el7 BUILT: Thu Sep 22 01:47:19 CDT 2016
device-mapper-1.02.134-4.el7 BUILT: Thu Sep 22 01:47:19 CDT 2016
device-mapper-libs-1.02.134-4.el7 BUILT: Thu Sep 22 01:47:19 CDT 2016
device-mapper-event-1.02.134-4.el7 BUILT: Thu Sep 22 01:47:19 CDT 2016
device-mapper-event-libs-1.02.134-4.el7 BUILT: Thu Sep 22 01:47:19 CDT 2016
device-mapper-persistent-data-0.6.3-1.el7 BUILT: Fri Jul 22 05:29:13 CDT 2016
[root@host-116 ~]# pvscan
PV /dev/sda1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
PV /dev/sdb1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
PV /dev/sdc1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
PV /dev/sdd1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
PV /dev/sde1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
PV /dev/sdf1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
PV /dev/sdg1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
PV /dev/sdh1 VG vg lvm2 [9.99 GiB / 9.99 GiB free]
[root@host-116 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg 8 0 0 wz--n- 79.94g 79.94g
[root@host-116 ~]# lvcreate --type raid1 -m 1 -l50%FREE vg
Logical volume "lvol0" created.
[root@host-116 ~]# lvremove -y vg/lvol0
Logical volume "lvol0" successfully removed
[root@host-116 ~]# lvcreate --type mirror -m 1 -l50%FREE vg
Insufficient free space for log allocation for logical volume .
Unable to allocate extents for mirror log.
[root@host-116 ~]# lvcreate --type mirror -m 3 -l60%FREE vg
Insufficient free space for log allocation for logical volume .
Unable to allocate extents for mirror log.
# This one actually worked for me
[root@host-116 ~]# lvcreate --type mirror -m 4 -l60%FREE vg
Logical volume "lvol0" created.
[root@host-116 ~]# lvs -a -o +devices
LV VG Attr LSize Log Cpy%Sync Devices
lvol0 vg mwi-a-m--- 9.99g [lvol0_mlog] 24.28 lvol0_mimage_0(0),lvol0_mimage_1(0),lvol0_mimage_2(0),lvol0_mimage_3(0),lvol0_mimage_4(0)
[lvol0_mimage_0] vg Iwi-aom--- 9.99g /dev/sda1(0)
[lvol0_mimage_1] vg Iwi-aom--- 9.99g /dev/sdb1(0)
[lvol0_mimage_2] vg Iwi-aom--- 9.99g /dev/sdc1(0)
[lvol0_mimage_3] vg Iwi-aom--- 9.99g /dev/sdd1(0)
[lvol0_mimage_4] vg Iwi-aom--- 9.99g /dev/sde1(0)
[lvol0_mlog] vg lwi-aom--- 4.00m /dev/sdh1(0)
So the problem is that it is allocating the log separately afterwards, and this only works if there was a remainder when the number of free extents was divided by the number of legs. Fix is either to do the allocation all in one go, or to require the first allocation to leave a certain amount of space free. There are a few related problems in this code. Cases that lead to Internal errors (if the percentage calculation leads to zero). Mix-ups between physical extents and logical extents that already got fixed for lvresize but not for lvcreate. First patch: https://www.redhat.com/archives/lvm-devel/2017-May/msg00042.html https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cf73f6cf61793e9d71391bb7a8f35162509898a4 commit cf73f6cf61793e9d71391bb7a8f35162509898a4 Author: Alasdair G Kergon <agk> Date: Fri May 12 02:04:05 2017 +0100 lvcreate: Fix mirror percentage size calculations. Trap cases where the percentage calculation currently leads to an empty LV and the message: Internal error: Unable to create new logical volume with no extents Additionally convert the calculated number of extents from physical to logical when creating a mirror using a percentage that is based on Physical Extents. Otherwise a command like 'lvcreate -m3 -l80%FREE' can never leave any free space. This brings the behaviour closer to that of lvresize. (A further patch is needed to cover all the raid types.) If the VG has no free space in it: Old: # lvcreate -l100%FREE vg0 -m4 Internal error: Unable to create new logical volume with no extents. New # lvcreate -l100%FREE vg0 -m4 Calculated size of logical volume is 0 extents. Needs to be larger. lvcreate -l50%FREE with a mirror should now use up 50% of the free space (instead of using all of it), in the same way that lvresize -l+50%FREE does. Because "mirror" allocates the log on a seperate PV but RAID doesn't with its rmeta devices, we got the following correct but odd looking layout allocating -l50%FREE on even number (e.g.) 4 PVs: # lvs -aoname,size,attr,segtype,segperanges p LV LSize Attr Type PE Ranges r 8.00g Mwi-a-m--- mirror r_mimage_0:0-2046 r_mimage_1:0-2046 [r_mimage_0] 8.00g iwi-aom--- linear /dev/sda:0-2046 [r_mimage_1] 8.00g iwi-aom--- linear /dev/sdb:0-2046 [r_mlog] 4.00m lwi-aom--- linear /dev/sdd:0-0 # lvs -aoname,size,attr,segtype,segperanges p LV LSize Attr Type PE Ranges r 8.00g Rwi-a-r--- raid1 r_rimage_0:0-2046 r_rimage_1:0-2046 [r_rimage_0] 8.00g iwi-aor--- linear /dev/sda:1-2046 [r_rimage_0] 8.00g iwi-aor--- linear /dev/sdc:0-0 [r_rimage_1] 8.00g iwi-aor--- linear /dev/sdb:1-2046 [r_rimage_1] 8.00g iwi-aor--- linear /dev/sdd:0-0 [r_rmeta_0] 4.00m ewi-aor--- linear /dev/sda:0-0 [r_rmeta_1] 4.00m ewi-aor--- linear /dev/sdb:0-0 Marking verified with latest rpms, this BZ seems to incorporate more fixes and behaviour changes. I'll try to summarize those (hopefully all of them) below. 1) creating a mirror when a vg has no free space left: BEFORE FIX: # lvcreate -l100%FREE vg -m4 Internal error: Unable to create new logical volume with no extents. AFTER FIX: # lvcreate -l100%FREE vg -m4 Calculated size of logical volume is 0 extents. Needs to be larger. 2) %FREE option now represents total allocation space (including possible mirrors) BEFORE FIX: # vgs vg -o vg_name,free VG VFree vg 89.95g # lvcreate -l50%FREE -m 2 vg Logical volume "lvol0" created. # vgs vg -o vg_name,free VG VFree vg 0 AFTER FIX: # vgs vg -o vg_name,free VG VFree vg 89.96g # lvcreate -l50%FREE -m 2 vg Logical volume "lvol0" created. # vgs vg -o vg_name,free VG VFree vg <44.98g 3) mirror log allocation: BEFORE FIX: # vgs vg -o vg_name,pv_count VG #PV vg 3 # lvcreate -l100%FREE --type mirror -m2 vg Insufficient free space for log allocation for logical volume . Unable to allocate extents for mirror log. AFTER FIX: # vgs vg -o vg_name,pv_count VG #PV vg 3 # lvcreate -l100%FREE --type mirror -m2 vg Logical volume "lvol0" created. 3.10.0-734.el7.x86_64 lvm2-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 lvm2-libs-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 lvm2-cluster-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-libs-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-event-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-event-libs-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-persistent-data-0.7.3-2.el7 BUILT: Tue Oct 10 11:00:07 CEST 2017 cmirror-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 (In reply to Roman Bednář from comment #27) > Marking verified with latest rpms, this BZ seems to incorporate more fixes > and behaviour changes. I'll try to summarize those (hopefully all of them) > below. > > 1) creating a mirror when a vg has no free space left: > > BEFORE FIX: > # lvcreate -l100%FREE vg -m4 > Internal error: Unable to create new logical volume with no extents. > Previously, the 100% allocation failed allocating the log for the mirror when consuming space of all PVs for the legs leading to this error. The new behaviour preserves space for the mirror log to allow for its allocation (see my remark below as well). > > AFTER FIX: > # lvcreate -l100%FREE vg -m4 > Calculated size of logical volume is 0 extents. Needs to be larger. You have a VG with 10 PVs. How did you cause this error? Succeeds here: [root@vm254 ~]# vgs nvm VG #PV #LV #SN Attr VSize VFree nvm 10 0 0 wz--n- 79.96g 79.96g [root@vm254 ~]# lvcreate -l100%FREE --ty mirror -m4 nvm Logical volume "lvol0" created. [root@vm254 ~]# lvs -aoname,size,attr,segtype,stripes,datastripes,regionsize,stripesize,syncpercent,reshapelen,origin,devices nvm LV LSize Attr Type #Str #DStr Region Stripe Cpy%Sync RSize Origin Devices lvol0 15.99g mwi-a-m--- mirror 5 5 512.00k 0 0.39 lvol0_mimage_0(0),lvol0_mimage_1(0),lvol0_mimage_2(0),lvol0_mimage_3(0),lvol0_mimage_4(0) [lvol0_mimage_0] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sda(0) [lvol0_mimage_0] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdf(0) [lvol0_mimage_1] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdb(0) [lvol0_mimage_1] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdg(0) [lvol0_mimage_2] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdc(0) [lvol0_mimage_2] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdh(0) [lvol0_mimage_3] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdd(0) [lvol0_mimage_3] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdi(0) [lvol0_mimage_4] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sde(0) [lvol0_mimage_4] 15.99g Iwi-aom--- linear 1 1 0 0 /dev/sdj(0) [lvol0_mlog] 4.00m lwi-aom--- linear 1 1 0 0 /dev/sdj(2046) > > > 2) %FREE option now represents total allocation space (including possible > mirrors) > > BEFORE FIX: > # vgs vg -o vg_name,free > VG VFree > vg 89.95g > > # lvcreate -l50%FREE -m 2 vg > Logical volume "lvol0" created. > > # vgs vg -o vg_name,free > VG VFree > vg 0 > > > AFTER FIX: > # vgs vg -o vg_name,free > VG VFree > vg 89.96g This results from the coallocation of the mirror log on a PV with a mirror log, hence reducing the soze of all legs cusing (a little) more free space. > > # lvcreate -l50%FREE -m 2 vg > Logical volume "lvol0" created. > > # vgs vg -o vg_name,free > VG VFree > vg <44.98g > > 3) mirror log allocation: > > BEFORE FIX: > # vgs vg -o vg_name,pv_count > VG #PV > vg 3 > # lvcreate -l100%FREE --type mirror -m2 vg > Insufficient free space for log allocation for logical volume . > Unable to allocate extents for mirror log. > > AFTER FIX: > # vgs vg -o vg_name,pv_count > VG #PV > vg 3 > # lvcreate -l100%FREE --type mirror -m2 vg > Logical volume "lvol0" created. > > > 3.10.0-734.el7.x86_64 > > lvm2-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 > lvm2-libs-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 > lvm2-cluster-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 > device-mapper-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 > device-mapper-libs-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 > device-mapper-event-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 > device-mapper-event-libs-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST > 2017 > device-mapper-persistent-data-0.7.3-2.el7 BUILT: Tue Oct 10 11:00:07 CEST > 2017 > cmirror-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 > > AFTER FIX:
> > # lvcreate -l100%FREE vg -m4
> > Calculated size of logical volume is 0 extents. Needs to be larger.
>
> You have a VG with 10 PVs. How did you cause this error?
It happens when vg has no free space left, as I wrote. I should have pasted all commands for clarity. So it's:
# vgs
VG #PV #LV #SN Attr VSize VFree
rhel_virt-362 1 2 0 wz--n- <7.00g 0
vg 10 0 0 wz--n- 299.88g 299.88g
# lvcreate -l100%FREE vg
Logical volume "lvol0" created.
# lvcreate -l100%FREE vg -m4
Calculated size of logical volume is 0 extents. Needs to be larger.
(In reply to Roman Bednář from comment #32) <SNIP> > # lvcreate -l100%FREE vg > Logical volume "lvol0" created. > > # lvcreate -l100%FREE vg -m4 > Calculated size of logical volume is 0 extents. Needs to be larger. Ok, when given percent size on a zero free VG, the message tells as much being calculated for the mirror LV which is correct. Marking verified in the latest rpms. The %FREE/%VG mirror cmds no longer fail. The remaining free space will always be dependent on the number of PVs in the VG and how many images were requested. For -m1, -m2, -m3, etc, there will always be scenarios we can construct where we'll have remaining space even when using 100%FREE # 4 leg mirror -m3 (but 4 PVs in VG) = no free space [root@host-082 ~]# vgcreate mirror_sanity /dev/sd[abcd] Volume group "mirror_sanity" successfully created [root@host-082 ~]# lvcreate -l100%VG -n mirror_3 --type mirror -m3 mirror_sanity Logical volume "mirror_3" created. [root@host-082 ~]# vgs -o vg_size,vg_free mirror_sanity VSize VFree <119.97g 12.00m # 2 leg mirror -m1 (but 3 PVs in VG) = free space equal to ~1 PVs [root@host-082 ~]# vgcreate mirror_sanity /dev/sd[abc] Volume group "mirror_sanity" successfully created [root@host-082 ~]# lvcreate -l100%VG -n mirror_1 --type mirror -m1 mirror_sanity Logical volume "mirror_1" created. [root@host-082 ~]# vgs -o vg_size,vg_free mirror_sanity VSize VFree <89.98g <29.99g # 3 leg mirror -m2 (but 5 PVs in VG) = free space equal to ~2 PVs [root@host-082 ~]# vgcreate mirror_sanity /dev/sd[abcde] Volume group "mirror_sanity" successfully created [root@host-082 ~]# lvcreate -l100%VG -n mirror_2 --type mirror -m2 mirror_sanity Logical volume "mirror_2" created. [root@host-082 ~]# vgs -o vg_size,vg_free mirror_sanity VSize VFree 149.96g 59.98g 3.10.0-830.el7.x86_64 lvm2-2.02.176-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 lvm2-libs-2.02.176-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 lvm2-cluster-2.02.176-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 lvm2-lockd-2.02.176-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 lvm2-python-boom-0.8.1-5.el7 BUILT: Wed Dec 6 11:15:40 CET 2017 cmirror-2.02.176-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 device-mapper-1.02.145-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 device-mapper-libs-1.02.145-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 device-mapper-event-1.02.145-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 device-mapper-event-libs-1.02.145-5.el7 BUILT: Wed Dec 6 11:13:07 CET 2017 device-mapper-persistent-data-0.7.0-0.1.rc6.el7 BUILT: Mon Mar 27 17:15:46 CEST 2017 sanlock-3.5.0-1.el7 BUILT: Wed Apr 26 16:37:30 CEST 2017 sanlock-lib-3.5.0-1.el7 BUILT: Wed Apr 26 16:37:30 CEST 2017 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHEA-2018:0853 |