1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

thin: select chunk size as power of 2

Whenever thin-pool chunk size is unspecified and left for lvm calculation
try to select the size as nearest highest power-of-2 instead of
just being a multiple of 64KiB.
This commit is contained in:
Zdenek Kabelac 2019-01-28 19:50:41 +01:00
parent 58ad831c72
commit 78dd9d820d
2 changed files with 4 additions and 14 deletions

View File

@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
Thin-pool selects power-of-2 chunk size by default.
Cache selects power-of-2 chunk size by default.
Support reszing for VDOPoolLV and VDOLV.
Improve -lXXX%VG modifier which improves cache segment estimation.

View File

@ -580,20 +580,9 @@ static uint32_t _estimate_chunk_size(uint32_t data_extents, uint32_t extent_size
{
uint32_t chunk_size = _estimate_size(data_extents, extent_size, metadata_size);
if (attr & THIN_FEATURE_BLOCK_SIZE) {
/* Round up to 64KB */
chunk_size += DM_THIN_MIN_DATA_BLOCK_SIZE - 1;
chunk_size &= ~(uint32_t)(DM_THIN_MIN_DATA_BLOCK_SIZE - 1);
} else {
/* Round up to nearest power of 2 */
chunk_size--;
chunk_size |= chunk_size >> 1;
chunk_size |= chunk_size >> 2;
chunk_size |= chunk_size >> 4;
chunk_size |= chunk_size >> 8;
chunk_size |= chunk_size >> 16;
chunk_size++;
}
/* Always round up to nearest power of 2 of 32-bit,
* even when pool supports multiple of 64KiB */
chunk_size = 1 << (32 - clz(chunk_size - 1));
if (chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE)
chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;