aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/cachedisklayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/cache/cachedisklayer.cpp')
-rw-r--r--src/zenserver/cache/cachedisklayer.cpp60
1 files changed, 3 insertions, 57 deletions
diff --git a/src/zenserver/cache/cachedisklayer.cpp b/src/zenserver/cache/cachedisklayer.cpp
index ebefa2e54..3cd725a27 100644
--- a/src/zenserver/cache/cachedisklayer.cpp
+++ b/src/zenserver/cache/cachedisklayer.cpp
@@ -604,8 +604,7 @@ ZenCacheDiskLayer::CacheBucket::OpenLog(const bool IsNew)
CreateDirectories(m_BucketDir);
- std::unordered_map<uint32_t, uint64_t> BlockSizes =
- m_BlockStore.Initialize(m_BlocksBasePath, MaxBlockSize, BlockStoreDiskLocation::MaxBlockIndex + 1);
+ m_BlockStore.Initialize(m_BlocksBasePath, MaxBlockSize, BlockStoreDiskLocation::MaxBlockIndex + 1);
if (std::filesystem::is_regular_file(IndexPath))
{
@@ -636,7 +635,6 @@ ZenCacheDiskLayer::CacheBucket::OpenLog(const bool IsNew)
std::vector<BlockStoreLocation> KnownLocations;
KnownLocations.reserve(m_Index.size());
- std::vector<DiskIndexEntry> BadEntries;
for (const auto& Entry : m_Index)
{
size_t EntryIndex = Entry.second;
@@ -649,48 +647,10 @@ ZenCacheDiskLayer::CacheBucket::OpenLog(const bool IsNew)
continue;
}
const BlockStoreLocation& BlockLocation = Location.GetBlockLocation(m_PayloadAlignment);
-
- auto BlockIt = BlockSizes.find(BlockLocation.BlockIndex);
- if (BlockIt == BlockSizes.end())
- {
- ZEN_WARN("Unknown block {} for entry {} in '{}'", BlockLocation.BlockIndex, Entry.first.ToHexString(), m_BucketDir);
- }
- else
- {
- uint64_t BlockSize = BlockIt->second;
- if (BlockLocation.Offset + BlockLocation.Size > BlockSize)
- {
- ZEN_WARN("Range is outside of block {} for entry {} in '{}'",
- BlockLocation.BlockIndex,
- Entry.first.ToHexString(),
- m_BucketDir);
- }
- else
- {
- KnownLocations.push_back(BlockLocation);
- continue;
- }
- }
-
- DiskLocation NewLocation = Payload.Location;
- NewLocation.Flags |= DiskLocation::kTombStone;
- BadEntries.push_back(DiskIndexEntry{.Key = Entry.first, .Location = NewLocation});
+ KnownLocations.push_back(BlockLocation);
}
- if (!BadEntries.empty())
- {
- m_SlogFile.Append(BadEntries);
- m_SlogFile.Flush();
-
- LogEntryCount += BadEntries.size();
-
- for (const DiskIndexEntry& BadEntry : BadEntries)
- {
- m_Index.erase(BadEntry.Key);
- }
- }
-
- m_BlockStore.Prune(KnownLocations);
+ m_BlockStore.CreateMissingBlocks(KnownLocations);
if (IsNew || LogEntryCount > 0)
{
@@ -1558,11 +1518,6 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx)
}
DeleteCacheKeys.push_back(ChunkHash);
});
- if (DeleteCacheKeys.empty())
- {
- ZEN_DEBUG("garbage collect SKIPPED, for '{}', no expired cache keys found", m_BucketDir);
- return;
- }
auto __ = MakeGuard([&]() {
if (!DeletedChunks.empty())
@@ -1638,11 +1593,6 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx)
WriteBlockTimeUs += ElapsedUs;
WriteBlockLongestTimeUs = std::max(ElapsedUs, WriteBlockLongestTimeUs);
});
- if (m_Index.empty())
- {
- ZEN_DEBUG("garbage collect SKIPPED, for '{}', container is empty", m_BucketDir);
- return;
- }
BlockStoreState = m_BlockStore.GetReclaimSnapshotState();
@@ -1769,10 +1719,6 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx)
}
}
- if (TotalChunkHashes.empty())
- {
- return;
- }
TotalChunkCount = TotalChunkHashes.size();
std::vector<BlockStoreLocation> ChunkLocations;