[PATCH] [f12/master] Don't force logical with a free primary slot and an extended. (#527952)

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

 



Also rewrite getNextPartitionType for clarity so that bugs like this
will be easier to identify and fix in the future.
---
 storage/partitioning.py |   36 +++++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index 8c171aa..02761a2 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -448,25 +448,31 @@ def getNextPartitionType(disk, no_primary=None):
     max_logicals = disk.getMaxLogicalPartitions()
     primary_count = disk.primaryPartitionCount
 
-    if primary_count >= disk.maxPrimaryPartitionCount - 1:
-        if extended and logical_count < max_logicals:
-            part_type = parted.PARTITION_LOGICAL
-        elif primary_count < disk.maxPrimaryPartitionCount:
+    if primary_count < disk.maxPrimaryPartitionCount:
+        if primary_count == disk.maxPrimaryPartitionCount - 1:
+            # can we make an extended partition? now's our chance.
             if not extended and supports_extended:
-                # last chance to create an extended partition
                 part_type = parted.PARTITION_EXTENDED
-            elif not no_primary:
-                # it's either a primary or nothing
+            elif not extended:
+                # extended partitions not supported. primary or nothing.
+                if not no_primary:
+                    part_type = parted.PARTITION_NORMAL
+            else:
+                # there is an extended and a free primary
+                if not no_primary:
+                    part_type = parted.PARTITION_NORMAL
+                elif logical_count < max_logical:
+                    # we have an extended with logical slots, so use one.
+                    part_type = parted.PARTITION_LOGICAL
+        else:
+            # there are two or more primary slots left. use one unless we're
+            # not supposed to make primaries.
+            if not no_primary:
                 part_type = parted.PARTITION_NORMAL
-    elif no_primary and extended and logical_count < max_logicals:
-        # create a logical even though we could presumably create a
-        # primary instead
+            elif extended and logical_count < max_logicals:
+                part_type = parted.PARTITION_LOGICAL
+    elif extended and logical_count < max_logicals:
         part_type = parted.PARTITION_LOGICAL
-    elif not no_primary:
-        # XXX there is a possiblity that the only remaining free space on
-        #     the disk lies within the extended partition, but we will
-        #     try to create a primary first
-        part_type = parted.PARTITION_NORMAL
 
     return part_type
 
-- 
1.6.0.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