diff options
| author | Dan Engelbrecht <[email protected]> | 2023-11-24 13:26:51 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-24 13:26:51 +0100 |
| commit | 254d2f89c110fc5f14e658505559a7e7534a984d (patch) | |
| tree | 511e8dcbae633ae4ccaea20f29b9b04bc41ea875 /src/zenstore/compactcas.cpp | |
| parent | fix truncation of sentry hostname (diff) | |
| download | zen-254d2f89c110fc5f14e658505559a7e7534a984d.tar.xz zen-254d2f89c110fc5f14e658505559a7e7534a984d.zip | |
Add GC Cancel/Stop (#568)
- GcScheduler will now cancel any running GC when it shuts down.
- Old GC is rather limited in *when* it reacts to cancel of GC. GCv2 is more responsive.
Diffstat (limited to 'src/zenstore/compactcas.cpp')
| -rw-r--r-- | src/zenstore/compactcas.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 02db5f848..f28601771 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -577,6 +577,11 @@ public: std::unordered_map<uint32_t, uint64_t> BlockUsage; { RwLock::SharedLockScope __(m_CasContainerStrategy.m_LocationMapLock); + if (Ctx.IsCancelledFlag.load()) + { + return; + } + for (const auto& Entry : m_CasContainerStrategy.m_LocationMap) { size_t Index = Entry.second; @@ -660,6 +665,11 @@ public: } m_CasContainerStrategy.m_CasLog.Append(MovedEntries); Stats.RemovedDisk += FreedDiskSpace; + if (Ctx.IsCancelledFlag.load()) + { + return false; + } + return true; }, ClaimDiskReserveCallback); } @@ -720,6 +730,10 @@ public: { RwLock::ExclusiveLockScope __(m_CasContainerStrategy.m_LocationMapLock); + if (Ctx.IsCancelledFlag.load()) + { + return nullptr; + } for (const IoHash& Cid : UnusedCids) { @@ -784,6 +798,11 @@ CasContainerStrategy::CreateReferencePruner(GcCtx& Ctx, GcReferenceStoreStats&) { return {}; } + if (Ctx.IsCancelledFlag.load()) + { + return nullptr; + } + CidsToCheck.reserve(m_LocationMap.size()); for (const auto& It : m_LocationMap) { |