diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-06 01:23:19 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-09 05:48:56 +0900 |
commit | f39cf264a68837c5347d8ead6e9a6b4e62d24ca8 (patch) | |
tree | 28c518247230d0b80af125680f2f00b42265dc4c /src | |
parent | d7c46b5e1e6c606f765198cf6a21f6dd997c6f2a (diff) | |
download | systemd-f39cf264a68837c5347d8ead6e9a6b4e62d24ca8.tar.gz |
repart: reset assignments by previous context_allocate_partitions()
The function context_allocate_partitions() may be called multiple times.
If this is called multiple times, then dropped partitions may still
assigned to free area.
Diffstat (limited to 'src')
-rw-r--r-- | src/partition/repart.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index 4857579977..5b999d5ba9 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -436,6 +436,8 @@ static bool context_drop_one_priority(Context *context) { continue; p->dropped = true; + p->allocated_to_area = NULL; + log_info("Can't fit partition %s of priority %" PRIi32 ", dropping.", p->definition_path, p->priority); /* We ensure that all verity sibling partitions have the same priority, so it's safe @@ -449,6 +451,7 @@ static bool context_drop_one_priority(Context *context) { continue; p->siblings[mode]->dropped = true; + p->siblings[mode]->allocated_to_area = NULL; log_info("Also dropping sibling verity %s partition %s", verity_mode_to_string(mode), p->siblings[mode]->definition_path); } @@ -621,6 +624,10 @@ static uint64_t charge_weight(uint64_t total, uint64_t amount) { static bool context_allocate_partitions(Context *context, uint64_t *ret_largest_free_area) { assert(context); + /* This may be called multiple times. Reset previous assignments. */ + for (size_t i = 0; i < context->n_free_areas; i++) + context->free_areas[i]->allocated = 0; + /* Sort free areas by size, putting smallest first */ typesafe_qsort_r(context->free_areas, context->n_free_areas, free_area_compare, context); |