diff options
Diffstat (limited to 'src/zenserver/projectstore/projectstore.h')
| -rw-r--r-- | src/zenserver/projectstore/projectstore.h | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/zenserver/projectstore/projectstore.h b/src/zenserver/projectstore/projectstore.h index bed3c83b7..55a3b7dee 100644 --- a/src/zenserver/projectstore/projectstore.h +++ b/src/zenserver/projectstore/projectstore.h @@ -84,7 +84,7 @@ public: [[nodiscard]] static bool ExistsAt(const std::filesystem::path& BasePath); - void Read(bool AllowCompact); + void Read(); void Write(); void Update(const std::filesystem::path& MarkerPath); bool Reset(); @@ -169,6 +169,9 @@ public: void GetAttachmentsLocked(std::vector<IoHash>& OutAttachments, bool StoreMetaDataOnDisk); + Project* GetOuterProject() const { return m_OuterProject; } + void CompactIfUnusedExceeds(bool DryRun, uint32_t CompactUnusedThreshold, std::string_view LogPrefix); + private: struct FileMapEntry { @@ -179,12 +182,13 @@ public: template<class V> using OidMap = tsl::robin_map<Oid, V, Oid::Hasher>; - Project* m_OuterProject = nullptr; - CidStore& m_CidStore; - std::filesystem::path m_BasePath; - std::filesystem::path m_MarkerPath; - std::filesystem::path m_TempPath; - std::filesystem::path m_MetaPath; + Project* m_OuterProject = nullptr; + const std::string m_OplogId; + CidStore& m_CidStore; + const std::filesystem::path m_BasePath; + std::filesystem::path m_MarkerPath; + std::filesystem::path m_TempPath; + std::filesystem::path m_MetaPath; mutable RwLock m_OplogLock; OidMap<IoHash> m_ChunkMap; // output data chunk id -> CAS address @@ -201,14 +205,15 @@ public: std::unique_ptr<std::vector<IoHash>> m_CapturedAttachments; RefPtr<OplogStorage> m_Storage; - const std::string m_OplogId; + uint64_t m_LogFlushPosition = 0; RefPtr<OplogStorage> GetStorage(); /** Scan oplog and register each entry, thus updating the in-memory tracking tables */ - void ReplayLog(bool AllowCompact); uint32_t GetUnusedSpacePercentLocked() const; + void WriteIndexSnapshot(); + void ReadIndexSnapshot(); struct OplogEntryMapping { @@ -269,16 +274,12 @@ public: void IterateOplogs(std::function<void(const RwLock::SharedLockScope&, const Oplog&)>&& Fn) const; void IterateOplogs(std::function<void(const RwLock::SharedLockScope&, Oplog&)>&& Fn); std::vector<std::string> ScanForOplogs() const; - bool IsExpired(const RwLock::SharedLockScope&, const GcClock::TimePoint ExpireTime); - bool IsExpired(const RwLock::SharedLockScope&, const GcClock::TimePoint ExpireTime, const ProjectStore::Oplog& Oplog); - bool IsExpired(const GcClock::TimePoint ExpireTime, const ProjectStore::Oplog& Oplog); - bool IsOplogTouchedSince(const RwLock::SharedLockScope& ProjectLock, - const GcClock::TimePoint TouchTime, - std::string_view Oplog) const; - - void TouchProject() const; - void TouchOplog(std::string_view Oplog) const; - GcClock::TimePoint LastOplogAccessTime(std::string_view Oplog) const; + bool IsExpired(const GcClock::TimePoint ExpireTime) const; + bool IsExpired(const GcClock::TimePoint ExpireTime, const ProjectStore::Oplog& Oplog) const; + bool IsOplogTouchedSince(const GcClock::TimePoint TouchTime, std::string_view Oplog) const; + void TouchProject(); + void TouchOplog(std::string_view Oplog); + GcClock::TimePoint LastOplogAccessTime(std::string_view Oplog) const; Project(ProjectStore* PrjStore, CidStore& Store, std::filesystem::path BasePath); virtual ~Project(); @@ -288,7 +289,7 @@ public: [[nodiscard]] static bool Exists(const std::filesystem::path& BasePath); void Flush(); void ScrubStorage(ScrubContext& Ctx); - LoggerRef Log(); + LoggerRef Log() const; void GatherReferences(GcContext& GcCtx); static uint64_t TotalSize(const std::filesystem::path& BasePath); uint64_t TotalSize() const; @@ -307,18 +308,16 @@ public: std::map<std::string, std::unique_ptr<Oplog>> m_Oplogs; std::vector<std::unique_ptr<Oplog>> m_DeletedOplogs; std::filesystem::path m_OplogStoragePath; + mutable RwLock m_LastAccessTimesLock; mutable tsl::robin_map<std::string, GcClock::Tick> m_LastAccessTimes; mutable RwLock m_UpdateCaptureLock; uint32_t m_UpdateCaptureRefCounter = 0; std::unique_ptr<std::vector<std::string>> m_CapturedOplogs; - std::filesystem::path BasePathForOplog(std::string_view OplogId); - bool IsExpired(const RwLock::SharedLockScope&, - const std::string& EntryName, - const std::filesystem::path& MarkerPath, - const GcClock::TimePoint ExpireTime); - void WriteAccessTimes(); - void ReadAccessTimes(); + std::filesystem::path BasePathForOplog(std::string_view OplogId) const; + bool IsExpired(const std::string& EntryName, const std::filesystem::path& MarkerPath, const GcClock::TimePoint ExpireTime) const; + void WriteAccessTimes(); + void ReadAccessTimes(); friend class ProjectStoreOplogReferenceChecker; friend class ProjectStoreReferenceChecker; |