diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-27 08:35:48 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-27 08:35:48 +0200 |
| commit | d508f996641430c3027210721d2317841e638911 (patch) | |
| tree | 6ad7ea9983e2712890829da01f9b1ef5dfed6c39 | |
| parent | trigger clang format (diff) | |
| parent | Batch log removal of Cid and take proper lock when modifying m_CidMap (#80) (diff) | |
| download | zen-d508f996641430c3027210721d2317841e638911.tar.xz zen-d508f996641430c3027210721d2317841e638911.zip | |
Merge remote-tracking branch 'origin/main' into de/use-bulk-fetch-from-upstream-on-getcachevalues
| -rw-r--r-- | zenserver/cache/structuredcachestore.cpp | 10 | ||||
| -rw-r--r-- | zenstore/cidstore.cpp | 23 |
2 files changed, 15 insertions, 18 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index f499cf194..a9f38e51d 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -1255,10 +1255,10 @@ ZenCacheDiskLayer::Put(std::string_view InBucket, const IoHash& HashKey, const Z auto It = m_Buckets.try_emplace(BucketName, BucketName); Bucket = &It.first->second; - std::filesystem::path bucketPath = m_RootDir; - bucketPath /= BucketName; + std::filesystem::path BucketPath = m_RootDir; + BucketPath /= BucketName; - Bucket->OpenOrCreate(bucketPath); + Bucket->OpenOrCreate(BucketPath); } } @@ -1363,11 +1363,9 @@ void ZenCacheDiskLayer::Flush() { std::vector<CacheBucket*> Buckets; - - Buckets.reserve(m_Buckets.size()); { RwLock::SharedLockScope _(m_Lock); - + Buckets.reserve(m_Buckets.size()); for (auto& Kv : m_Buckets) { Buckets.push_back(&Kv.second); diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp index 509d21abe..55bec817f 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::ExclusiveLockScope _(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; |