diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-07 23:34:15 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-12 22:20:47 +0200 |
| commit | 5e43b80df4cf8fff6bd350139783fb15d9d25207 (patch) | |
| tree | 48421b9efa7e4ee9bb75ccd308a5b98118937926 /zenstore | |
| parent | cleaner GatherReferences (diff) | |
| download | zen-5e43b80df4cf8fff6bd350139783fb15d9d25207.tar.xz zen-5e43b80df4cf8fff6bd350139783fb15d9d25207.zip | |
correct expire vs contribute
Diffstat (limited to 'zenstore')
| -rw-r--r-- | zenstore/cidstore.cpp | 23 | ||||
| -rw-r--r-- | zenstore/gc.cpp | 9 | ||||
| -rw-r--r-- | zenstore/include/zenstore/gc.h | 3 |
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; |