aboutsummaryrefslogtreecommitdiff
path: root/zenstore
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore')
-rw-r--r--zenstore/CAS.cpp7
-rw-r--r--zenstore/cidstore.cpp17
-rw-r--r--zenstore/gc.cpp6
-rw-r--r--zenstore/include/zenstore/CAS.h1
-rw-r--r--zenstore/include/zenstore/gc.h4
5 files changed, 23 insertions, 12 deletions
diff --git a/zenstore/CAS.cpp b/zenstore/CAS.cpp
index 18abd2cf5..d4023bdc4 100644
--- a/zenstore/CAS.cpp
+++ b/zenstore/CAS.cpp
@@ -101,6 +101,7 @@ public:
virtual void Initialize(const CasStoreConfiguration& InConfig) override;
virtual CasStore::InsertResult InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) override;
virtual IoBuffer FindChunk(const IoHash& ChunkHash) override;
+ virtual bool ContainsChunk(const IoHash& ChunkHash) override;
virtual void FilterChunks(CasChunkSet& InOutChunks) override;
virtual void Flush() override;
virtual void Scrub(ScrubContext& Ctx) override;
@@ -282,6 +283,12 @@ CasImpl::FindChunk(const IoHash& ChunkHash)
return IoBuffer{};
}
+bool
+CasImpl::ContainsChunk(const IoHash& ChunkHash)
+{
+ return m_SmallStrategy.HaveChunk(ChunkHash) || m_TinyStrategy.HaveChunk(ChunkHash) || m_LargeStrategy.HaveChunk(ChunkHash);
+}
+
void
CasImpl::FilterChunks(CasChunkSet& InOutChunks)
{
diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp
index 33dc216b5..c5396cff3 100644
--- a/zenstore/cidstore.cpp
+++ b/zenstore/cidstore.cpp
@@ -107,20 +107,17 @@ struct CidStore::Impl
bool ContainsChunk(const IoHash& DecompressedId)
{
- RwLock::SharedLockScope _(m_Lock);
- // Note that we do not check CAS here. This is optimistic but usually
- // what we want.
- auto It = m_CidMap.find(DecompressedId);
+ IoHash CasHash = IoHash::Zero;
- if (It == m_CidMap.end())
{
- // Not in map
- return false;
+ RwLock::SharedLockScope _(m_Lock);
+ if (const auto It = m_CidMap.find(DecompressedId); It != m_CidMap.end())
+ {
+ CasHash = It->second;
+ }
}
- ZEN_ASSERT(It->second != IoHash::Zero);
-
- return true;
+ return CasHash != IoHash::Zero ? m_CasStore.ContainsChunk(CasHash) : false;
}
void InitializeIndex(const std::filesystem::path& RootDir)
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index d5cb4901b..307adc04e 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -268,6 +268,10 @@ CasGc::CollectGarbage(GcContext& GcCtx)
Contributor->GatherReferences(GcCtx);
}
+ // Cache records reference CAS chunks with the uncompressed
+ // raw hash (Cid). Map the content ID to CAS hash to enable
+ // the CAS storage backends to filter valid chunks.
+
if (CidStore* CidStore = m_CidStore)
{
std::vector<IoHash> CasHashes;
@@ -301,6 +305,8 @@ CasGc::CollectGarbage(GcContext& GcCtx)
Storage->CollectGarbage(GcCtx);
}
+ // Remove Cid to CAS hash mappings. Scrub?
+
if (CidStore* CidStore = m_CidStore)
{
CidStore->RemoveCids(GcCtx.DeletedCas());
diff --git a/zenstore/include/zenstore/CAS.h b/zenstore/include/zenstore/CAS.h
index 5f1565f81..2e530c418 100644
--- a/zenstore/include/zenstore/CAS.h
+++ b/zenstore/include/zenstore/CAS.h
@@ -126,6 +126,7 @@ public:
virtual void Initialize(const CasStoreConfiguration& Config) = 0;
virtual InsertResult InsertChunk(IoBuffer Data, const IoHash& ChunkHash) = 0;
virtual IoBuffer FindChunk(const IoHash& ChunkHash) = 0;
+ virtual bool ContainsChunk(const IoHash& ChunkHash) = 0;
virtual void FilterChunks(CasChunkSet& InOutChunks) = 0;
virtual void Flush() = 0;
virtual void Scrub(ScrubContext& Ctx) = 0;
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index 9b0025403..b752d159a 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -167,8 +167,8 @@ struct GcSchedulerConfig
std::chrono::seconds MonitorInterval{30};
std::chrono::seconds Interval{};
std::chrono::seconds MaxCacheDuration{86400};
- bool CollectSmallObjects = false;
- bool Enabled = false;
+ bool CollectSmallObjects = true;
+ bool Enabled = true;
};
/**