diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-04 11:54:52 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-08 22:35:41 +0200 |
commit | d7c46b5e1e6c606f765198cf6a21f6dd997c6f2a (patch) | |
tree | 0deb847d5947f5bdbe5fa21e2362195193fc46dc /src/partition/repart.c | |
parent | repart: set new size for foreign partitions at first (diff) | |
download | systemd-d7c46b5e1e6c606f765198cf6a21f6dd997c6f2a.tar.xz systemd-d7c46b5e1e6c606f765198cf6a21f6dd997c6f2a.zip |
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.
Diffstat (limited to 'src/partition/repart.c')
-rw-r--r-- | src/partition/repart.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index 368c2cd289..4857579977 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -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; } |