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.
* 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;
}
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;
}