[PATCH] Correct and simplify handling of "bootable" partition requests (#804915)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: David Lehman <dlehman@xxxxxxxxxx>

Base everything on the request's weight. Since the weight tells us
what we need to know, we can remove the explicit check for a
bootable req from partitionCompare.

cherry-picked from 962f77eb
Modifications by Brian C. Lane <bcl@xxxxxxxxxx>

Resolves: rhbz#804915

NOTE: Tested on x86_64, x86_64 EFI and PPC64
---
 platform.py             |    5 ++++-
 storage/partitioning.py |   35 +++++++----------------------------
 2 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/platform.py b/platform.py
index bffa73a..3cd9116 100644
--- a/platform.py
+++ b/platform.py
@@ -230,7 +230,10 @@ class Platform(object):
             for the base sorting weight.  This is used to modify the sort
             algorithm for partition requests, mainly to make sure bootable
             partitions and /boot are placed where they need to be."""
-        return 0
+        if mountpoint and mountpoint == "/boot":
+            return 2000
+        else:
+            return 0
 
 class EFI(Platform):
     _bootFSTypes = ["ext4", "ext3", "ext2"]
diff --git a/storage/partitioning.py b/storage/partitioning.py
index 46418a2..b038c23 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -514,9 +514,6 @@ def partitionCompare(part1, part2):
     if part2.req_base_weight:
         ret += part2.req_base_weight
 
-    # bootable partitions to the front
-    ret -= cmp(part1.req_bootable, part2.req_bootable) * 1000
-
     # more specific disk specs to the front of the list
     # req_disks being empty is equivalent to it being an infinitely long list
     if part1.req_disks and not part2.req_disks:
@@ -997,19 +994,6 @@ def allocatePartitions(storage, disks, partitions, freespace):
 
     removeNewPartitions(disks, new_partitions)
 
-    # Search for the /boot partition.
-    # If there is not a separate /boot partition,
-    # the /boot will end up on the / partition.
-    # We need this later for apple's bootstrap and prepboot,
-    # because this partition needs to be on the same disk
-    # as bootstrap/prepboot partition.
-    # Only do this on systems that need it.
-    _boot_part = "/boot"
-    pl = platform.getPlatform(None)
-    if pl.weight(fstype="prepboot") or pl.weight(fstype="appleboot"):
-        if "/boot" not in storage.mountpoints and "/" in storage.mountpoints:
-            _boot_part = "/"
-
     for _part in new_partitions:
         if _part.partedPartition and _part.isExtended:
             # ignore new extendeds as they are implicit requests
@@ -1039,11 +1023,13 @@ def allocatePartitions(storage, disks, partitions, freespace):
             boot_disk = req_disks.pop(boot_index)
             req_disks.insert(0, boot_disk)
 
+        boot = _part.req_base_weight > 1000
+
         log.debug("allocating partition: %s ; id: %d ; disks: %s ;\n"
                   "boot: %s ; primary: %s ; size: %dMB ; grow: %s ; "
                   "max_size: %s" % (_part.name, _part.id,
                                     [d.name for d in req_disks],
-                                    _part.req_bootable, _part.req_primary,
+                                    boot, _part.req_primary,
                                     _part.req_size, _part.req_grow,
                                     _part.req_max_size))
         free = None
@@ -1095,7 +1081,7 @@ def allocatePartitions(storage, disks, partitions, freespace):
                                           new_part_type,
                                           _part.req_size,
                                           best_free=current_free,
-                                          boot=_part.req_bootable,
+                                          boot=boot,
                                           grow=_part.req_grow)
 
             if best == free and not _part.req_primary and \
@@ -1109,7 +1095,7 @@ def allocatePartitions(storage, disks, partitions, freespace):
                                                   new_part_type,
                                                   _part.req_size,
                                                   best_free=current_free,
-                                                  boot=_part.req_bootable,
+                                                  boot=boot,
                                                   grow=_part.req_grow)
 
             if best and free != best:
@@ -1195,14 +1181,7 @@ def allocatePartitions(storage, disks, partitions, freespace):
                                 growth)
                     free = best
 
-            # For platforms with a fake boot partition (like Apple Bootstrap or
-            # PReP) and multiple disks, we need to ensure the /boot partition
-            # ends up on the same disk as the fake one.
-            mountpoint = getattr(_part.format, "mountpoint", "")
-            if not mountpoint:
-                mountpoint = ""
-
-            if free and (_part.req_bootable or mountpoint == _boot_part):
+            if free and boot:
                 # if this is a bootable partition we want to
                 # use the first freespace region large enough
                 # to satisfy the request
@@ -1228,7 +1207,7 @@ def allocatePartitions(storage, disks, partitions, freespace):
             free = getBestFreeSpaceRegion(disklabel.partedDisk,
                                           part_type,
                                           _part.req_size,
-                                          boot=_part.req_bootable,
+                                          boot=boot,
                                           grow=_part.req_grow)
             if not free:
                 raise PartitioningError("not enough free space after "
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux