Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Oct 29, 2023
1 parent 50afc30 commit 0ee0199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/include/homestore/meta_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string>
#include <system_error>
#include <vector>
#include <optional>

#include <sisl/fds/buffer.hpp>
#include <sisl/metrics/metrics.hpp>
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/lib/meta/meta_blk_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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]++;
}
Expand Down

0 comments on commit 0ee0199

Please sign in to comment.