diff --git a/src/include/homestore/checkpoint/cp_mgr.hpp b/src/include/homestore/checkpoint/cp_mgr.hpp index 1a06766a7..322f3411e 100644 --- a/src/include/homestore/checkpoint/cp_mgr.hpp +++ b/src/include/homestore/checkpoint/cp_mgr.hpp @@ -141,6 +141,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 32fed0d6c..b4f551a8e 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; @@ -41,7 +41,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; @@ -66,13 +66,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/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/checkpoint/cp_mgr.cpp b/src/lib/checkpoint/cp_mgr.cpp index 98c10fbe9..82669645b 100644 --- a/src/lib/checkpoint/cp_mgr.cpp +++ b/src/lib/checkpoint/cp_mgr.cpp @@ -303,6 +303,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/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 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 fd1425d9f..4463ebbd4 100644 --- a/src/tests/test_index_btree.cpp +++ b/src/tests/test_index_btree.cpp @@ -304,7 +304,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();