aboutsummaryrefslogtreecommitdiff
path: root/zenstore/filecas.h
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore/filecas.h')
-rw-r--r--zenstore/filecas.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/zenstore/filecas.h b/zenstore/filecas.h
index 29c28560e..420b3a634 100644
--- a/zenstore/filecas.h
+++ b/zenstore/filecas.h
@@ -45,16 +45,26 @@ struct FileCasStrategy final : public GcStorage
virtual GcStorageSize StorageSize() const override { return {.DiskSize = m_TotalSize.load(std::memory_order::relaxed)}; }
private:
+ void MakeIndexSnapshot();
+ uint64_t ReadIndexFile();
+ uint64_t ReadLog(uint64_t LogPosition);
+
+ struct IndexEntry
+ {
+ uint64_t Size = 0;
+ };
+ using IndexMap = tsl::robin_map<IoHash, IndexEntry, IoHash::Hasher>;
+
CasStore::InsertResult InsertChunk(const void* ChunkData, size_t ChunkSize, const IoHash& ChunkHash);
- std::filesystem::path m_RootDirectory;
- RwLock m_Lock;
- std::unordered_set<IoHash, IoHash::Hasher> m_KnownEntries;
- RwLock m_ShardLocks[256]; // TODO: these should be spaced out so they don't share cache lines
- spdlog::logger& m_Log;
- spdlog::logger& Log() { return m_Log; }
- std::atomic_uint64_t m_TotalSize{};
- bool m_IsInitialized = false;
+ std::filesystem::path m_RootDirectory;
+ RwLock m_Lock;
+ IndexMap m_Index;
+ RwLock m_ShardLocks[256]; // TODO: these should be spaced out so they don't share cache lines
+ spdlog::logger& m_Log;
+ spdlog::logger& Log() { return m_Log; }
+ std::atomic_uint64_t m_TotalSize{};
+ bool m_IsInitialized = false;
struct FileCasIndexEntry
{
@@ -66,13 +76,16 @@ private:
uint32_t Flags = 0;
uint64_t Size = 0;
};
+ static bool ValidateEntry(const FileCasIndexEntry& Entry, std::string& OutReason);
+ static std::vector<FileCasStrategy::FileCasIndexEntry> ScanFolderForCasFiles(const std::filesystem::path& RootDir);
static_assert(sizeof(FileCasIndexEntry) == 32);
TCasLogFile<FileCasIndexEntry> m_CasLog;
+ uint64_t m_LogFlushPosition = 0;
inline RwLock& LockForHash(const IoHash& Hash) { return m_ShardLocks[Hash.Hash[19]]; }
- void IterateChunks(std::function<void(const IoHash& Hash, BasicFile& PayloadFile)>&& Callback);
+ void IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&& Payload)>&& Callback);
void DeleteChunk(const IoHash& ChunkHash, std::error_code& Ec);
struct ShardingHelper