]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: anyway run loop at the end even if the loop will be restarted later
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Sep 2022 09:51:55 +0000 (18:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 8 Sep 2022 20:35:41 +0000 (05:35 +0900)
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

index 02d7dc8e10bbc5e104722d6c706a620d2e9755ef..b23d74bee4c0ea652de43486e141735eb21a12eb 100644 (file)
@@ -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) {