1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

mirror: fix calcs for maximal region_size

Since extent_size is no longer power_of_2 this max region size
evalution was rather producing random bitsize as a combination
of lowest bit from number of extents and extent size itself.

Correct calculation to use whole LV size and pick biggest
possible power of 2 value smaller then UINT32_MAX.
This commit is contained in:
Zdenek Kabelac 2018-04-20 10:03:26 +02:00
parent 91965af9b1
commit a19456b868
2 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.178 -
=====================================
Fix evaluation of maximal region size for mirror log.
Enhance mirror log size estimation and use smaller size when possible.
Fix incorrect mirror log size calculation on 32bit arch.
Enhnace preloading tree creating.

View File

@ -161,17 +161,17 @@ uint32_t adjusted_mirror_region_size(struct cmd_context *cmd,
uint32_t extent_size, uint32_t extents,
uint32_t region_size, int internal, int clustered)
{
uint64_t region_max;
uint64_t region_min, region_min_pow2;
uint64_t region_max, region_min;
uint32_t region_min_pow2;
region_max = (UINT64_C(1) << (ffs((int)extents) - 1)) * (UINT64_C(1) << (ffs((int)extent_size) - 1));
region_max = (uint64_t) extents * extent_size;
if (region_max < UINT32_MAX && region_size > region_max) {
region_size = (uint32_t) region_max;
region_size = UINT64_C(1) << (31 - clz(region_max));
if (!internal)
log_print_unless_silent("Using reduced mirror region size of %s",
display_size(cmd, region_size));
else
else
log_verbose("Using reduced mirror region size of %s",
display_size(cmd, region_size));
}