mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvextend: improve percentage estimation
Correcting rounding rules for percentage evaluation. Validate supported range of percentage. (although ranges are already validated earlier on code path)
This commit is contained in:
parent
6d392776b0
commit
e7f5acdfa6
@ -1,5 +1,6 @@
|
|||||||
Version 2.03.11 -
|
Version 2.03.11 -
|
||||||
==================================
|
==================================
|
||||||
|
Enhance --use-policy percentage rounding.
|
||||||
Configure --with-vdo and --with-writecache as internal segments.
|
Configure --with-vdo and --with-writecache as internal segments.
|
||||||
Improving VDO man page examples.
|
Improving VDO man page examples.
|
||||||
Switch code base to use flexible array syntax.
|
Switch code base to use flexible array syntax.
|
||||||
|
@ -4932,7 +4932,7 @@ static int _fsadm_cmd(enum fsadm_cmd_e fcmd,
|
|||||||
|
|
||||||
static uint32_t _adjust_amount(dm_percent_t percent, int policy_threshold, int policy_amount)
|
static uint32_t _adjust_amount(dm_percent_t percent, int policy_threshold, int policy_amount)
|
||||||
{
|
{
|
||||||
if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) ||
|
if (!((50 * DM_PERCENT_1) < percent && percent <= DM_PERCENT_100) ||
|
||||||
percent <= (policy_threshold * DM_PERCENT_1))
|
percent <= (policy_threshold * DM_PERCENT_1))
|
||||||
return 0; /* nothing to do */
|
return 0; /* nothing to do */
|
||||||
/*
|
/*
|
||||||
@ -4940,7 +4940,7 @@ static uint32_t _adjust_amount(dm_percent_t percent, int policy_threshold, int p
|
|||||||
* Keep using DM_PERCENT_1 units for better precision.
|
* Keep using DM_PERCENT_1 units for better precision.
|
||||||
* Round-up to needed percentage value
|
* Round-up to needed percentage value
|
||||||
*/
|
*/
|
||||||
percent = (percent / policy_threshold + (DM_PERCENT_1 - 1) / 100) / (DM_PERCENT_1 / 100) - 100;
|
percent = ((percent + policy_threshold - 1) / policy_threshold) / (DM_PERCENT_1 / 100) - 100;
|
||||||
|
|
||||||
/* Use it if current policy amount is smaller */
|
/* Use it if current policy amount is smaller */
|
||||||
return (policy_amount < percent) ? (uint32_t) percent : (uint32_t) policy_amount;
|
return (policy_amount < percent) ? (uint32_t) percent : (uint32_t) policy_amount;
|
||||||
|
Loading…
Reference in New Issue
Block a user