Bug 1268832

Summary: LVM: Unpredictable LV size when using -lX%FREE option
Product: Red Hat Enterprise Linux 7 Reporter: Roman Bednář <rbednar>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Command-line tools QA Contact: cluster-qe <cluster-qe>
Status: CLOSED NOTABUG Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, prajnoha, prockai, thornber, zkabelac
Version: 7.2   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-10-13 12:07:39 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:

Description Roman Bednář 2015-10-05 12:11:29 UTC
Description of problem:
 
Combination of mirror, raid1,4,5 and stripe with -lX%FREE option gives unpredictable results.
Highest possible value is always applied to create all the needed LVs (public and private)
ending up with public logical volume of unpredictable size.
 
Version-Release number of selected component (if applicable):
lvm2-2.02.130-2.el7.x86_64
 
How reproducible:
always
 
Steps to Reproduce:
1. vgcreate vg /dev/sda
2. lvcreate -n test_lv --type mirror -l30%FREE -m 4 vg
3. lvs
4. check the size of this new LV
 
Actual results:
The size of logical volumes are reduced, resulting size for public LV is not ~30% but ~16%.
Same behaviour also applies to any other combination of legs and percentage
that would result in exceeding the limit of free volume group extents.
 
Expected results:
Users should have the public LV of the size they requested. Command should fail
when user tries to create a logical volume whose public+private LVs would exceed
the limit of free extents in volume group
 
Additional info:
the expected results are actually implemented for mirror LVs with other than 3 and 4 copies.
 
Example:
"lvcreate -n test_lv --type mirror -m 1 -l50%FREE vg"
fails with a message:
"Insufficient free space for log allocation for logical volume.
Unable to allocate extents for mirror log."

Comment 2 Jonathan Earl Brassow 2015-10-06 21:26:26 UTC
When specifying %FREE, the amount is considered to be an approximation.  So, there should not be the assumption of an exact match.  However, I see two possible valid complaints in the above:
1) The amount received is much less than the amount requested (I'd need to see the before and after pvs,vgs,lvs to be sure this is the case though).
2) legacy mirrors (i.e. --type mirror) do not function the way other targets do

Comment 3 Roman Bednář 2015-10-13 12:07:39 UTC
Closing bug. Two new BZs were created to deal with those issues.

1) https://bugzilla.redhat.com/show_bug.cgi?id=1269893

2) https://bugzilla.redhat.com/show_bug.cgi?id=1269533