diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-30 14:38:27 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 11:29:28 +0200 |
| commit | 596e25eeb59aae3eb39f004aa0eddbe7aecdad01 (patch) | |
| tree | 92a9df100b3f0dd8aa362c4781d18bdc46f0bfc7 /zenstore/compactcas.cpp | |
| parent | Properly figure out block ranges in migration (diff) | |
| download | zen-596e25eeb59aae3eb39f004aa0eddbe7aecdad01.tar.xz zen-596e25eeb59aae3eb39f004aa0eddbe7aecdad01.zip | |
WIP
Diffstat (limited to 'zenstore/compactcas.cpp')
| -rw-r--r-- | zenstore/compactcas.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index 1c4f7db51..687955e9c 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -1199,6 +1199,8 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx) void CasContainerStrategy::MakeIndexSnapshot() { + // Flush on done + ZEN_INFO("write store {} snapshot", m_Config.RootDirectory / m_ContainerBaseName); uint64_t EntryCount = 0; Stopwatch Timer; @@ -1324,6 +1326,7 @@ CasContainerStrategy::MakeIndexSnapshot() void CasContainerStrategy::OpenContainer(bool IsNewStore) { + // Add .running file and delete on clean on close to detect bad termination m_TotalSize = 0; m_LocationMap.clear(); @@ -1343,6 +1346,7 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) std::vector<CasDiskIndexEntry> IndexEntries = ReadIndexFile(m_Config.RootDirectory, m_ContainerBaseName, m_PayloadAlignment); for (const CasDiskIndexEntry& Entry : IndexEntries) { + // Log and skip entries that don't makes sense m_LocationMap[Entry.Key] = Entry.Location; } } @@ -1352,6 +1356,7 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) std::vector<CasDiskIndexEntry> LogEntries = ReadLog(m_Config.RootDirectory, m_ContainerBaseName); for (const CasDiskIndexEntry& Entry : LogEntries) { + // Log and skip entries that don't makes sense if (Entry.Flags & CasDiskIndexEntry::kTombstone) { m_LocationMap.erase(Entry.Key); @@ -1374,6 +1379,7 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) MigrateLegacyData(m_Config.RootDirectory, m_ContainerBaseName, m_MaxBlockSize, m_PayloadAlignment, true, ExistingChunks); for (const CasDiskIndexEntry& Entry : LegacyEntries) { + // Log and skip entries that don't makes sense m_LocationMap[Entry.Key] = Entry.Location; } MakeSnapshot |= !LegacyEntries.empty(); @@ -1413,11 +1419,6 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) { continue; } - if (IsNewStore) - { - std::filesystem::remove(Path); - continue; - } std::string FileName = Path.stem().string(); uint32_t BlockIndex; bool OK = ParseHexNumber(FileName, BlockIndex); @@ -1427,6 +1428,7 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) } if (!KnownBlocks.contains(BlockIndex)) { + // Log removing unreferenced block // Clear out unused blocks std::filesystem::remove(Path); continue; |