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

Vratislav Podzimek vpodzime at redhat.com
Wed Jan 21 09:06:34 UTC 2015


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
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 blivet/devices.py      |  7 ++++++-
 blivet/partitioning.py | 20 +++++---------------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/blivet/devices.py b/blivet/devices.py
index f67c5b5..576fe07 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -53,6 +53,11 @@ from .i18n import P_
 import logging
 log = logging.getLogger("blivet")
 
+DEFAULT_PART_SIZE = Size("500MiB")
+
+# in case the default partition size doesn't fit
+FALLBACK_DEFAULT_PART_SIZE = Size("10MiB")
+
 def get_device_majors():
     majors = {}
     for line in open("/proc/devices").readlines():
@@ -1368,7 +1373,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 24cb982..f909de2 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -28,7 +28,7 @@ from pykickstart.constants import AUTOPART_TYPE_BTRFS, AUTOPART_TYPE_LVM, AUTOPA
 
 from .errors import DeviceError, NoDisksError, NotEnoughFreeSpaceError, PartitioningError, SanityError, SanityWarning
 from .flags import flags
-from .devices import PartitionDevice, LUKSDevice, devicePathToName
+from .devices import PartitionDevice, LUKSDevice, devicePathToName, FALLBACK_DEFAULT_PART_SIZE
 from .formats import getFormat
 from .devicelibs.lvm import get_pool_padding
 from .size import Size
@@ -243,20 +243,10 @@ def _schedulePartitions(storage, disks, implicit_devices, min_luks_entropy=0):
             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
 
-- 
2.1.0



More information about the anaconda-patches mailing list