Bug 1021505 - blivet reports wrong LVMVolumeGroupDevice.freeExtents
blivet reports wrong LVMVolumeGroupDevice.freeExtents
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python-blivet (Show other bugs)
Unspecified Unspecified
unspecified Severity high
: rc
: ---
Assigned To: mulhern
Release Test Team
Depends On:
  Show dependency treegraph
Reported: 2013-10-21 08:25 EDT by Jan Safranek
Modified: 2015-03-05 09:05 EST (History)
2 users (show)

See Also:
Fixed In Version: python-blivet-
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-03-05 09:05:36 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
reproducer (663 bytes, text/x-python)
2013-10-21 08:25 EDT, Jan Safranek
no flags Details

  None (edit)
Description Jan Safranek 2013-10-21 08:25:52 EDT
Created attachment 814560 [details]

Description of problem:
Let's consider this setup:
$ vgcreate test /dev/sdb1
$ lvcreate -l 2 -n 00 test
$ vgdisplay
  --- Volume group ---
  VG Name               test
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               92.00 MiB
  PE Size               4.00 MiB
  Total PE              23
  Alloc PE / Size       2 / 8.00 MiB
  Free  PE / Size       21 / 84.00 MiB
  VG UUID               NJA1Qr-yf3e-7WVU-5bHj-Q3mZ-1yEL-5FMQXr

So, 2 extents are used, 21 extents are free. But blivet reports 23 free extents:

LVMVolumeGroupDevice instance (0x2925590) --
  format args = []  originalFormat = None  target = None  dmUuid = None  free = 84.0  PE Size = 4.0  PE Count = 23
  PE Free = 21  PV Count = 1
  LV Names = ['00']  modified = False
  extents = 23.0  free space = 92
  free extents = 23.0  reserved percent = 0  reserved space = 0
vg.freeExtents = 23
vg.peFree = 21

OpenLMI has used freeExtents so far, is there some API change and should we switch to peFree?

In the reproducer debug logs I can see LVMLogicalVolumeDevice printed once with parent LVMVolumeGroupDevice.free extents = 21.0 and once with free extents = 23.0; something has changed it in the meantime.

Version-Release number of selected component:
(python-blivet-0.18.6-1.el7.noarch works fine)

This bug applies also to rawhide.
Comment 2 David Lehman 2013-10-21 11:08:10 EDT
peFree is taken directly from lvm and does not get updated without a reset.

freeExtents is blivet doing its best to guess how many extents are free based on what it knows about how lvm uses space in the vg. Normally if this number is wrong it is showing too few free extents, so this is puzzling.

I'll take a look at the reproducer.
Comment 4 mulhern 2014-09-11 18:12:54 EDT
So, peFree is set during discovery from udev info, and not used anywhere, AFAICT.

freeExtents is just freeSpace/peSize rounded to the nearest whole number. 100 to 1 freeSpace is the culprit, since peSize really ought not to move around much. To get this right, free space should be less than 88 but it is at least 92 and probably no more. Just looking at probabilities, it seems unlikely that the vg.size is too big, more likely that the things subtracted from it are too small.
Comment 5 mulhern 2014-09-12 10:09:08 EDT
Could you verify that this is still occurring?

I ran a test in current rhel7 and the free extents calculated by blivet for the vg matched those reported by vgdisplay.

If you can still reproduce it can you give more specifics about /dev/sdb1 and include logs?

Comment 6 Jan Safranek 2014-09-16 03:50:05 EDT
Tested today with python-blivet- from brew, it seems to be fixed. vg.freeExtents and vg.peFree are consistent now.
Comment 9 Jan Safranek 2015-01-15 03:13:29 EST
I checked with python-blivet- that peFree and freeExtents are the same on my system. They get different when an LV is created (as comment #2 says, this is expected) and they get the same after blivet.reset().

So, from OpenLMI point of view, the bug is fixed.
Comment 12 errata-xmlrpc 2015-03-05 09:05:36 EST
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.


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