summaryrefslogtreecommitdiffstats
path: root/lvm.py
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2002-06-12 03:33:34 +0000
committerJeremy Katz <katzj@redhat.com>2002-06-12 03:33:34 +0000
commit923d9e5e6733443eb553be1764feaf6076f177b7 (patch)
treec9d7056262cf474e9f9afb34453b862b49f2dbd4 /lvm.py
parent9d9a097d6a3b8fbca8b2c818345137944be8043f (diff)
downloadanaconda-923d9e5e6733443eb553be1764feaf6076f177b7.tar.gz
anaconda-923d9e5e6733443eb553be1764feaf6076f177b7.tar.xz
anaconda-923d9e5e6733443eb553be1764feaf6076f177b7.zip
try to make informed guesses about how much overhead there is on a per-physical volume basis. my eyes, my eyes.
Diffstat (limited to 'lvm.py')
-rw-r--r--lvm.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/lvm.py b/lvm.py
index b4a63dd95..998ba8225 100644
--- a/lvm.py
+++ b/lvm.py
@@ -14,6 +14,7 @@
import iutil
import os,sys
import string
+import math
output = "/tmp/lvmout"
@@ -132,13 +133,35 @@ def clampLVSizeRequest(size, pe):
def clampPVSize(pvsize, pesize):
"""Given a PV size and a PE, returns the usable space of the PV.
+ Takes into account both overhead of the physical volume and 'clamping'
+ to the PE size.
pvsize - size (in MB) of PV request
pesize - PE size (in KB)
"""
- return (long(pvsize*1024/pesize)*pesize)/1024
-
+ # calculate the number of physical extents. this is size / pesize
+ # with an appropriate factor for kb/mb matchup
+ numpes = math.floor(pvsize * 1024 / pesize)
+
+ # now, calculate our "real" overhead. 4 bytes for each PE + 128K
+ overhead = (4 * numpes / 1024) + 128
+
+ # now, heuristically, the max of ceil(pesize + 2*overhead) and
+ # ceil(2*overhead) is greater than the real overhead, so we won't
+ # get people in a situation where they overcommit the vg
+ one = math.ceil(pesize + 2 * overhead)
+ two = math.ceil(2 * overhead)
+
+ # now we have to do more unit conversion since our overhead in in KB
+ if one > two:
+ usable = pvsize - math.ceil(one / 1024.0)
+ else:
+ usable = pvsize - math.ceil(two / 1024.0)
+
+ # finally, clamp to being at a pesize boundary
+ return (long(usable*1024/pesize)*pesize)/1024
+
def getMaxLVSize(pe):
"""Given a PE size in KB, returns maximum size (in MB) of a logical volume.