summaryrefslogtreecommitdiffstats
path: root/storage/partitioning.py
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2009-03-24 18:02:39 -0500
committerDavid Lehman <dlehman@redhat.com>2009-03-24 19:47:07 -0500
commit9eff413553721203b7ff811175c4ca1e2f64ab38 (patch)
tree415927b9841f838a8263ccacb118e76651490c27 /storage/partitioning.py
parent82c16d2ca057417b6e02bb389b26005ea50477f4 (diff)
downloadanaconda-9eff413553721203b7ff811175c4ca1e2f64ab38.tar.gz
anaconda-9eff413553721203b7ff811175c4ca1e2f64ab38.tar.xz
anaconda-9eff413553721203b7ff811175c4ca1e2f64ab38.zip
Be a little bit smarter about allocating space to grow parts. (#491761)
parted.disk.Disk.maximizePartition leads to libparted applying a cylinder-alignment constraint, which we would frikking ask for if we wanted it. So, for now, we can use this to identify chunks of free space that will initially be allocated to requests whose max size will prevent them from making full use of their share of the space. Cases where this comes into play are ones where an initially larger request has a relatively low max size and an initially smaller request has no max size at all. Since we base the allocation of free space for growing on the requests' initial size, we could previously end up with very large chunks of unused free space.
Diffstat (limited to 'storage/partitioning.py')
-rw-r--r--storage/partitioning.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/storage/partitioning.py b/storage/partitioning.py
index f71665734..9f42a7299 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -835,11 +835,41 @@ def growPartitions(disks, partitions):
log.debug("growable total is now %d sectors" % disk_total)
# now we loop through the partitions...
+ # this first loop is to identify obvious chunks of free space that
+ # will be left over due to max size
+ leftover = 0
+ limited = {}
+ unlimited_total = 0
+ for part in growable:
+ # calculate max number of sectors this request can grow
+ req_sectors = part.partedPartition.geometry.length
+ share = float(req_sectors) / float(disk_total)
+ max_grow = (share * disk_free)
+ max_sectors = req_sectors + max_grow
+ limited[part.name] = False
+
+ if part.req_max_size:
+ req_max_sect = (part.req_max_size * (1024 * 1024)) / sectorSize
+ if req_max_sect < max_sectors:
+ mb = ((max_sectors - req_max_sect) * sectorSize) / (1024*1024)
+
+ log.debug("adding %dMB to leftovers from %s"
+ % (mb, part.name))
+ leftover += (max_sectors - req_max_sect)
+ limited[part.name] = True
+
+ if not limited[part.name]:
+ unlimited_total += req_sectors
+
+ # now we loop through the partitions...
for part in growable:
# calculate max number of sectors this request can grow
req_sectors = part.partedPartition.geometry.length
share = float(req_sectors) / float(disk_total)
max_grow = (share * disk_free)
+ if not limited[part.name]:
+ leftover_share = float(req_sectors) / float(unlimited_total)
+ max_grow += leftover_share * leftover
max_sectors = req_sectors + max_grow
max_mb = (max_sectors * sectorSize) / (1024 * 1024)
log.debug("%s: base_size=%dMB, max_size=%sMB" % (part.name,