From 2a503ad2a9c46e3867eae3d50c55e9077b5a0219 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 4 Sep 2022 18:51:55 +0900 Subject: [PATCH] repart: anyway run loop at the end even if the loop will be restarted later The order of the partitions processed in each phase does not change result for the first two phase (PHASE_OVERCHARGE and PHASE_UNDERCHARGE). --- src/partition/repart.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index 02d7dc8e10..b23d74bee4 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -736,6 +736,8 @@ static bool context_grow_partitions_phase( uint64_t *span, uint64_t *weight_sum) { + bool try_again = false; + assert(context); assert(a); assert(span); @@ -753,8 +755,8 @@ static bool context_grow_partitions_phase( continue; if (p->new_size == UINT64_MAX) { - bool charge = false, try_again = false; uint64_t share, rsz, xsz; + bool charge = false; /* Calculate how much this space this partition needs if everyone would get * the weight based share */ @@ -798,14 +800,11 @@ static bool context_grow_partitions_phase( *span = charge_size(context, *span, p->new_size); *weight_sum = charge_weight(*weight_sum, p->weight); } - - if (try_again) - return false; /* try again */ } if (p->new_padding == UINT64_MAX) { - bool charge = false, try_again = false; uint64_t share, rsz, xsz; + bool charge = false; share = scale_by_weight(*span, p->padding_weight, *weight_sum); @@ -827,13 +826,10 @@ static bool context_grow_partitions_phase( *span = charge_size(context, *span, p->new_padding); *weight_sum = charge_weight(*weight_sum, p->padding_weight); } - - if (try_again) - return false; /* try again */ } } - return true; /* done */ + return !try_again; } static void context_grow_partition_one(Context *context, FreeArea *a, Partition *p, uint64_t *span) {