repart: Sort the partition list by partition offset#42488
Open
jonas2515 wants to merge 2 commits into
Open
Conversation
Claude review of PR #42488 (b08d5a4)The reordering logic is correct and memory-safe — node ownership stays well-defined, the list head stays consistent, the insertion sorts terminate, and no downstream consumer (partno/offset assignment, supplement resolution, place/grow, JSON dump) depends on the old ordering. The new integration test is auto-discovered, deterministic across architectures, self-consistent, and would fail without the code change. A few maintainability/clarity notes only: Suggestions
Nits
|
7b2d6bf to
ef0dfd3
Compare
ef0dfd3 to
23f366d
Compare
23f366d to
86cc59f
Compare
Claude found a small bug with the partition table we print: We filter out partitions with p->dropped while making the table, but we want to put an underline after the last row of the table. In the case where the last entry in the context->partitions list is a dropped partition, the check for !p->partitions_next returns FALSE when it actually *is* the last row in the table. So move to a check that's based on a pre-counted number of partitions to print rather than checking for !p->partitions_next. Co-developed-by: Claude Opus 4.8 <[email protected]>
Currently the partition list is ordered like this: First come the partitions that exist as definition files (could be pre-existing partitions or could be new ones), then come the pre-existing partitions that aren't matched to a definition file. This ordering is visible to the user when we print our partition table, and it doesn't really make sense from a UX perspective: Partition tables are usually either presented in order of the partition indices, or in order of the partition offsets. Arguably the latter would be nicer here, since the visualization below is already ordered by physical offsets. So reorder the list after we assigned the new partitions to their respective free areas, according to the physical offset (or, for partitions to newly create, the order that we will allocate them in). Another potential upside of this is that we could rely on the partition order in the code now more, too. To ensure it keeps working, also add a test in the integration tests for it.
86cc59f to
b08d5a4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the partition list is ordered like this: First come the partitions that exist as definition files (could be pre-existing partitions or could be new ones), then come the pre-existing partitions that aren't matched to a definition file.
This ordering is visible to the user when we print our partition table, and it doesn't really make sense from a UX perspective: Partition tables are usually either presented in order of the partition indices, or in order of the partition offsets. Arguably the latter would be nicer here, since the visualization below is already ordered by physical offsets.
So reorder the list after we assigned the new partitions to their respective free areas, according to the physical offset (or, for partitions to newly create, the order that we will allocate them in).
Another potential upside of this is that we could rely on the partition order in the code now more, too.
To ensure it keeps working, also add a test in the integration tests for it.
Screenshot before:

Screenshot after: