master - thin: select chunk size as power of 2
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=78dd9d820da44c6b9907b481231745590e94613d Commit: 78dd9d820da44c6b9907b481231745590e94613d Parent: 58ad831c72b024233d91980f2269d0a26101ff99 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Jan 28 19:50:41 2019 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Jan 28 22:17:25 2019 +0100
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.
--- WHATS_NEW | 1 + lib/metadata/thin_manip.c | 17 +++-------------- 2 files changed, 4 insertions(+), 14 deletions(-)
WHATS_NEW +1 -0
@@ -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.
lib/metadata/thin_manip.c +3 -14
@@ -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 ;