diff --git a/src/blockstore/blockstore_heap.cpp b/src/blockstore/blockstore_heap.cpp index 4574c668..e5f53808 100644 --- a/src/blockstore/blockstore_heap.cpp +++ b/src/blockstore/blockstore_heap.cpp @@ -334,19 +334,12 @@ corrupted_block: block_num, block_offset, wr->size, sizeof(heap_entry_t)); goto corrupted_block; } - if (wr->is_garbage()) - { - // Garbage collection is only performed when writing new entries into the block - // because it needs a fake LSN and modified blocks require consecutive modified LSNs - // That's why garbage entries may persist on disk - if (log_level > 5) - { - fprintf(stderr, "Notice: skipping garbage entry %jx:%jx v%ju l%ju in metadata block %u at %u\n", - wr->inode, wr->stripe, wr->version, wr->lsn, block_num, block_offset); - } - block_offset += wr->size; - continue; - } + // Garbage collection is only performed when writing new entries into the block + // because it needs a fake LSN and modified blocks require consecutive modified LSNs + // At the same time, further modifications _after_ putting new entries into the block, + // but _before_ writing it, may mark some entries in it as garbage. That's why garbage + // entries may still be present on disk. + wr->entry_type &= ~BS_HEAP_GARBAGE; if ((wr->entry_type & BS_HEAP_TYPE) < BS_HEAP_BIG_WRITE || (wr->entry_type & BS_HEAP_TYPE) > BS_HEAP_ROLLBACK || (wr->entry_type & ~(BS_HEAP_TYPE|BS_HEAP_STABLE)) || diff --git a/src/test/test_heap.cpp b/src/test/test_heap.cpp index 5eed117c..706501fe 100644 --- a/src/test/test_heap.cpp +++ b/src/test/test_heap.cpp @@ -1893,7 +1893,8 @@ void test_big_intent_csums() heap.finish_recheck(); auto mod = heap.get_recheck_modified_blocks(); - assert(mod.size() == 0); + assert(mod.size() == 1); + assert(mod[0] == 0); // read object 1 - big_intent should be there object_id oid = { .inode = INODE_WITH_POOL(1, 1), .stripe = 0 };