From cd4d671e22040f3195d5b2a9b972bfae107dbec9 Mon Sep 17 00:00:00 2001 From: Sanal Date: Thu, 5 Oct 2023 09:51:41 -0700 Subject: [PATCH] Add blkid's serialize api's. (#196) --- conanfile.py | 2 +- src/include/homestore/blk.h | 2 ++ src/lib/blkalloc/blk.cpp | 5 ++--- src/lib/common/resource_mgr.hpp | 2 +- src/tests/CMakeLists.txt | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conanfile.py b/conanfile.py index 2ca2c687a..f26964a2c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "4.5.2" + version = "4.5.3" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/include/homestore/blk.h b/src/include/homestore/blk.h index 217d20b9e..318de4473 100644 --- a/src/include/homestore/blk.h +++ b/src/include/homestore/blk.h @@ -83,6 +83,7 @@ struct BlkId { uint32_t serialized_size() const; std::string to_string() const; bool is_valid() const; + static uint32_t expected_serialized_size(); static int compare(BlkId const& one, BlkId const& two); }; @@ -131,6 +132,7 @@ struct MultiBlkId : public BlkId { bool has_room() const; BlkId to_single_blkid() const; + static uint32_t expected_serialized_size(uint16_t num_pieces); static int compare(MultiBlkId const& one, MultiBlkId const& two); struct iterator { diff --git a/src/lib/blkalloc/blk.cpp b/src/lib/blkalloc/blk.cpp index 8f5276062..f6b8aecce 100644 --- a/src/lib/blkalloc/blk.cpp +++ b/src/lib/blkalloc/blk.cpp @@ -29,6 +29,7 @@ uint64_t BlkId::to_integer() const { return *r_cast< const uint64_t* >(&s); } sisl::blob BlkId::serialize() { return sisl::blob{r_cast< uint8_t* >(&s), sizeof(serialized)}; } uint32_t BlkId::serialized_size() const { return sizeof(BlkId); } +uint32_t BlkId::expected_serialized_size() { return sizeof(BlkId); } void BlkId::deserialize(sisl::blob const& b, bool copy) { serialized* other = r_cast< serialized* >(b.bytes); @@ -110,13 +111,11 @@ void MultiBlkId::deserialize(sisl::blob const& b, bool copy) { } } -#if 0 -static uint32_t MultiBlkId::expected_serialized_size(uint16_t num_pieces) { +uint32_t MultiBlkId::expected_serialized_size(uint16_t num_pieces) { uint32_t sz = BlkId::expected_serialized_size(); if (num_pieces > 1) { sz += sizeof(uint16_t) + ((num_pieces - 1) * sizeof(chain_blkid)); } return sz; } -#endif uint16_t MultiBlkId::num_pieces() const { return BlkId::is_valid() ? n_addln_piece + 1 : 0; } diff --git a/src/lib/common/resource_mgr.hpp b/src/lib/common/resource_mgr.hpp index 47424d36f..54fc459b6 100644 --- a/src/lib/common/resource_mgr.hpp +++ b/src/lib/common/resource_mgr.hpp @@ -98,7 +98,7 @@ class ResourceMgr { std::atomic< int64_t > m_hs_fb_size; // free size std::atomic< int64_t > m_hs_ab_cnt; // alloc count std::atomic< int64_t > m_memory_used_in_recovery; - std::atomic< uint32_t > m_flush_dirty_buf_q_depth; + std::atomic< uint32_t > m_flush_dirty_buf_q_depth{64}; uint64_t m_total_cap; exceed_limit_cb_t m_dirty_buf_exceed_cb; exceed_limit_cb_t m_free_blks_exceed_cb; diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index c89708d72..42844d22a 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -57,7 +57,7 @@ if (${build_nonio_tests}) target_link_libraries(test_append_blk_allocator homestore ${COMMON_TEST_DEPS} GTest::gmock) add_test(NAME AppendBlkAlloc COMMAND test_append_blk_allocator) set_property(TEST AppendBlkAlloc PROPERTY ENVIRONMENT "ASAN_OPTIONS=detect_stack_use_after_return=true") - + set(TEST_BLKID_SOURCES test_blkid.cpp ../lib/blkalloc/blk.cpp) add_executable(test_blkid ${TEST_BLKID_SOURCES}) target_link_libraries(test_blkid ${COMMON_TEST_DEPS} GTest::gtest)