diff options
| author | Stefan Boberg <[email protected]> | 2021-09-21 12:55:42 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-21 12:55:42 +0200 |
| commit | 76c5774982fa96d9551b360d541db8a7dba9ab7e (patch) | |
| tree | 9b8f1411d7f5d5aca860be14797cdfc24c9f9659 | |
| parent | Trigger storage scrubbing pass at startup (diff) | |
| download | zen-76c5774982fa96d9551b360d541db8a7dba9ab7e.tar.xz zen-76c5774982fa96d9551b360d541db8a7dba9ab7e.zip | |
Fixed an issue in scrubbing which would flag certain chunks as invalid
Added some more context to log output
| -rw-r--r-- | zenstore/compactcas.cpp | 14 | ||||
| -rw-r--r-- | zenstore/compactcas.h | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index fe38f0fde..f17b8d376 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -5,6 +5,7 @@ #include "CompactCas.h" #include <zencore/except.h> +#include <zencore/logging.h> #include <zencore/memory.h> #include <zencore/string.h> #include <zencore/thread.h> @@ -32,7 +33,9 @@ CasContainerStrategy::Initialize(const std::string_view ContainerBaseName, uint6 ZEN_ASSERT(IsPow2(Alignment)); ZEN_ASSERT(!m_IsInitialized); - m_PayloadAlignment = Alignment; + m_ContainerBaseName = ContainerBaseName; + m_PayloadAlignment = Alignment; + std::string BaseName(ContainerBaseName); std::filesystem::path SobsPath = m_Config.RootDirectory / (BaseName + ".ucas"); std::filesystem::path SidxPath = m_Config.RootDirectory / (BaseName + ".uidx"); @@ -210,7 +213,7 @@ CasContainerStrategy::Scrub(ScrubContext& Ctx) continue; } - const IoHash ComputedHash = IoHash::HashBuffer(BufferBase, Entry.second.Size); + const IoHash ComputedHash = IoHash::HashBuffer(reinterpret_cast<uint8_t*>(BufferBase) + Entry.second.Offset - WindowStart, Entry.second.Size); if (Entry.first != ComputedHash) { @@ -242,6 +245,13 @@ CasContainerStrategy::Scrub(ScrubContext& Ctx) } } + if (BadChunks.empty()) + { + return; + } + + ZEN_ERROR("Scrubbing found {} bad chunks in '{}'", BadChunks.size(), m_ContainerBaseName); + // Deal with bad chunks by removing them from our lookup map std::vector<IoHash> BadChunkHashes; diff --git a/zenstore/compactcas.h b/zenstore/compactcas.h index 101e6b1b7..a512c3d93 100644 --- a/zenstore/compactcas.h +++ b/zenstore/compactcas.h @@ -69,6 +69,7 @@ private: BasicFile m_SmallObjectFile; BasicFile m_SmallObjectIndex; TCasLogFile<CasDiskIndexEntry> m_CasLog; + std::string m_ContainerBaseName; RwLock m_LocationMapLock; std::unordered_map<IoHash, CasDiskLocation, IoHash::Hasher> m_LocationMap; |