aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.h
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-03-22 23:25:55 +0100
committerDan Engelbrecht <[email protected]>2022-03-31 11:29:26 +0200
commitc9ecf2a3014d3a2b0e8efbc236300814f6d55e45 (patch)
tree291023601678769756d92871b2be3c54bceff207 /zenstore/compactcas.h
parentTry to recreate gc reserve after successful garbage collect if it is not present (diff)
downloadzen-c9ecf2a3014d3a2b0e8efbc236300814f6d55e45.tar.xz
zen-c9ecf2a3014d3a2b0e8efbc236300814f6d55e45.zip
Make garbage collection state copy less complex
Diffstat (limited to 'zenstore/compactcas.h')
-rw-r--r--zenstore/compactcas.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/zenstore/compactcas.h b/zenstore/compactcas.h
index f9e60aec8..398218cd0 100644
--- a/zenstore/compactcas.h
+++ b/zenstore/compactcas.h
@@ -45,26 +45,30 @@ struct CasDiskLocation
inline CasLocation Get(uint64_t OffsetAlignement) const
{
- return {.BlockIndex = BlockIndex(), .Offset = Offset() * OffsetAlignement, .Size = Size()};
+ uint64_t PackedOffset = 0;
+ memcpy(&PackedOffset, &m_Offset, sizeof m_Offset);
+ return {.BlockIndex = static_cast<std::uint32_t>(PackedOffset >> MaxOffsetBits),
+ .Offset = (PackedOffset & MaxOffset) * OffsetAlignement,
+ .Size = GetSize()};
}
-private:
- inline uint32_t BlockIndex() const
+ inline uint32_t GetBlockIndex() const
{
uint64_t PackedOffset = 0;
memcpy(&PackedOffset, &m_Offset, sizeof m_Offset);
return static_cast<std::uint32_t>(PackedOffset >> MaxOffsetBits);
}
- inline uint64_t Offset() const
+ inline uint64_t GetOffset() const
{
uint64_t PackedOffset = 0;
memcpy(&PackedOffset, &m_Offset, sizeof m_Offset);
return PackedOffset & MaxOffset;
}
- inline uint64_t Size() const { return m_Size; }
+ inline uint64_t GetSize() const { return m_Size; }
+private:
inline void Init(uint32_t BlockIndex, uint64_t Offset, uint64_t Size)
{
ZEN_ASSERT(BlockIndex <= MaxBlockIndex);