1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-29 21:55:36 +03:00

repart: do not assign new size larger than acquired or the specified maximum

The acquired size may be larger than the requested maximum. So, let's
cap the value.

Note, at the final phase, the acquired size should be larger than the
requested minimum. Hence, the assertion about that is added.
This commit is contained in:
Yu Watanabe 2022-09-04 18:54:52 +09:00
parent bf99aed6e8
commit d7c46b5e1e

View File

@ -796,7 +796,8 @@ static bool context_grow_partitions_phase(
* assigning this shouldn't impact the shares of the other
* partitions. */
p->new_size = MAX(round_down_size(share, context->grain_size), rsz);
assert(share >= rsz);
p->new_size = CLAMP(round_down_size(share, context->grain_size), rsz, xsz);
charge = true;
}
@ -822,7 +823,8 @@ static bool context_grow_partitions_phase(
p->new_padding = xsz;
charge = try_again = true;
} else if (phase == PHASE_DISTRIBUTE) {
p->new_padding = MAX(round_down_size(share, context->grain_size), rsz);
assert(share >= rsz);
p->new_padding = CLAMP(round_down_size(share, context->grain_size), rsz, xsz);
charge = true;
}