[rhel7-branch 5/5] Make implicit partitions smaller if real requests don't fit anywhere

vpodzime installerbot-noreply at redhat.com
Wed Jun 3 18:27:13 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

In case of BTRFS/LVM autopartitioning we schedule one parition on every disk
used for the installation to be part of the new BTRFS/LVM setup. But in case
some other partition needs to be allocated (e.g. swap in case of BTRFS) we need
to fit this partition to some disk together with one of the implicitly scheduled
ones. In case we find out the implicitly scheduled partitions are too big to
make this possible we need to make them smaller so that autopartitioning works.

Resolves: rhbz#1171116
Related: rhbz#1202877
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
(cherry picked from commit 77c5f24b218010be81af50e75118b9c74d06086e)

Conflicts:
	blivet/devices.py
---
 blivet/devices/partition.py |  7 ++++++-
 blivet/partitioning.py      | 19 +++++--------------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
index 62e34ce..ca009d0 100644
--- a/blivet/devices/partition.py
+++ b/blivet/devices/partition.py
@@ -42,6 +42,11 @@
 from .dm import DMDevice
 from .lib import devicePathToName, deviceNameToDiskByPath
 
+DEFAULT_PART_SIZE = Size("500MiB")
+
+# in case the default partition size doesn't fit
+FALLBACK_DEFAULT_PART_SIZE = Size("10MiB")
+
 class PartitionDevice(StorageDevice):
     """ A disk partition.
 
@@ -54,7 +59,7 @@ class PartitionDevice(StorageDevice):
     """
     _type = "partition"
     _resizable = True
-    defaultSize = Size("500MiB")
+    defaultSize = DEFAULT_PART_SIZE
 
     def __init__(self, name, fmt=None,
                  size=None, grow=False, maxsize=None, start=None, end=None,
diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index 8e07763..69bb2c6 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -29,6 +29,7 @@
 from .errors import DeviceError, NoDisksError, NotEnoughFreeSpaceError, PartitioningError
 from .flags import flags
 from .devices import PartitionDevice, LUKSDevice, devicePathToName
+from .devices.partition import FALLBACK_DEFAULT_PART_SIZE
 from .formats import getFormat
 from .devicelibs.lvm import get_pool_padding
 from .size import Size
@@ -249,20 +250,10 @@ def _schedulePartitions(storage, disks, implicit_devices, min_luks_entropy=0, re
             smallest_implicit = sorted(implicit_devices, key=lambda d: d.size)[0]
             if (request.size + smallest_implicit.size) > all_free[0]:
                 # not enough space to allocate the smallest implicit partition
-                # and the request, make the implicit partition smaller with
-                # fixed size in order to make space for the request
-                new_size = all_free[0] - request.size
-
-                # subtract the size from the biggest free region and reorder the
-                # list
-                all_free[0] -= request.size
-                all_free.sort(reverse=True)
-
-                if new_size > Size(0):
-                    smallest_implicit.size = new_size
-                else:
-                    implicit_devices.remove(smallest_implicit)
-                    storage.destroyDevice(smallest_implicit)
+                # and the request, make the implicit partitions smaller in
+                # attempt to make space for the request
+                for implicit_req in implicit_devices:
+                    implicit_req.size = FALLBACK_DEFAULT_PART_SIZE
 
     return implicit_devices
 


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


More information about the anaconda-patches mailing list