PATCH: storage-branch: Maximize partitions after growing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In some cases the grow code would not use the entire disk, this patch fixes
this (and removes this item from the TODO list)
---
 storage/partitioning.py |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index 77a101d..75ab085 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -699,11 +699,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)
@@ -830,9 +825,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:
--
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux