diff options
author | Hans de Goede <hdegoede@redhat.com> | 2009-03-03 09:23:15 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2009-03-03 09:23:15 +0100 |
commit | 2c82b2c4e0e0bbfa510dd5d5d26a31e0b20117da (patch) | |
tree | 7b1f8409c57b8d2cf8460cd4051d9c645b1b3db2 /storage/partitioning.py | |
parent | 90a8ecb9470e3583fbfea3125be914be8d36e2e7 (diff) | |
download | anaconda-2c82b2c4e0e0bbfa510dd5d5d26a31e0b20117da.tar.gz anaconda-2c82b2c4e0e0bbfa510dd5d5d26a31e0b20117da.tar.xz anaconda-2c82b2c4e0e0bbfa510dd5d5d26a31e0b20117da.zip |
Maximize partitions after growing
In some cases the grow code would not use the entire disk, this patch fixes
this (and removes this item from the TODO list)
Diffstat (limited to 'storage/partitioning.py')
-rw-r--r-- | storage/partitioning.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/storage/partitioning.py b/storage/partitioning.py index 3331518c5..c10986533 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -707,11 +707,6 @@ def growPartitions(disks, partitions): this fails, we begin a rough binary search with a maximum of three iterations to settle on a new size. - TODO: Call disk.maximizePartition for each growable partition that - has not been allocated its full share of the free space upon - termination of each disk's loop iteration. Any detected - maximum size can be specified via a parted Constraint. - Arguments: disks -- a list of all usable disks (DiskDevice instances) @@ -840,9 +835,25 @@ def growPartitions(disks, partitions): except PartitioningError, e: raise PartitioningError("failed to grow partitions") - # TODO: call disk.maximizePartition with max_size as the - # constraint, in case it can grab some more free space + # Maximize partitions, we do this after growing all partitions + # as some partitions may grow unlimited, and we don't want them + # eating up the entire disk when we still need to grow others + for part in growable: + constraint = parted.Constraint(device=disk.partedDisk.device) + + # don't grow beyond the request's maximum size + if part.req_max_size: + max_sect = (part.req_max_size * (1024 * 1024)) / sectorSize + if constraint.max_size > max_sect: + constraint.max_size = max_sect + + # don't grow beyond the resident filesystem's max size + if part.format.maxSize > 0: + max_sect = (part.format.maxSize * (1024 * 1024)) / sectorSize + if constraint.max_size > max_sect: + constraint.max_size = max_sect + disk.partedDisk.maximizePartition(part.partedPartition, constraint) # reset all requests to their original requested size for part in partitions: |