[PATCH 3/7] Only include following free space in partitions' max size.

David Lehman dlehman at redhat.com
Wed Sep 12 15:50:53 UTC 2012


Leading space isn't useful for growing a filesystem.
---
 pyanaconda/storage/devices.py |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index d01693f..aaf4763 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -1615,13 +1615,21 @@ class PartitionDevice(StorageDevice):
     @property
     def maxSize(self):
         """ The maximum size this partition can be. """
-        # XXX: this is MB by default
-        maxPartSize = self.partedPartition.getMaxAvailableSize()
-
-        if self.format.maxSize > maxPartSize:
-            return maxPartSize
+        # XXX Only allow growth up to the amount of free space following this
+        #     partition on disk. We don't care about leading free space --
+        #     a filesystem cannot be relocated, so if you want to use space
+        #     before and after your partition, remove it and create a new one.
+        sector = self.partedPartition.geometry.end + 1
+        maxPartSize = self.size
+        try:
+            partition = self.partedPartition.disk.getPartitionBySector(sector)
+        except _ped.PartitionException:
+            pass
         else:
-            return self.format.maxSize
+            if partition.type == parted.PARTITION_FREESPACE:
+                maxPartSize = self.size + math.floor(partition.getSize())
+
+        return min(self.format.maxSize, maxPartSize)
 
     @property
     def currentSize(self):
-- 
1.7.7.6



More information about the anaconda-patches mailing list