aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/compactcas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenstore/compactcas.cpp')
-rw-r--r--src/zenstore/compactcas.cpp51
1 files changed, 5 insertions, 46 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index 98ad20b98..0468e95de 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -804,8 +804,7 @@ CasContainerStrategy::OpenContainer(bool IsNewStore)
CreateDirectories(BasePath);
- std::unordered_map<uint32_t, uint64_t> BlockSizes =
- m_BlockStore.Initialize(m_BlocksBasePath, m_MaxBlockSize, BlockStoreDiskLocation::MaxBlockIndex + 1);
+ m_BlockStore.Initialize(m_BlocksBasePath, m_MaxBlockSize, BlockStoreDiskLocation::MaxBlockIndex + 1);
std::filesystem::path LogPath = GetLogPath(m_RootDirectory, m_ContainerBaseName);
std::filesystem::path IndexPath = GetIndexPath(m_RootDirectory, m_ContainerBaseName);
@@ -839,54 +838,14 @@ CasContainerStrategy::OpenContainer(bool IsNewStore)
std::vector<BlockStoreLocation> KnownLocations;
KnownLocations.reserve(m_LocationMap.size());
- std::vector<CasDiskIndexEntry> BadEntries;
for (const auto& Entry : m_LocationMap)
{
- const BlockStoreDiskLocation& DiskLocation = m_Locations[Entry.second];
- uint32_t BlockIndex = DiskLocation.GetBlockIndex();
- auto BlockIt = BlockSizes.find(BlockIndex);
- if (BlockIt == BlockSizes.end())
- {
- ZEN_WARN("Unknown block {} for entry {} in '{}'", BlockIndex, Entry.first.ToHexString(), BasePath);
- }
- else
- {
- BlockStoreLocation BlockLocation = DiskLocation.Get(m_PayloadAlignment);
-
- 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(),
- BasePath);
- }
- else
- {
- KnownLocations.emplace_back(std::move(BlockLocation));
- continue;
- }
- BadEntries.push_back({.Key = Entry.first, .Location = DiskLocation, .Flags = CasDiskIndexEntry::kTombstone});
- }
- }
-
- if (!BadEntries.empty())
- {
- m_CasLog.Append(BadEntries);
- m_CasLog.Flush();
-
- LogEntryCount += BadEntries.size();
-
- for (const CasDiskIndexEntry& BadEntry : BadEntries)
- {
- m_LocationMap.erase(BadEntry.Key);
- }
-
- RwLock::ExclusiveLockScope IndexLock(m_LocationMapLock);
- CompactIndex(IndexLock);
+ const BlockStoreDiskLocation& DiskLocation = m_Locations[Entry.second];
+ BlockStoreLocation BlockLocation = DiskLocation.Get(m_PayloadAlignment);
+ KnownLocations.emplace_back(std::move(BlockLocation));
}
- m_BlockStore.Prune(KnownLocations);
+ m_BlockStore.CreateMissingBlocks(KnownLocations);
if (IsNewStore || (LogEntryCount > 0))
{