aboutsummaryrefslogtreecommitdiff
path: root/zenstore/filecas.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-12-08 08:52:23 +0100
committerPer Larsson <[email protected]>2021-12-08 08:52:23 +0100
commit17fe85637a49acf38ea222edd161f2919b3558fa (patch)
treed924db4c7974661027fb29638c2fb9457710e63d /zenstore/filecas.cpp
parentFirst pass of z$ garbage collection. (diff)
downloadzen-17fe85637a49acf38ea222edd161f2919b3558fa.tar.xz
zen-17fe85637a49acf38ea222edd161f2919b3558fa.zip
Added tombstone flag to file cas.
Diffstat (limited to 'zenstore/filecas.cpp')
-rw-r--r--zenstore/filecas.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp
index 3c4add82a..62600eae6 100644
--- a/zenstore/filecas.cpp
+++ b/zenstore/filecas.cpp
@@ -90,7 +90,16 @@ FileCasStrategy::Initialize(bool IsNewStore)
m_CasLog.Open(m_Config.RootDirectory / "cas.ulog", IsNewStore);
- m_CasLog.Replay([&](const FileCasIndexEntry& Entry) { m_TotalSize.fetch_add(Entry.Size); });
+ m_CasLog.Replay([&](const FileCasIndexEntry& Entry) {
+ if (Entry.IsFlagSet(FileCasIndexEntry::kTombStone))
+ {
+ m_TotalSize.fetch_sub(Entry.Size, std::memory_order_relaxed);
+ }
+ else
+ {
+ m_TotalSize.fetch_add(Entry.Size, std::memory_order_relaxed);
+ }
+ });
}
CasStore::InsertResult
@@ -400,7 +409,7 @@ FileCasStrategy::DeleteChunk(const IoHash& ChunkHash, std::error_code& Ec)
if (!Ec)
{
m_TotalSize.fetch_sub(FileSize);
- m_CasLog.Append({.Key = ChunkHash, .Size = -static_cast<int64_t>(FileSize)});
+ m_CasLog.Append({.Key = ChunkHash, .Flags = FileCasIndexEntry::kTombStone, .Size = static_cast<int64_t>(FileSize)});
}
}