Skip to content

Commit b76b917

Browse files
committed
support trigger gc for a specific pg
1 parent 596f40e commit b76b917

File tree

3 files changed

+209
-132
lines changed

3 files changed

+209
-132
lines changed

src/lib/homestore_backend/gc_manager.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,20 @@ void GCManager::stop() {
176176
}
177177

178178
folly::SemiFuture< bool > GCManager::submit_gc_task(task_priority priority, chunk_id_t chunk_id) {
179-
auto pdev_id = m_chunk_selector->get_extend_vchunk(chunk_id)->get_pdev_id();
179+
auto ex_vchunk = m_chunk_selector->get_extend_vchunk(chunk_id);
180+
if (ex_vchunk == nullptr) {
181+
LOGERRORMOD(gcmgr, "chunk {} not found when submit gc task!", chunk_id);
182+
return folly::makeFuture< bool >(false);
183+
}
184+
185+
// if the chunk has no garbage to be reclaimed, we don`t need to gc it , return true directly
186+
const auto defrag_blk_num = ex_vchunk->get_defrag_nblks();
187+
if (!defrag_blk_num) {
188+
LOGERRORMOD(gcmgr, "chunk {} has no garbage to be reclaimed, skip gc for this chunk!", chunk_id);
189+
return folly::makeFuture< bool >(true);
190+
}
191+
192+
auto pdev_id = ex_vchunk->get_pdev_id();
180193
auto it = m_pdev_gc_actors.find(pdev_id);
181194
if (it == m_pdev_gc_actors.end()) {
182195
LOGINFOMOD(gcmgr, "pdev gc actor not found for pdev_id={}, chunk={}", pdev_id, chunk_id);

0 commit comments

Comments
 (0)