aboutsummaryrefslogtreecommitdiff
path: root/zenstore
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2022-06-03 10:08:22 +0200
committerStefan Boberg <[email protected]>2022-06-03 10:08:22 +0200
commit91e2573a1fdebc1c3cbbbc5d5f9be3b6f540463b (patch)
tree2bf98fe4a1dfa20bace298d0f51b1a2d8b9a7217 /zenstore
parentMerge branch 'main' into use-catch2 (diff)
parentmove release job to in-house linux agent (diff)
downloadzen-91e2573a1fdebc1c3cbbbc5d5f9be3b6f540463b.tar.xz
zen-91e2573a1fdebc1c3cbbbc5d5f9be3b6f540463b.zip
merge from main
Diffstat (limited to 'zenstore')
-rw-r--r--zenstore/blockstore.cpp42
-rw-r--r--zenstore/compactcas.cpp6
-rw-r--r--zenstore/gc.cpp3
-rw-r--r--zenstore/include/zenstore/blockstore.h2
4 files changed, 31 insertions, 22 deletions
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp
index d490678b5..4e61c23cf 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<BlockStoreFile> 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);
@@ -268,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;
}
@@ -911,12 +919,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};
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index c277359bd..65f959a0e 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -1894,8 +1894,12 @@ TEST_CASE("compactcas.threadedinsert")
}
}
-TEST_CASE("compactcas.migrate.large.data") // * doctest::skip(true))
+TEST_CASE("compactcas.migrate.large.data") // * doctest::skip(true))
{
+ if (true)
+ {
+ return;
+ }
const char* BigDataPath = "D:\\zen-data\\dc4-zen-cache-t\\cas";
std::filesystem::path TobsBasePath = GetBasePath(BigDataPath, "tobs");
std::filesystem::path SobsBasePath = GetBasePath(BigDataPath, "sobs");
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index 4b50668d9..8e2d441f8 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -343,7 +343,7 @@ GcStorage::GcStorage(CasGc& Gc) : m_Gc(Gc)
GcStorage::~GcStorage()
{
- m_Gc.AddGcStorage(this);
+ m_Gc.RemoveGcStorage(this);
}
//////////////////////////////////////////////////////////////////////////
@@ -373,6 +373,7 @@ CasGc::RemoveGcContributor(GcContributor* Contributor)
void
CasGc::AddGcStorage(GcStorage* Storage)
{
+ ZEN_ASSERT(Storage != nullptr);
RwLock::ExclusiveLockScope _(m_Lock);
m_GcStorage.push_back(Storage);
}
diff --git a/zenstore/include/zenstore/blockstore.h b/zenstore/include/zenstore/blockstore.h
index 34c475fb6..000395fb9 100644
--- a/zenstore/include/zenstore/blockstore.h
+++ b/zenstore/include/zenstore/blockstore.h
@@ -64,6 +64,8 @@ struct BlockStoreDiskLocation
inline uint64_t GetSize() const { return m_Size; }
+ inline auto operator<=>(const BlockStoreDiskLocation& Rhs) const = default;
+
private:
inline void Init(uint32_t BlockIndex, uint64_t Offset, uint64_t Size)
{