aboutsummaryrefslogtreecommitdiff
path: root/zenstore/blockstore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore/blockstore.cpp')
-rw-r--r--zenstore/blockstore.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp
index 5e47d061f..2894244fe 100644
--- a/zenstore/blockstore.cpp
+++ b/zenstore/blockstore.cpp
@@ -452,7 +452,15 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
WriteBlockLongestTimeUs = std::max(ElapsedUs, WriteBlockLongestTimeUs);
});
OldBlockFile = m_ChunkBlocks[BlockIndex];
- ZEN_ASSERT(OldBlockFile);
+ }
+
+ if (!OldBlockFile)
+ {
+ // If the block file pointed to does not exist, move them all to deleted list
+ BlockDeleteChunks[ChunkMapIndex].insert(BlockDeleteChunks[ChunkMapIndex].end(),
+ BlockKeepChunks[ChunkMapIndex].begin(),
+ BlockKeepChunks[ChunkMapIndex].end());
+ BlockKeepChunks[ChunkMapIndex].clear();
}
const ChunkIndexArray& KeepMap = BlockKeepChunks[ChunkMapIndex];
@@ -473,14 +481,19 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
ReadBlockTimeUs += ElapsedUs;
ReadBlockLongestTimeUs = std::max(ElapsedUs, ReadBlockLongestTimeUs);
});
- m_ChunkBlocks[BlockIndex] = nullptr;
- ZEN_DEBUG("marking cas block store file '{}' for delete, block #{}", OldBlockFile->GetPath(), BlockIndex);
- m_TotalSize.fetch_sub(OldBlockFile->FileSize(), std::memory_order::relaxed);
- OldBlockFile->MarkAsDeleteOnClose();
+ if (OldBlockFile != nullptr)
+ {
+ m_ChunkBlocks[BlockIndex] = nullptr;
+ ZEN_DEBUG("marking cas block store file '{}' for delete, block #{}", OldBlockFile->GetPath(), BlockIndex);
+ m_TotalSize.fetch_sub(OldBlockFile->FileSize(), std::memory_order::relaxed);
+ OldBlockFile->MarkAsDeleteOnClose();
+ }
}
continue;
}
+ ZEN_ASSERT(OldBlockFile);
+
MovedChunksArray MovedChunks;
std::vector<uint8_t> Chunk;
for (const size_t& ChunkIndex : KeepMap)