From f0d389a4430b62bfa8ea0852905fcf84065b08c2 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Fri, 20 May 2022 18:45:35 +0200 Subject: Add catch2 support (#101) Added option to use catch2 for unit tests Currently both doctest and catch2 are supported via some compatibility macros. doctest is the default, and ZEN_USE_CATCH2 needs to be defined to switch to catch2. Our goal is to evaluate how well catch2 works and switch to catch2 if everything pans out since UE5 now supports using catch2 for unit tests. --- zenstore/blockstore.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'zenstore/blockstore.cpp') diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index d490678b5..3e27b0d12 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -911,12 +911,6 @@ BlockStore::GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint #if ZEN_WITH_TESTS -static bool -operator==(const BlockStoreLocation& Lhs, const BlockStoreLocation& Rhs) -{ - return Lhs.BlockIndex == Rhs.BlockIndex && Lhs.Offset == Rhs.Offset && Lhs.Size == Rhs.Size; -} - TEST_CASE("blockstore.blockstoredisklocation") { BlockStoreLocation Zero = BlockStoreLocation{.BlockIndex = 0, .Offset = 0, .Size = 0}; -- cgit v1.2.3 From 682c7d68f8ba2d0bea16ef382c2b35a772b4c8bc Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 27 May 2022 08:25:50 +0200 Subject: Make sure we can properly create the block file before assigning it for use --- zenstore/blockstore.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'zenstore/blockstore.cpp') diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index 3e27b0d12..7d3d2f5bb 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -225,23 +225,27 @@ BlockStore::WriteChunk(const void* Data, uint64_t Size, uint64_t Alignment, Writ { m_WriteBlock = nullptr; } + + if (m_ChunkBlocks.size() == m_MaxBlockCount) { - if (m_ChunkBlocks.size() == m_MaxBlockCount) - { - throw std::runtime_error(fmt::format("unable to allocate a new block in '{}'", m_BlocksBasePath)); - } - WriteBlockIndex += IsWriting ? 1 : 0; - while (m_ChunkBlocks.contains(WriteBlockIndex)) - { - WriteBlockIndex = (WriteBlockIndex + 1) & (m_MaxBlockCount - 1); - } - std::filesystem::path BlockPath = GetBlockPath(m_BlocksBasePath, WriteBlockIndex); - m_WriteBlock = new BlockStoreFile(BlockPath); - m_ChunkBlocks[WriteBlockIndex] = m_WriteBlock; - m_WriteBlockIndex.store(WriteBlockIndex, std::memory_order_release); + throw std::runtime_error(fmt::format("unable to allocate a new block in '{}'", m_BlocksBasePath)); + } + + WriteBlockIndex += IsWriting ? 1 : 0; + while (m_ChunkBlocks.contains(WriteBlockIndex)) + { + WriteBlockIndex = (WriteBlockIndex + 1) & (m_MaxBlockCount - 1); } + + std::filesystem::path BlockPath = GetBlockPath(m_BlocksBasePath, WriteBlockIndex); + + Ref NewBlockFile = new BlockStoreFile(BlockPath); + NewBlockFile->Create(m_MaxBlockSize); + + m_ChunkBlocks[WriteBlockIndex] = NewBlockFile; + m_WriteBlock = NewBlockFile; + m_WriteBlockIndex.store(WriteBlockIndex, std::memory_order_release); m_CurrentInsertOffset = 0; - m_WriteBlock->Create(m_MaxBlockSize); } uint64_t InsertOffset = m_CurrentInsertOffset; m_CurrentInsertOffset = RoundUp(InsertOffset + Size, Alignment); -- cgit v1.2.3 From cc540692b75192229d0d8425c3fc0406784c1760 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 31 May 2022 22:04:34 +0200 Subject: Always block GC of current write block --- zenstore/blockstore.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'zenstore/blockstore.cpp') diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index 7d3d2f5bb..4e61c23cf 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -272,6 +272,10 @@ BlockStore::GetReclaimSnapshotState() { State.m_ActiveWriteBlocks.insert(BlockIndex); } + if (m_WriteBlock) + { + State.m_ActiveWriteBlocks.insert(m_WriteBlockIndex); + } State.BlockCount = m_ChunkBlocks.size(); return State; } -- cgit v1.2.3