From: "Brian C. Lane" bcl@redhat.com
Make sure that we don't even look at regions shorter than the alignment grain size, and that free regions have sufficient length after aligning the start and end sector before instantiating a DiskChunk.
(cherry picked from python-blivet commits 897889b8a294ea240e2b5a4ae3714ed7a7363c79 and 178c933748692bfae1134e5db4ade014affabf04) Resolves: rhbz#1236506 --- storage/partitioning.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/storage/partitioning.py b/storage/partitioning.py index 57ebfa5..544378b 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -856,12 +856,14 @@ def getFreeRegions(disks): disks -- list of parted.Disk instances
Return value is a list of unaligned parted.Geometry instances. + Only free regions guaranteed to contain at least one aligned sector for + both the start and end alignments in the disklabel are returned.
""" free = [] for disk in disks: for f in disk.format.partedDisk.getFreeSpaceRegions(): - if f.length > 0: + if f.length >= disk.format.alignment.grainSize: free.append(f)
return free @@ -1543,7 +1545,7 @@ def getDiskChunks(disk, partitions, free): free -- list of parted.Geometry instances representing free space
Partitions and free regions not on the specified disk are ignored. - + Chunks contain an aligned version of the free region's geometry. """ # list of all new partitions on this disk disk_parts = [p for p in partitions if p.disk == disk and not p.exists] @@ -1552,10 +1554,23 @@ def getDiskChunks(disk, partitions, free):
chunks = [] for f in disk_free: - # align the geometry so we have a realistic view of the free space + # Align the geometry so we have a realistic view of the free space. + # alignUp and alignDown can align in the reverse direction if the only + # aligned sector within the geometry is in that direction, so we have to + # also check that the resulting aligned geometry has a non-zero length. + # (It is possible that both will align to the same sector in a small + # enough region.) + al_start = disk.format.alignment.alignUp(f, f.start) + al_end = disk.format.endAlignment.alignDown(f, f.end) + if al_start >= al_end: + continue + geom = parted.Geometry(device=f.device, - start=disk.format.alignment.alignUp(f, f.start), - end=disk.format.endAlignment.alignDown(f, f.end)) + start=al_start, + end=al_end) + if geom.length < disk.format.alignment.grainSize: + continue + chunks.append(Chunk(geom))
for p in disk_parts:
From: "Brian C. Lane" bcl@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)
Added label: rhel6-branch.
Looks good, but you might want to add rhinstaller/blivet@178c9337.
Done, squashed it into the other one.
Added label: ACK.
Closed.
anaconda-patches@lists.fedorahosted.org