diff options
Diffstat (limited to 'zenstore/include')
| -rw-r--r-- | zenstore/include/zenstore/blockstore.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/zenstore/include/zenstore/blockstore.h b/zenstore/include/zenstore/blockstore.h index e330cc080..9edfc36e8 100644 --- a/zenstore/include/zenstore/blockstore.h +++ b/zenstore/include/zenstore/blockstore.h @@ -110,8 +110,8 @@ class BlockStore public: struct ReclaimSnapshotState { - size_t ExcludeBlockIndex; - size_t BlockCount; + std::unordered_set<uint32_t> m_ActiveWriteBlocks; + size_t BlockCount; }; typedef std::vector<std::pair<size_t, BlockStoreLocation>> MovedChunksArray; @@ -123,6 +123,7 @@ public: typedef std::function<void(size_t ChunkIndex, Ref<BlockStoreFile> BlockFile, uint64_t Offset, uint64_t Size)> IterateChunksLargeSizeCallback; typedef std::function<void(const MovedChunksArray& MovedChunks)> SplitCallback; + typedef std::function<void(const BlockStoreLocation& Location)> WriteChunkCallback; void Initialize(const std::filesystem::path& BlocksBasePath, uint64_t MaxBlockSize, @@ -130,7 +131,7 @@ public: const std::vector<BlockStoreLocation>& KnownLocations); void Close(); - BlockStoreLocation WriteChunk(const void* Data, uint64_t Size, uint64_t Alignment); + void WriteChunk(const void* Data, uint64_t Size, uint64_t Alignment, WriteChunkCallback Callback); Ref<BlockStoreFile> GetChunkBlock(const BlockStoreLocation& Location); void Flush(); @@ -164,10 +165,11 @@ public: private: std::unordered_map<uint32_t, Ref<BlockStoreFile>> m_ChunkBlocks; - RwLock m_InsertLock; // used to serialize inserts - Ref<BlockStoreFile> m_WriteBlock; - std::uint64_t m_CurrentInsertOffset = 0; - std::atomic_uint32_t m_WriteBlockIndex{}; + RwLock m_InsertLock; // used to serialize inserts + Ref<BlockStoreFile> m_WriteBlock; + std::uint64_t m_CurrentInsertOffset = 0; + std::atomic_uint32_t m_WriteBlockIndex{}; + std::vector<uint32_t> m_ActiveWriteBlocks; uint64_t m_MaxBlockSize = 1u << 28; uint64_t m_MaxBlockCount = BlockStoreDiskLocation::MaxBlockIndex + 1; |