Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Created attachment 1474610[details]
Not tested patch which could fix it.
Description of problem:
lvrezsize %VG increase amount of allocated extents by 1, even if the
LV was created wit same amount of percentage
Version-Release number of selected component (if applicable):
lvm2-2.02.177-4.el7.x86_64
How reproducible:
Every time
Steps to Reproduce:
1. vgcreate test_vg /dev/sdc
2. lvcreate -l 90%VG test_vg -n test
3. lvresize -l 90%VG test_vg/test
[root@fastvm-rhel-7-5-uefi-24 ~]# lvcreate -l 90%VG test_vg -n test
Logical volume "test" created.
[root@fastvm-rhel-7-5-uefi-24 ~]# lvresize -l 90%VG test_vg/test
Size of logical volume test_vg/test changed from <18.00 GiB (4607 extents) to 18.00 GiB (4608 extents).
Logical volume test_vg/test successfully resized.
[root@fastvm-rhel-7-5-uefi-24 ~]#
Actual results:
LV is resized by 1 extent.
Expected results:
LV is not resized.
Additional info:
The problem comes from different way of calling function `percent_of_extents`.
lib/misc/lvm-percent.c:
uint32_t percent_of_extents(uint32_t percents, uint32_t count, int roundup)
{
return (uint32_t)(((uint64_t)percents * (uint64_t)count +
((roundup) ? 99 : 0)) / 100);
}
While creating the LV the roundup parameter is 0.
lvcreate:
tools/lvcreate.c:
...
switch (lcp->percent) {
case PERCENT_VG:
extents = percent_of_extents(lp->extents, base_calc_extents = vg->extent_count, 0);
break;
...
But while resizing it, it is 1 as a result of `!=` operator.
lvresize:
lib/metadata/lv_manip.c
...
switch (lp->percent) {
case PERCENT_VG:
lp->extents = percent_of_extents(lp->extents, vg->extent_count,
(lp->sign != SIGN_MINUS));
...
We will look on this - just initial comment here is - the 'percentage' usage is never meant to be used as some 'exact' definition - if the user needs 'extent precise' size for LV - he should use option '-l extent_count' - since percentage size is free to round things according to current allocation algorithm in place (so it's never guaranteed you will always get the same size in 'extents' across different versions of lvm2.
So let's put here the reasoning;
lvcreate -l% specifies 'AT MOST' the size LV can have.
Basically this makes command useful for most case - when user want to have SOME LV with approximate size of X.
So the applied rounding is DOWN.
on the other lvresize command uses the logic 'AT LEAST'
So the applied rounding is UP.
The reasoning have be choosen after some discussion in past and this may lead to this occasional 1-extent
difference when commands are executed this way.
Main argument is - when user is creating something and uses % specifier - he doesn't really care about exact value but he wants to have command to proceed - so lvm2 scales down number considerable to make it 'work'
(i.e. if there is only 10% free space in VG and you specify 90%VG - LV of ~10% size of VG will be created).
When the resize is executed - the logic is that user specifies minimal value.
So as mentioned in comment 2 - when exact size is wanted - avoid using %specifier.
There is no plan to fix or change this logic - so closing this BZ
Hmm thinking about it more -
it likely can't do much harm when lvcreate would be matching lvresize computed size.
Both command do implement automatic size reduction - and both report it - so it likely should be leading to the same rouding logic.
Original we were not doing size reduction - but now - it does look more logical to keep 'lvcreate & lvresize' size to be actually trying to reach same value - I'll look on the code issues here.
Red Hat Enterprise Linux 7 shipped it's final minor release on September 29th, 2020. 7.9 was the last minor releases scheduled for RHEL 7.
From intial triage it does not appear the remaining Bugzillas meet the inclusion criteria for Maintenance Phase 2 and will now be closed.
From the RHEL life cycle page:
https://access.redhat.com/support/policy/updates/errata#Maintenance_Support_2_Phase
"During Maintenance Support 2 Phase for Red Hat Enterprise Linux version 7,Red Hat defined Critical and Important impact Security Advisories (RHSAs) and selected (at Red Hat discretion) Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available."
If this BZ was closed in error and meets the above criteria please re-open it flag for 7.9.z, provide suitable business and technical justifications, and follow the process for Accelerated Fixes:
https://source.redhat.com/groups/public/pnt-cxno/pnt_customer_experience_and_operations_wiki/support_delivery_accelerated_fix_release_handbook
Feature Requests can re-opened and moved to RHEL 8 if the desired functionality is not already present in the product.
Please reach out to the applicable Product Experience Engineer[0] if you have any questions or concerns.
[0] https://bugzilla.redhat.com/page.cgi?id=agile_component_mapping.html&product=Red+Hat+Enterprise+Linux+7
Created attachment 1474610 [details] Not tested patch which could fix it. Description of problem: lvrezsize %VG increase amount of allocated extents by 1, even if the LV was created wit same amount of percentage Version-Release number of selected component (if applicable): lvm2-2.02.177-4.el7.x86_64 How reproducible: Every time Steps to Reproduce: 1. vgcreate test_vg /dev/sdc 2. lvcreate -l 90%VG test_vg -n test 3. lvresize -l 90%VG test_vg/test [root@fastvm-rhel-7-5-uefi-24 ~]# lvcreate -l 90%VG test_vg -n test Logical volume "test" created. [root@fastvm-rhel-7-5-uefi-24 ~]# lvresize -l 90%VG test_vg/test Size of logical volume test_vg/test changed from <18.00 GiB (4607 extents) to 18.00 GiB (4608 extents). Logical volume test_vg/test successfully resized. [root@fastvm-rhel-7-5-uefi-24 ~]# Actual results: LV is resized by 1 extent. Expected results: LV is not resized. Additional info: The problem comes from different way of calling function `percent_of_extents`. lib/misc/lvm-percent.c: uint32_t percent_of_extents(uint32_t percents, uint32_t count, int roundup) { return (uint32_t)(((uint64_t)percents * (uint64_t)count + ((roundup) ? 99 : 0)) / 100); } While creating the LV the roundup parameter is 0. lvcreate: tools/lvcreate.c: ... switch (lcp->percent) { case PERCENT_VG: extents = percent_of_extents(lp->extents, base_calc_extents = vg->extent_count, 0); break; ... But while resizing it, it is 1 as a result of `!=` operator. lvresize: lib/metadata/lv_manip.c ... switch (lp->percent) { case PERCENT_VG: lp->extents = percent_of_extents(lp->extents, vg->extent_count, (lp->sign != SIGN_MINUS)); ...