Skip to content

Commit

Permalink
add interface to get blk alloc hints for chunks on same pg
Browse files Browse the repository at this point in the history
  • Loading branch information
zichanglai committed Sep 25, 2023
1 parent 427ed24 commit 6a52eb9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/lib/homestore/heap_chunk_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,16 @@ void HeapChunkSelector::build_per_dev_chunk_heap(const std::unordered_set< chunk
if (excludingChunks.find(p.first) == excludingChunks.end()) { add_chunk_internal(p.first); }
};
}
} // namespace homeobject

homestore::blk_alloc_hints HeapChunkSelector::get_blk_alloc_hints_on_same_pdev(chunk_num_t chunk_id) const {
auto iter = m_chunks.find(chunk_id);
if (iter == m_chunks.end()) {
LOGWARN("No chunk found for ChunkID {}, will return default blk alloc hints", chunk_id);
return homestore::blk_alloc_hints();
}
homestore::blk_alloc_hints hints;
hints.pdev_id_hint = VChunk(iter->second).get_pdev_id();
return hints;
}

} // namespace homeobject
4 changes: 3 additions & 1 deletion src/lib/homestore/heap_chunk_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class HeapChunkSelector : public homestore::ChunkSelector {
// this should be called after ShardManager is initialized and get all the open shards
void build_per_dev_chunk_heap(const std::unordered_set< chunk_num_t >& excludingChunks);

homestore::blk_alloc_hints get_blk_alloc_hints_on_same_pdev(chunk_num_t chunk_id) const;

private:
std::unordered_map< uint32_t, std::shared_ptr< PerDevHeap > > m_per_dev_heap;

Expand All @@ -54,4 +56,4 @@ class HeapChunkSelector : public homestore::ChunkSelector {

void add_chunk_internal(const chunk_num_t);
};
} // namespace homeobject
} // namespace homeobject

0 comments on commit 6a52eb9

Please sign in to comment.