From d1ac41dde0f6c0b204756c83ea4ec4df8e7bf685 Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Wed, 14 Aug 2024 03:15:17 -0700 Subject: [PATCH] fix ut Signed-off-by: Xiaoxi Chen --- src/lib/device/hs_super_blk.h | 15 +++++++-------- src/tests/test_pdev.cpp | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib/device/hs_super_blk.h b/src/lib/device/hs_super_blk.h index c6b85dbbe..a539c1e56 100644 --- a/src/lib/device/hs_super_blk.h +++ b/src/lib/device/hs_super_blk.h @@ -183,7 +183,9 @@ class hs_super_blk { static uint64_t chunk_super_block_size(const dev_info& dinfo); static uint64_t chunk_info_bitmap_size(const dev_info& dinfo) { // Chunk bitmap area has bitmap of max_chunks rounded off to 4k page - return sisl::round_up(bitset_serialized::nbytes(hs_super_blk::max_chunks_in_pdev(dinfo)), 4096)); + // add 4KB headroom for bitmap serialized header + auto bytes = sisl::round_up(hs_super_blk::max_chunks_in_pdev(dinfo), 8) / 8 + 4096; + return sisl::round_up(bytes, 4096); } static uint64_t total_size(const dev_info& dinfo) { return total_used_size(dinfo) + future_padding_size(dinfo); } @@ -197,13 +199,10 @@ class hs_super_blk { return (dinfo.dev_type == HSDevType::Fast) ? EXTRA_SB_SIZE_FOR_FAST_DEVICE : EXTRA_SB_SIZE_FOR_DATA_DEVICE; } static uint32_t max_chunks_in_pdev(const dev_info& dinfo) { - uint64_t min_chunk_size = - (dinfo.dev_type == HSDevType::Fast) ? MIN_CHUNK_SIZE_FAST_DEVICE : MIN_CHUNK_SIZE_DATA_DEVICE; -#ifdef _PRERELEASE - auto chunk_size = iomgr_flip::instance()->get_test_flip< long >("set_minimum_chunk_size"); - if (chunk_size) { min_chunk_size = chunk_size.get(); } -#endif - return (dinfo.dev_size - 1) / min_chunk_size + 1; + uint64_t min_c_size = min_chunk_size(dinfo.dev_type); + // Do not round up , for a device with 128MB and min_chunk_size = 16MB, we should get 8 chunks + // for a device with 100MB and min_chunk_size = 16MB, we should get 6 chunks, not 7. + return dinfo.dev_size / min_c_size; } static uint32_t min_chunk_size(HSDevType dtype) { uint64_t min_chunk_size = (dtype == HSDevType::Fast) ? MIN_CHUNK_SIZE_FAST_DEVICE : MIN_CHUNK_SIZE_DATA_DEVICE; diff --git a/src/tests/test_pdev.cpp b/src/tests/test_pdev.cpp index e28c8a933..4447c500b 100644 --- a/src/tests/test_pdev.cpp +++ b/src/tests/test_pdev.cpp @@ -44,8 +44,10 @@ SISL_OPTION_GROUP(test_pdev, ::cxxopts::value< uint32_t >()->default_value("2"), "number"), (data_dev_size_mb, "", "data_dev_size_mb", "size of each data device in MB", ::cxxopts::value< uint64_t >()->default_value("1024"), "number"), + // in OrderlyChunkOpsWithRestart UT, we need to create 10 chunks on fast drive + // ensure fast dev has > min_chunk_size_fast(32M) * 10 capacity. (fast_dev_size_mb, "", "fast_dev_size_mb", "size of each fast device in MB", - ::cxxopts::value< uint64_t >()->default_value("100"), "number"), + ::cxxopts::value< uint64_t >()->default_value("400"), "number"), (spdk, "", "spdk", "spdk", ::cxxopts::value< bool >()->default_value("false"), "true or false")); std::vector< std::string > g_data_dev_names;