Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Sep 17, 2023
1 parent 795cd05 commit eb3df0b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/homestore/heap_chunk_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ csharedChunk HeapChunkSelector::select_chunk(homestore::blk_count_t count, const
if(pdevID == homestore::INVALID_DEV_ID) {
// this is the first shard of this pg, select a pdev with the most available blocks for it
std::lock_guard<std::mutex> l(lock);
auto it = std::max_element(m_pdev_avalable_blk_map.begin(), m_pdev_avalable_blk_map.end(),
auto& it = std::max_element(m_pdev_avalable_blk_map.begin(), m_pdev_avalable_blk_map.end(),
[](const std::pair<uint32_t, uint32_t>& lhs, const std::pair<uint32_t, uint32_t>& rhs) {
return lhs.second < rhs.second; }
);
if(it == m_pdev_avalable_blk_map.end()) {
LOGINFO("No pdev found for pg");
return nullptr;
}
pdevID = it->first;
}

Expand All @@ -41,13 +45,13 @@ csharedChunk HeapChunkSelector::select_chunk(homestore::blk_count_t count, const
LOGINFO("No pdev found for pdev {}", pdevID);
return nullptr;
}


it->second->first.lock();
if(it->second->second.empty()) {
LOGINFO("No more available chunks found for pdev {}", pdevID);
return nullptr;
}

auto& vchunk = it->second->second.top();
it->second->second.pop();
it->second->first.unlock();
Expand Down

0 comments on commit eb3df0b

Please sign in to comment.