diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-11-09 16:25:00 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-11-09 16:25:00 +0100 |
commit | ae0613c6c4cf8aa2d924c9468e8dac1e792a4e71 (patch) | |
tree | 6f5b89ae2ad008b63714d8f7ec7e7a98789b0de2 /src/partition | |
parent | repart: use LESS_BY() more (diff) | |
download | systemd-ae0613c6c4cf8aa2d924c9468e8dac1e792a4e71.tar.xz systemd-ae0613c6c4cf8aa2d924c9468e8dac1e792a4e71.zip |
repart: simplify stat machine we mostly go through linearly
Diffstat (limited to 'src/partition')
-rw-r--r-- | src/partition/repart.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index 482ef156ef..db2f95afc7 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -644,6 +644,8 @@ typedef enum GrowPartitionPhase { /* The third phase: we distribute what remains among the remaining partitions, according to the weights */ PHASE_DISTRIBUTE, + + _GROW_PARTITION_PHASE_MAX, } GrowPartitionPhase; static int context_grow_partitions_phase( @@ -779,20 +781,14 @@ static int context_grow_partitions_on_free_area(Context *context, FreeArea *a) { span += round_up_size(a->after->offset + a->after->current_size, 4096) - a->after->offset; } - GrowPartitionPhase phase = PHASE_OVERCHARGE; - for (;;) { + for (GrowPartitionPhase phase = 0; phase < _GROW_PARTITION_PHASE_MAX;) { r = context_grow_partitions_phase(context, a, phase, &span, &weight_sum); if (r < 0) return r; if (r == 0) /* not done yet, re-run this phase */ continue; - if (phase == PHASE_OVERCHARGE) - phase = PHASE_UNDERCHARGE; - else if (phase == PHASE_UNDERCHARGE) - phase = PHASE_DISTRIBUTE; - else if (phase == PHASE_DISTRIBUTE) - break; + phase++; /* got to next phase */ } /* We still have space left over? Donate to preceding partition if we have one */ |