From 0ee01998645ce1aa130db19d4d413259684c3690 Mon Sep 17 00:00:00 2001 From: Jie Yao Date: Fri, 27 Oct 2023 22:55:09 -0700 Subject: [PATCH] fix comments --- src/include/homestore/meta_service.hpp | 4 +++- src/lib/meta/meta_blk_service.cpp | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/include/homestore/meta_service.hpp b/src/include/homestore/meta_service.hpp index 94067c9d4..0c1cd9872 100644 --- a/src/include/homestore/meta_service.hpp +++ b/src/include/homestore/meta_service.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,7 @@ struct vdev_info; // new blk found subsystem callback typedef std::function< void(meta_blk* mblk, sisl::byte_view buf, size_t size) > meta_blk_found_cb_t; typedef std::string meta_sub_type; +typedef std::vector< meta_sub_type > meta_subtype_vec_t; typedef std::function< void(bool success) > meta_blk_recover_comp_cb_t; // recover complete subsystem callbacks; typedef std::map< uint64_t, meta_blk* > meta_blk_map_t; // blkid to meta_blk map; typedef std::map< uint64_t, meta_blk_ovf_hdr* > ovf_hdr_map_t; // ovf_blkid to ovf_blk_hdr map; @@ -123,7 +125,7 @@ class MetaBlkService { * @param cb : subsystem cb */ void register_handler(meta_sub_type type, const meta_blk_found_cb_t& cb, const meta_blk_recover_comp_cb_t& comp_cb, - bool do_crc = true, std::vector< meta_sub_type > dependencies = {}); + bool do_crc = true, std::optional< meta_subtype_vec_t > deps = std::nullopt); /** * @brief diff --git a/src/lib/meta/meta_blk_service.cpp b/src/lib/meta/meta_blk_service.cpp index 8ddaa46d4..eb7733d0e 100644 --- a/src/lib/meta/meta_blk_service.cpp +++ b/src/lib/meta/meta_blk_service.cpp @@ -360,7 +360,7 @@ void MetaBlkService::deregister_handler(meta_sub_type type) { void MetaBlkService::register_handler(meta_sub_type type, const meta_blk_found_cb_t& cb, const meta_blk_recover_comp_cb_t& comp_cb, bool do_crc, - std::vector< meta_sub_type > dependencies) { + std::optional< meta_subtype_vec_t > deps) { std::lock_guard< decltype(m_meta_mtx) > lk(m_meta_mtx); HS_REL_ASSERT_LT(type.length(), MAX_SUBSYS_TYPE_LEN, "type len: {} should not exceed len: {}", type.length(), MAX_SUBSYS_TYPE_LEN); @@ -377,8 +377,7 @@ void MetaBlkService::register_handler(meta_sub_type type, const meta_blk_found_c m_sub_info[type].cb = cb; m_sub_info[type].comp_cb = comp_cb; m_sub_info[type].do_crc = do_crc ? 1 : 0; - m_dependency_topological_graph[type] = dependencies; - HS_LOG(INFO, metablk, "[type={}] registered with do_crc: {}", type, do_crc); + m_dependency_topological_graph[type] = deps.value_or(meta_subtype_vec_t()); } void MetaBlkService::add_sub_sb(meta_sub_type type, const uint8_t* context_data, uint64_t sz, void*& cookie) { @@ -1165,9 +1164,9 @@ MetaBlkService::topological_sort(std::unordered_map< meta_sub_type, std::vector< // Calculate in-degree of each vertex for (const auto& [vertex, edges] : topological_graph) { - in_degree[vertex] = 0; - } - for (const auto& [vertex, edges] : topological_graph) { + // we should make sure all the vertex in in_degree map; + // if vertex is not in the map, 0 will be assigned. + in_degree[vertex]; for (const auto& edge : edges) { in_degree[edge]++; }