aboutsummaryrefslogtreecommitdiff
path: root/zenstore
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore')
-rw-r--r--zenstore/cidstore.cpp23
-rw-r--r--zenstore/gc.cpp9
-rw-r--r--zenstore/include/zenstore/gc.h3
3 files changed, 13 insertions, 22 deletions
diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp
index 509d21abe..6cf9ee734 100644
--- a/zenstore/cidstore.cpp
+++ b/zenstore/cidstore.cpp
@@ -234,23 +234,22 @@ struct CidStore::Impl
void RemoveCids(CasChunkSet& CasChunks)
{
- RwLock::ExclusiveLockScope _(m_Lock);
-
- for (auto It = m_CidMap.begin(), End = m_CidMap.end(); It != End;)
+ std::vector<IndexEntry> RemovedEntries;
+ RemovedEntries.reserve(CasChunks.GetSize());
{
- if (CasChunks.ContainsChunk(It->second))
- {
- const IoHash& BadHash = It->first;
-
- // Log a tombstone record
- LogMapping(BadHash, IoHash::Zero);
- It = m_CidMap.erase(It);
- }
- else
+ RwLock::SharedLockScope _(m_Lock);
+ for (auto It = m_CidMap.begin(), End = m_CidMap.end(); It != End;)
{
+ if (CasChunks.ContainsChunk(It->second))
+ {
+ RemovedEntries.push_back({It->first, IoHash::Zero});
+ It = m_CidMap.erase(It);
+ continue;
+ }
++It;
}
}
+ m_LogFile.Append(RemovedEntries);
}
uint64_t m_LastScrubTime = 0;
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index 856f9af02..21522e46a 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -212,9 +212,8 @@ GcContext::ContributeCas(std::span<const IoHash> Cas)
}
void
-GcContext::ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash> ValidKeys, std::vector<IoHash> ExpiredKeys)
+GcContext::ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash>&& ExpiredKeys)
{
- m_State->m_CacheBuckets[Bucket].ValidKeys = std::move(ValidKeys);
m_State->m_CacheBuckets[Bucket].ExpiredKeys = std::move(ExpiredKeys);
}
@@ -255,12 +254,6 @@ GcContext::DeletedCas()
}
std::span<const IoHash>
-GcContext::ValidCacheKeys(const std::string& Bucket) const
-{
- return m_State->m_CacheBuckets[Bucket].ValidKeys;
-}
-
-std::span<const IoHash>
GcContext::ExpiredCacheKeys(const std::string& Bucket) const
{
return m_State->m_CacheBuckets[Bucket].ExpiredKeys;
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index bc8dee9a3..6268588ec 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -53,7 +53,7 @@ public:
void ContributeCids(std::span<const IoHash> Cid);
void ContributeCas(std::span<const IoHash> Hash);
- void ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash> ValidKeys, std::vector<IoHash> ExpiredKeys);
+ void ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash>&& ExpiredKeys);
void IterateCids(std::function<void(const IoHash&)> Callback);
@@ -64,7 +64,6 @@ public:
void DeletedCas(std::span<const IoHash> Cas);
CasChunkSet& DeletedCas();
- std::span<const IoHash> ValidCacheKeys(const std::string& Bucket) const;
std::span<const IoHash> ExpiredCacheKeys(const std::string& Bucket) const;
bool IsDeletionMode() const;