Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the first fitting gap for ESP, instead of the largest gap #1765

Merged
merged 5 commits into from
Aug 21, 2023

Conversation

mwhudson
Copy link
Collaborator

This is basically @medicalwei's #1764 with potentially useful functionality factored into a method.

@@ -252,6 +252,14 @@ def largest_gap_size(device, in_extended=None):
return 0


def gap_with_size(device, size, *, in_extended=None):
for pg in parts_and_gaps(device):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gap_with_size sounds like any gap will do that fits the requirement, or maybe even the closest gap (first gap is large, second gap is small but large enough, choose the second). Would you add a docstring clarifying intent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the method name to 'first_gap_with_size'. For this use case, finding the smallest suitable gap might actually make more sense but well. Minor stuff I think.

@@ -224,7 +224,7 @@ def get_add_part_plan(device, *, spec, args, resize_partition=None):
# is a bad idea. So avoid putting any sort of boot stuff on a logical -
# it's probably a bad idea for all cases.

gap = gaps.largest_gap(device, in_extended=False)
gap = gaps.gap_with_size(device, size, in_extended=False)
if gap is not None and gap.size >= size and gap.is_usable:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the logic is redundant now

@mwhudson mwhudson merged commit 76979c5 into canonical:main Aug 21, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants