[master 1/1] Allow aligning free regions to disk grainSize (#1244671)

vojtechtrefny installerbot-noreply at redhat.com
Wed Aug 5 11:49:53 UTC 2015


From: Vojtech Trefny <vtrefny at redhat.com>

Using full size of a free region results in PartitioningError
because blivet expects the size of new partition to be aligned
to disk grainSize (and rounds the size up if it isn't aligned).

Signed-off-by: Vojtech Trefny <vtrefny at redhat.com>
---
 blivet/partitioning.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index 69e79e5..b09857b 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -424,11 +424,13 @@ def addPartition(disklabel, free, part_type, size, start=None, end=None):
                                       constraint=constraint)
     return partition
 
-def getFreeRegions(disks):
+def getFreeRegions(disks, align=False):
     """ Return a list of free regions on the specified disks.
 
         :param disks: list of disks
         :type disks: list of :class:`~.devices.Disk`
+        :param align: align the region lenght to disk grainSize
+        :type align: bool
         :returns: list of free regions
         :rtype: list of :class:`parted.Geometry`
 
@@ -439,7 +441,12 @@ def getFreeRegions(disks):
     free = []
     for disk in disks:
         for f in disk.format.partedDisk.getFreeSpaceRegions():
-            if f.length >= disk.format.alignment.grainSize:
+            grain_size = disk.format.alignment.grainSize
+            if f.length >= grain_size:
+                if align:
+                    log.debug("lenght of free region aligned from %d to %d",
+                              f.length, f.length - (f.length % grain_size))
+                    f.length -= (f.length % grain_size)
                 free.append(f)
 
     return free


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/86c8f7317fa6b6965e4851c971881fd1d53e742b


More information about the anaconda-patches mailing list