aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-03-11 22:46:47 +0100
committerDan Engelbrecht <[email protected]>2022-03-31 11:28:31 +0200
commit4ead3f9304c791840ee585d320fcd67ea0c21e5b (patch)
tree34e60dff0145cbb283f21bc7b70c6377510015cb /zenstore/compactcas.cpp
parentRewrite smallobjectindex after gc (diff)
downloadzen-4ead3f9304c791840ee585d320fcd67ea0c21e5b.tar.xz
zen-4ead3f9304c791840ee585d320fcd67ea0c21e5b.zip
We don't use the uidx file for anything, disable for now
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp78
1 files changed, 34 insertions, 44 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index 7b68f0ebc..133784cb6 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -77,14 +77,14 @@ CasContainerStrategy::InsertChunk(const void* ChunkData, size_t ChunkSize, const
m_SmallObjectFile.Write(ChunkData, ChunkSize, InsertOffset);
m_CurrentInsertOffset = (m_CurrentInsertOffset + ChunkSize + m_PayloadAlignment - 1) & ~(m_PayloadAlignment - 1);
- RwLock::ExclusiveLockScope __(m_LocationMapLock);
-
const CasDiskLocation Location{InsertOffset, ChunkSize};
-
- m_LocationMap[ChunkHash] = Location;
-
CasDiskIndexEntry IndexEntry{.Key = ChunkHash, .Location = Location};
+// m_SmallObjectIndex.Write(&IndexEntry, sizeof(CasDiskIndexEntry), m_CurrentIndexOffset);
+// m_CurrentIndexOffset += sizeof(CasDiskIndexEntry);
+
+ RwLock::ExclusiveLockScope __(m_LocationMapLock);
+ m_LocationMap[ChunkHash] = Location;
m_TotalSize.fetch_add(static_cast<uint64_t>(ChunkSize));
m_CasLog.Append(IndexEntry);
@@ -144,7 +144,7 @@ void
CasContainerStrategy::Flush()
{
m_CasLog.Flush();
- m_SmallObjectIndex.Flush();
+// m_SmallObjectIndex.Flush();
m_SmallObjectFile.Flush();
}
@@ -438,32 +438,31 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
m_CurrentInsertOffset = 0;
}
- if (!MovedChunks.empty() || DeletedChunks.empty())
- {
- // Rewrite object index
- std::filesystem::path SidxPath = m_Config.RootDirectory / (m_ContainerBaseName + ".uidx");
- std::filesystem::path TmpSidxPath = m_Config.RootDirectory / (m_ContainerBaseName + ".gc.uidx");
- BasicFile TmpSmallObjectIndex;
- TmpSmallObjectIndex.Open(TmpSidxPath, true);
-
- std::vector<CasDiskIndexEntry> Entries{m_LocationMap.size()};
- uint64_t EntryIndex = 0;
- for (auto& Entry : m_LocationMap)
- {
- CasDiskIndexEntry& IndexEntry = Entries[EntryIndex++];
- IndexEntry.Key = Entry.first;
- IndexEntry.Location = Entry.second;
- }
-
- TmpSmallObjectIndex.Write(Entries.data(), Entries.size() * sizeof(CasDiskIndexEntry), 0);
- TmpSmallObjectIndex.Flush();
- TmpSmallObjectIndex.Close();
-
- m_SmallObjectIndex.Close();
- fs::remove(SidxPath);
- fs::rename(TmpSidxPath, SidxPath);
- m_SmallObjectIndex.Open(SidxPath, false);
- }
+// if (!MovedChunks.empty() || DeletedChunks.empty())
+// {
+// // Rewrite object index
+// std::filesystem::path SidxPath = m_Config.RootDirectory / (m_ContainerBaseName + ".uidx");
+// std::filesystem::path TmpSidxPath = m_Config.RootDirectory / (m_ContainerBaseName + ".gc.uidx");
+// BasicFile TmpSmallObjectIndex;
+// TmpSmallObjectIndex.Open(TmpSidxPath, true);
+//
+// std::vector<CasDiskIndexEntry> Entries{m_LocationMap.size()};
+// uint64_t EntryIndex = 0;
+// for (auto& Entry : m_LocationMap)
+// {
+// CasDiskIndexEntry& IndexEntry = Entries[EntryIndex++];
+// IndexEntry.Key = Entry.first;
+// IndexEntry.Location = Entry.second;
+// }
+//
+// TmpSmallObjectIndex.Write(Entries.data(), Entries.size() * sizeof(CasDiskIndexEntry), 0);
+// TmpSmallObjectIndex.Close();
+//
+// m_SmallObjectIndex.Close();
+// fs::remove(SidxPath);
+// fs::rename(TmpSidxPath, SidxPath);
+// m_SmallObjectIndex.Open(SidxPath, false);
+// }
// TODO: Should we flush the cas log? It will grow forever...
@@ -486,13 +485,13 @@ CasContainerStrategy::OpenContainer(bool IsNewStore)
std::filesystem::path SlogPath = m_Config.RootDirectory / (m_ContainerBaseName + ".ulog");
m_SmallObjectFile.Open(SobsPath, IsNewStore);
- m_SmallObjectIndex.Open(SidxPath, IsNewStore);
+// m_SmallObjectIndex.Open(SidxPath, IsNewStore);
m_CasLog.Open(SlogPath, IsNewStore);
// TODO: should validate integrity of container files here
m_CurrentInsertOffset = 0;
- m_CurrentIndexOffset = 0;
+// m_CurrentIndexOffset = 0;
m_TotalSize = 0;
m_LocationMap.clear();
@@ -519,16 +518,7 @@ CasContainerStrategy::OpenContainer(bool IsNewStore)
}
m_CurrentInsertOffset = (MaxFileOffset + m_PayloadAlignment - 1) & ~(m_PayloadAlignment - 1);
-
- m_CurrentIndexOffset = m_SmallObjectIndex.FileSize();
-}
-
-void
-CasContainerStrategy::CloseContainer()
-{
- m_SmallObjectFile.Close();
- m_SmallObjectIndex.Close();
- m_CasLog.Close();
+// m_CurrentIndexOffset = m_SmallObjectIndex.FileSize();
}
//////////////////////////////////////////////////////////////////////////