From 666a543ed82896c972526ef08476a41ccbfbd2c4 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Thu, 24 Nov 2022 13:20:59 +0100 Subject: Fix disk usage stats (#194) * Improve tracking of used disk space for filecas and compactcas Add tracking of used disk space for project store Remove ZenCacheStore as GcStorage/GcContributor - underlying ZenCacheNamespace instances register themselves directly - removing this also fixes double reporting of GcStorageSize for namespaces * changelog --- zenstore/include/zenstore/blockstore.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'zenstore/include') diff --git a/zenstore/include/zenstore/blockstore.h b/zenstore/include/zenstore/blockstore.h index 9f16063a0..5ef2d4694 100644 --- a/zenstore/include/zenstore/blockstore.h +++ b/zenstore/include/zenstore/blockstore.h @@ -96,7 +96,6 @@ struct BlockStoreFile : public RefCounted IoBuffer GetChunk(uint64_t Offset, uint64_t Size); void Read(void* Data, uint64_t Size, uint64_t FileOffset); void Write(const void* Data, uint64_t Size, uint64_t FileOffset); - void Truncate(uint64_t Size); void Flush(); BasicFile& GetBasicFile(); void StreamByteRange(uint64_t FileOffset, uint64_t Size, std::function&& ChunkFun); @@ -153,6 +152,8 @@ public: static const char* GetBlockFileExtension(); static std::filesystem::path GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint32_t BlockIndex); + inline uint64_t TotalSize() const { return m_TotalSize.load(std::memory_order::relaxed); } + private: std::unordered_map> m_ChunkBlocks; @@ -165,6 +166,8 @@ private: uint64_t m_MaxBlockSize = 1u << 28; uint64_t m_MaxBlockCount = BlockStoreDiskLocation::MaxBlockIndex + 1; std::filesystem::path m_BlocksBasePath; + + std::atomic_uint64_t m_TotalSize{}; }; void blockstore_forcelink(); -- cgit v1.2.3