diff options
| author | Dan Engelbrecht <[email protected]> | 2022-05-03 23:04:45 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-05-03 23:04:45 +0200 |
| commit | a19eee841d7ce0c9c868dced40a6380f55cdb9bd (patch) | |
| tree | 7dc1a81d9ba159588e845c94c10eb7e391cfed9b /zenstore/include | |
| parent | unused variable in test fix (diff) | |
| download | zen-a19eee841d7ce0c9c868dced40a6380f55cdb9bd.tar.xz zen-a19eee841d7ce0c9c868dced40a6380f55cdb9bd.zip | |
handle that more than one block can be written to in parallel
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; |