mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lv_manip: ensure it will fit bellow threshold
Use single code to evaluate if the percentage value has crossed threshold. Recalculate amount value to always fit bellow threshold so there are not need any extra reiterations to reach this state in case policy amount is too small.
This commit is contained in:
parent
b780d329aa
commit
40eea582ae
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.133 -
|
Version 2.02.133 -
|
||||||
======================================
|
======================================
|
||||||
|
Ensure --use-policy will resize volume to fit below threshold.
|
||||||
Correct percentage evaluation when checking thin-pool over threshold.
|
Correct percentage evaluation when checking thin-pool over threshold.
|
||||||
Fix lvmcache to move PV from VG to orphans if VG is removed and lvmetad used.
|
Fix lvmcache to move PV from VG to orphans if VG is removed and lvmetad used.
|
||||||
Fix lvmcache to not cache even invalid info about PV which got removed.
|
Fix lvmcache to not cache even invalid info about PV which got removed.
|
||||||
|
@ -4424,6 +4424,25 @@ static int _fsadm_cmd(struct cmd_context *cmd,
|
|||||||
return exec_cmd(cmd, argv, status, 1);
|
return exec_cmd(cmd, argv, status, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _adjust_amount(dm_percent_t percent, int policy_threshold, int *policy_amount)
|
||||||
|
{
|
||||||
|
if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) ||
|
||||||
|
percent <= (policy_threshold * DM_PERCENT_1))
|
||||||
|
return 0;
|
||||||
|
/*
|
||||||
|
* Evaluate the minimal amount needed to get bellow threshold.
|
||||||
|
* Keep using DM_PERCENT_1 units for better precision.
|
||||||
|
* Round-up to needed percentage value
|
||||||
|
*/
|
||||||
|
percent = (percent/policy_threshold + (DM_PERCENT_1 - 1) / 100) / (DM_PERCENT_1 / 100) - 100;
|
||||||
|
|
||||||
|
/* Use it if current policy amount is smaller */
|
||||||
|
if (*policy_amount < percent)
|
||||||
|
*policy_amount = percent;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int _adjust_policy_params(struct cmd_context *cmd,
|
static int _adjust_policy_params(struct cmd_context *cmd,
|
||||||
struct logical_volume *lv, struct lvresize_params *lp)
|
struct logical_volume *lv, struct lvresize_params *lp)
|
||||||
{
|
{
|
||||||
@ -4469,35 +4488,29 @@ static int _adjust_policy_params(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
policy_threshold *= DM_PERCENT_1;
|
|
||||||
|
|
||||||
if (lv_is_thin_pool(lv)) {
|
if (lv_is_thin_pool(lv)) {
|
||||||
if (!lv_thin_pool_percent(lv, 1, &percent))
|
if (!lv_thin_pool_percent(lv, 1, &percent))
|
||||||
return_0;
|
return_0;
|
||||||
if ((DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) &&
|
if (_adjust_amount(percent, policy_threshold, &policy_amount)) {
|
||||||
(percent > policy_threshold)) {
|
|
||||||
if (!thin_pool_feature_supported(lv, THIN_FEATURE_METADATA_RESIZE)) {
|
if (!thin_pool_feature_supported(lv, THIN_FEATURE_METADATA_RESIZE)) {
|
||||||
log_error_once("Online metadata resize for %s/%s is not supported.",
|
log_error_once("Online metadata resize for %s is not supported.",
|
||||||
lv->vg->name, lv->name);
|
display_lvname(lv));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lp->poolmetadatasize = (first_seg(lv)->metadata_lv->size *
|
lp->poolmetadatasize = (first_seg(lv)->metadata_lv->size *
|
||||||
policy_amount + 99) / 100;
|
policy_amount + 99) / 100;
|
||||||
lp->poolmetadatasign = SIGN_PLUS;
|
lp->poolmetadatasign = SIGN_PLUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lv_thin_pool_percent(lv, 0, &percent))
|
if (!lv_thin_pool_percent(lv, 0, &percent))
|
||||||
return_0;
|
return_0;
|
||||||
if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) ||
|
|
||||||
percent <= policy_threshold)
|
|
||||||
return 1;
|
|
||||||
} else {
|
} else {
|
||||||
if (!lv_snapshot_percent(lv, &percent))
|
if (!lv_snapshot_percent(lv, &percent))
|
||||||
return_0;
|
return_0;
|
||||||
if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) || percent <= policy_threshold)
|
|
||||||
return 1; /* nothing to do */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_adjust_amount(percent, policy_threshold, &policy_amount))
|
||||||
|
return 1; /* nothing to do */
|
||||||
|
|
||||||
lp->extents = policy_amount;
|
lp->extents = policy_amount;
|
||||||
lp->sizeargs = (lp->extents) ? 1 : 0;
|
lp->sizeargs = (lp->extents) ? 1 : 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user