From 282f3da63951b5182e3d476b8d4beb75c0a9b011 Mon Sep 17 00:00:00 2001 From: Jie Yao Date: Tue, 19 Sep 2023 10:39:43 +0800 Subject: [PATCH 1/2] add get_chunk_id to vchunk (#170) --- src/include/homestore/vchunk.h | 1 + src/lib/device/vchunk.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/include/homestore/vchunk.h b/src/include/homestore/vchunk.h index 11b313de7..f34ed0f4a 100644 --- a/src/include/homestore/vchunk.h +++ b/src/include/homestore/vchunk.h @@ -31,6 +31,7 @@ class VChunk { const uint8_t* get_user_private() const; blk_num_t available_blks() const; uint32_t get_pdev_id() const; + uint16_t get_chunk_id() const; cshared< Chunk > get_internal_chunk() const; private: diff --git a/src/lib/device/vchunk.cpp b/src/lib/device/vchunk.cpp index e2430219c..54dc54604 100644 --- a/src/lib/device/vchunk.cpp +++ b/src/lib/device/vchunk.cpp @@ -27,5 +27,7 @@ blk_num_t VChunk::available_blks() const { return m_internal_chunk->blk_allocato uint32_t VChunk::get_pdev_id() const { return m_internal_chunk->physical_dev()->pdev_id(); } +uint16_t VChunk::get_chunk_id() const { return m_internal_chunk->chunk_id(); } + cshared< Chunk > VChunk::get_internal_chunk() const { return m_internal_chunk; } } // namespace homestore From edf89329ae0e15040e8532886fd15f38368c37f0 Mon Sep 17 00:00:00 2001 From: Sanal Date: Tue, 19 Sep 2023 09:32:08 -0700 Subject: [PATCH 2/2] Fix the external depedency for compilation of index table and its deps. (#174) --- conanfile.py | 2 +- src/include/homestore/checkpoint/cp_mgr.hpp | 1 + src/include/homestore/index/index_table.hpp | 9 ++++----- src/include/homestore/index_service.hpp | 8 ++++---- src/lib/checkpoint/cp_mgr.cpp | 1 + src/lib/index/wb_cache.cpp | 2 +- src/tests/test_index_btree.cpp | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/conanfile.py b/conanfile.py index d4bb59224..5a8da5712 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "4.3.0" + version = "4.3.1" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/include/homestore/checkpoint/cp_mgr.hpp b/src/include/homestore/checkpoint/cp_mgr.hpp index cd7291c9e..0e79d6af9 100644 --- a/src/include/homestore/checkpoint/cp_mgr.hpp +++ b/src/include/homestore/checkpoint/cp_mgr.hpp @@ -140,6 +140,7 @@ class CPGuard { CPGuard(const CPGuard& other); CPGuard operator=(const CPGuard& other); + CPContext* context(cp_consumer_t consumer); CP& operator*(); CP* operator->(); CP* get(); diff --git a/src/include/homestore/index/index_table.hpp b/src/include/homestore/index/index_table.hpp index 58a9a9f3b..fdd0582d0 100644 --- a/src/include/homestore/index/index_table.hpp +++ b/src/include/homestore/index/index_table.hpp @@ -22,8 +22,7 @@ #include #include #include -#include "checkpoint/cp.hpp" -#include "index/wb_cache.hpp" +#include SISL_LOGGING_DECL(wbcache) @@ -56,7 +55,7 @@ class IndexTable : public IndexTableBase, public Btree< K, V > { btree_status_t init() { auto cp = hs()->cp_mgr().cp_guard(); - auto ret = Btree< K, V >::init((void*)cp->context(cp_consumer_t::INDEX_SVC)); + auto ret = Btree< K, V >::init((void*)cp.context(cp_consumer_t::INDEX_SVC)); update_new_root_info(Btree< K, V >::root_node_id(), Btree< K, V >::root_link_version()); return ret; } @@ -77,14 +76,14 @@ class IndexTable : public IndexTableBase, public Btree< K, V > { template < typename ReqT > btree_status_t put(ReqT& put_req) { auto cpg = hs()->cp_mgr().cp_guard(); - put_req.m_op_context = (void*)cpg->context(cp_consumer_t::INDEX_SVC); + put_req.m_op_context = (void*)cpg.context(cp_consumer_t::INDEX_SVC); return Btree< K, V >::put(put_req); } template < typename ReqT > btree_status_t remove(ReqT& remove_req) { auto cpg = hs()->cp_mgr().cp_guard(); - remove_req.m_op_context = (void*)cpg->context(cp_consumer_t::INDEX_SVC); + remove_req.m_op_context = (void*)cpg.context(cp_consumer_t::INDEX_SVC); return Btree< K, V >::remove(remove_req); } diff --git a/src/include/homestore/index_service.hpp b/src/include/homestore/index_service.hpp index b2ab7d879..cdeb3d3ba 100644 --- a/src/include/homestore/index_service.hpp +++ b/src/include/homestore/index_service.hpp @@ -25,7 +25,7 @@ namespace homestore { -class IndexWBCache; +class IndexWBCacheBase; class IndexTableBase; class VirtualDev; @@ -38,7 +38,7 @@ class IndexServiceCallbacks { class IndexService { private: std::unique_ptr< IndexServiceCallbacks > m_svc_cbs; - std::unique_ptr< IndexWBCache > m_wb_cache; + std::unique_ptr< IndexWBCacheBase > m_wb_cache; std::shared_ptr< VirtualDev > m_vdev; mutable std::mutex m_index_map_mtx; @@ -63,13 +63,13 @@ class IndexService { uint64_t used_size() const; uint32_t node_size() const; - IndexWBCache& wb_cache() { return *m_wb_cache; } + IndexWBCacheBase& wb_cache() { return *m_wb_cache; } private: void meta_blk_found(const sisl::byte_view& buf, void* meta_cookie); }; extern IndexService& index_service(); -extern IndexWBCache& wb_cache(); +extern IndexWBCacheBase& wb_cache(); } // namespace homestore diff --git a/src/lib/checkpoint/cp_mgr.cpp b/src/lib/checkpoint/cp_mgr.cpp index 54dd7a2d9..4faae7ae8 100644 --- a/src/lib/checkpoint/cp_mgr.cpp +++ b/src/lib/checkpoint/cp_mgr.cpp @@ -296,6 +296,7 @@ CPGuard CPGuard::operator=(const CPGuard& other) { CP& CPGuard::operator*() { return *get(); } CP* CPGuard::operator->() { return get(); } +CPContext* CPGuard::context(cp_consumer_t consumer) { return get()->context(consumer); } CP* CPGuard::get() { HS_DBG_ASSERT_NE((void*)m_cp, (void*)nullptr, "CPGuard get on empty CP pointer"); diff --git a/src/lib/index/wb_cache.cpp b/src/lib/index/wb_cache.cpp index 27899db61..21ad44345 100644 --- a/src/lib/index/wb_cache.cpp +++ b/src/lib/index/wb_cache.cpp @@ -29,7 +29,7 @@ SISL_LOGGING_DECL(wbcache) namespace homestore { -IndexWBCache& wb_cache() { return index_service().wb_cache(); } +IndexWBCacheBase& wb_cache() { return index_service().wb_cache(); } IndexWBCache::IndexWBCache(const std::shared_ptr< VirtualDev >& vdev, const std::shared_ptr< sisl::Evictor >& evictor, uint32_t node_size) : diff --git a/src/tests/test_index_btree.cpp b/src/tests/test_index_btree.cpp index 59248c125..50fcfe4dd 100644 --- a/src/tests/test_index_btree.cpp +++ b/src/tests/test_index_btree.cpp @@ -298,7 +298,7 @@ struct BtreeTest : public testing::Test { void destroy_btree() { auto cpg = hs()->cp_mgr().cp_guard(); - auto op_context = (void*)cpg->context(cp_consumer_t::INDEX_SVC); + auto op_context = (void*)cpg.context(cp_consumer_t::INDEX_SVC); const auto [ret, free_node_cnt] = m_bt->destroy_btree(op_context); ASSERT_EQ(ret, btree_status_t::success) << "btree destroy failed"; m_bt.reset();