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. --- storage/partitioning.py | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/storage/partitioning.py b/storage/partitioning.py index f716657..9f42a72 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, -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list