aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/compactcas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenstore/compactcas.cpp')
-rw-r--r--src/zenstore/compactcas.cpp53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index 5fca3046c..a5d70a991 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -871,48 +871,45 @@ public:
Stats.CheckedCount = m_Cids.size();
Stats.FoundCount = UnusedCids.size();
- if (UnusedCids.empty())
- {
- // Nothing to collect
- return nullptr;
- }
-
if (!Ctx.Settings.CollectSmallObjects)
{
return nullptr;
}
- if (Ctx.Settings.IsDeleteMode)
+ if (!UnusedCids.empty())
{
- std::vector<CasDiskIndexEntry> ExpiredEntries;
- ExpiredEntries.reserve(UnusedCids.size());
-
+ if (Ctx.Settings.IsDeleteMode)
{
- RwLock::ExclusiveLockScope __(m_CasContainerStrategy.m_LocationMapLock);
- if (Ctx.IsCancelledFlag.load())
- {
- return nullptr;
- }
+ std::vector<CasDiskIndexEntry> ExpiredEntries;
+ ExpiredEntries.reserve(UnusedCids.size());
- for (const IoHash& Cid : UnusedCids)
{
- if (auto It = m_CasContainerStrategy.m_LocationMap.find(Cid); It != m_CasContainerStrategy.m_LocationMap.end())
+ RwLock::ExclusiveLockScope __(m_CasContainerStrategy.m_LocationMapLock);
+ if (Ctx.IsCancelledFlag.load())
{
- ExpiredEntries.push_back({.Key = Cid,
- .Location = m_CasContainerStrategy.m_Locations[It->second],
- .Flags = CasDiskIndexEntry::kTombstone});
+ return nullptr;
}
- }
- if (!ExpiredEntries.empty())
- {
- for (const CasDiskIndexEntry& Entry : ExpiredEntries)
+ for (const IoHash& Cid : UnusedCids)
+ {
+ if (auto It = m_CasContainerStrategy.m_LocationMap.find(Cid); It != m_CasContainerStrategy.m_LocationMap.end())
+ {
+ ExpiredEntries.push_back({.Key = Cid,
+ .Location = m_CasContainerStrategy.m_Locations[It->second],
+ .Flags = CasDiskIndexEntry::kTombstone});
+ }
+ }
+
+ if (!ExpiredEntries.empty())
{
- m_CasContainerStrategy.m_LocationMap.erase(Entry.Key);
- Stats.DeletedCount++;
+ for (const CasDiskIndexEntry& Entry : ExpiredEntries)
+ {
+ m_CasContainerStrategy.m_LocationMap.erase(Entry.Key);
+ Stats.DeletedCount++;
+ }
+ m_CasContainerStrategy.m_CasLog.Append(ExpiredEntries);
+ m_CasContainerStrategy.m_CasLog.Flush();
}
- m_CasContainerStrategy.m_CasLog.Append(ExpiredEntries);
- m_CasContainerStrategy.m_CasLog.Flush();
}
}
}