Skip to content

Commit

Permalink
fix lock leak
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Sep 18, 2023
1 parent eb3df0b commit 30aa355
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/homestore/heap_chunk_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ csharedChunk HeapChunkSelector::select_chunk(homestore::blk_count_t count, const
it->second->first.lock();
if(it->second->second.empty()) {
LOGINFO("No more available chunks found for pdev {}", pdevID);
it->second->first.unlock();
return nullptr;
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/homestore/heap_chunk_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ class HeapChunkSelector : public homestore::ChunkSelector {
csharedChunk select_chunk([[maybe_unused]]homestore::blk_count_t nblks, const homestore::blk_alloc_hints& hints);

private:
//this holds all the chunks for each pdev, they are all unselected.
folly::ConcurrentHashMap< uint32_t, std::shared_ptr< std::pair< std::mutex, VChunkHeap > > > m_pdev_heap_map;

//for now, uint32_t is enough for the sum of all the available blocks of a pdev.
//if necessary , we can change this to uint64_t to hold a larger sum.
std::unordered_map< uint32_t, uint32_t> m_pdev_avalable_blk_map;

//hold all the chunks , selected or not
std::unordered_set< VChunk > m_chunks;
std::mutex lock;

};
} // namespace homeobject

0 comments on commit 30aa355

Please sign in to comment.