aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zenstore/compactcas.cpp12
-rw-r--r--zenstore/compactcas.h4
2 files changed, 9 insertions, 7 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;
diff --git a/zenstore/compactcas.h b/zenstore/compactcas.h
index 4b9f5685b..602c37713 100644
--- a/zenstore/compactcas.h
+++ b/zenstore/compactcas.h
@@ -50,7 +50,6 @@ struct CasContainerStrategy final : public GcStorage
CasContainerStrategy(const CasStoreConfiguration& Config, CasGc& Gc);
~CasContainerStrategy();
- CasStore::InsertResult InsertChunk(const void* ChunkData, size_t ChunkSize, const IoHash& ChunkHash);
CasStore::InsertResult InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash);
IoBuffer FindChunk(const IoHash& ChunkHash);
bool HaveChunk(const IoHash& ChunkHash);
@@ -62,7 +61,8 @@ struct CasContainerStrategy final : public GcStorage
virtual GcStorageSize StorageSize() const override { return {.DiskSize = m_TotalSize.load(std::memory_order::acquire)}; }
private:
- void OpenContainer(bool IsNewStore);
+ CasStore::InsertResult InsertChunk(const void* ChunkData, size_t ChunkSize, const IoHash& ChunkHash);
+ void OpenContainer(bool IsNewStore);
spdlog::logger& Log() { return m_Log; }
void UpdateLocations(const std::span<CasDiskIndexEntry>& Entries);