aboutsummaryrefslogtreecommitdiff
path: root/zenserver/projectstore.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-28 13:58:28 +0200
committerStefan Boberg <[email protected]>2021-10-28 13:58:28 +0200
commite140ec960bec2a3c2b867361af35b312a5bbc53d (patch)
treef04bb05d0906948b8acd53c7efbd69dd5e4c4db5 /zenserver/projectstore.cpp
parentMerge remote-tracking branch 'origin/main' into gc (diff)
downloadzen-e140ec960bec2a3c2b867361af35b312a5bbc53d.tar.xz
zen-e140ec960bec2a3c2b867361af35b312a5bbc53d.zip
gc: Implemented initial root gathering for projects/oplogs
Diffstat (limited to 'zenserver/projectstore.cpp')
-rw-r--r--zenserver/projectstore.cpp56
1 files changed, 52 insertions, 4 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp
index 73d61c124..72d7284a0 100644
--- a/zenserver/projectstore.cpp
+++ b/zenserver/projectstore.cpp
@@ -298,6 +298,36 @@ ProjectStore::Oplog::Flush()
m_Storage->Flush();
}
+void
+ProjectStore::Oplog::Scrub(ScrubContext& Ctx) const
+{
+ ZEN_UNUSED(Ctx);
+}
+
+void
+ProjectStore::Oplog::GatherReferences(GcContext& GcCtx) const
+{
+ RwLock::SharedLockScope _(m_OplogLock);
+
+ std::vector<IoHash> Hashes;
+
+ for (const auto& Kv : m_ChunkMap)
+ {
+ Hashes.push_back(Kv.second);
+ }
+
+ GcCtx.ContributeCids(Hashes);
+
+ Hashes.clear();
+
+ for (const auto& Kv : m_MetaMap)
+ {
+ Hashes.push_back(Kv.second);
+ }
+
+ GcCtx.ContributeCids(Hashes);
+}
+
bool
ProjectStore::Oplog::ExistsAt(std::filesystem::path BasePath)
{
@@ -750,7 +780,7 @@ ProjectStore::Project::DeleteOplog(std::string_view OplogId)
void
ProjectStore::Project::IterateOplogs(std::function<void(const Oplog&)>&& Fn) const
{
- // TODO: should iterate over oplogs which are present on disk but not yet loaded
+ // TODO: should also iterate over oplogs which are present on disk but not yet loaded
RwLock::SharedLockScope _(m_ProjectLock);
@@ -769,13 +799,20 @@ ProjectStore::Project::Flush()
void
ProjectStore::Project::Scrub(ScrubContext& Ctx)
{
- ZEN_UNUSED(Ctx);
+ IterateOplogs([&](const Oplog& Ops) { Ops.Scrub(Ctx); });
+}
+
+void
+ProjectStore::Project::GatherReferences(GcContext& GcCtx)
+{
+ IterateOplogs([&](const Oplog& Ops) { Ops.GatherReferences(GcCtx); });
}
//////////////////////////////////////////////////////////////////////////
-ProjectStore::ProjectStore(CidStore& Store, std::filesystem::path BasePath)
-: m_Log(zen::logging::Get("project"))
+ProjectStore::ProjectStore(CidStore& Store, std::filesystem::path BasePath, CasGc& Gc)
+: GcContributor(Gc)
+, m_Log(zen::logging::Get("project"))
, m_ProjectBasePath(BasePath)
, m_CidStore(Store)
{
@@ -818,6 +855,17 @@ ProjectStore::Scrub(ScrubContext& Ctx)
}
}
+void
+ProjectStore::GatherReferences(GcContext& GcCtx)
+{
+ RwLock::SharedLockScope _(m_ProjectsLock);
+
+ for (auto& Kv : m_Projects)
+ {
+ Kv.second.GatherReferences(GcCtx);
+ }
+}
+
ProjectStore::Project*
ProjectStore::OpenProject(std::string_view ProjectId)
{