[rhel6-branch 2/2] Align end sector in the appropriate direction for resize. (#1236506)

bcl installerbot-noreply at redhat.com
Mon Jun 29 22:21:32 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

When shrinking, align the end sector up to ensure the aligned partition
is still larger than the formatting's minimum size.

When growing, align the end sector down to ensure the aligned partition
is completely within the free region (and not larger than the formatting's
maximum size).

(cherry picked from python-blivet commit 1583dcc24dbbfd64cfff1f62339d9eb9e24f38c2)
Resolves: rhbz#1236506
---
 storage/devices.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 139c3e3..21f5da9 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1363,8 +1363,14 @@ def _computeResize(self, partition):
                                       start=currentGeom.start,
                                       length=newLen)
         # and align the end sector
-        newGeometry.end = self.disk.format.endAlignment.alignDown(newGeometry,
-                                                               newGeometry.end)
+        if newGeometry.length < currentGeom.length:
+            align = self.disk.format.endAlignment.alignUp
+            alignGeom = currentGeom # we can align up into the old geometry
+        else:
+            align = self.disk.format.endAlignment.alignDown
+            alignGeom = newGeometry
+
+        newGeometry.end = align(alignGeom, newGeometry.end)
         constraint = parted.Constraint(exactGeom=newGeometry)
 
         return (constraint, newGeometry)


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/615c77c5caea6eb139c9007003187bcc4f2a1bee


More information about the anaconda-patches mailing list