diff options
author | David Lehman <dlehman@redhat.com> | 2009-10-20 11:33:18 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2009-10-20 11:33:18 -0500 |
commit | e7c3ef925d8e36b8d556d7653b11c2e09d0c4b59 (patch) | |
tree | 54b1af66bcaf6c210b3031c89f70606d1f5da667 | |
parent | 4ba5b5876d4c7234b9149ffe4ab400c5a990f873 (diff) | |
download | anaconda-e7c3ef925d8e36b8d556d7653b11c2e09d0c4b59.tar.gz anaconda-e7c3ef925d8e36b8d556d7653b11c2e09d0c4b59.tar.xz anaconda-e7c3ef925d8e36b8d556d7653b11c2e09d0c4b59.zip |
Don't force logical with a free primary slot and an extended. (#527952)
Also rewrite getNextPartitionType for clarity so that bugs like this
will be easier to identify and fix in the future.
-rw-r--r-- | storage/partitioning.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/storage/partitioning.py b/storage/partitioning.py index 8c171aad6..02761a231 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 |