aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenstore')
-rw-r--r--src/zenstore/compactcas.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index 9aa4ff613..50af7246e 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -329,31 +329,33 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes,
{
ZEN_MEMSCOPE(GetCasContainerTag());
- const size_t ChunkCount = ChunkHashes.size();
- if (ChunkCount < 3)
+ const size_t ChunkCount = ChunkHashes.size();
+ std::vector<size_t> FoundChunkIndexes;
+ std::vector<BlockStoreLocation> FoundChunkLocations;
+ FoundChunkIndexes.reserve(ChunkCount);
+ FoundChunkLocations.reserve(ChunkCount);
{
+ RwLock::SharedLockScope _(m_LocationMapLock);
for (size_t ChunkIndex = 0; ChunkIndex < ChunkCount; ChunkIndex++)
{
- IoBuffer Chunk = FindChunk(ChunkHashes[ChunkIndex]);
- if (!AsyncCallback(ChunkIndex, Chunk))
+ if (auto KeyIt = m_LocationMap.find(ChunkHashes[ChunkIndex]); KeyIt != m_LocationMap.end())
{
- return false;
+ FoundChunkIndexes.push_back(ChunkIndex);
+ FoundChunkLocations.push_back(m_Locations[KeyIt->second].Get(m_PayloadAlignment));
}
}
- return true;
}
- std::vector<size_t> FoundChunkIndexes;
- std::vector<BlockStoreLocation> FoundChunkLocations;
- FoundChunkIndexes.reserve(ChunkCount);
- FoundChunkLocations.reserve(ChunkCount);
- RwLock::SharedLockScope _(m_LocationMapLock);
- for (size_t ChunkIndex = 0; ChunkIndex < ChunkCount; ChunkIndex++)
+ if (FoundChunkLocations.size() < 3)
{
- if (auto KeyIt = m_LocationMap.find(ChunkHashes[ChunkIndex]); KeyIt != m_LocationMap.end())
+ for (size_t ChunkIndex : FoundChunkIndexes)
{
- FoundChunkIndexes.push_back(ChunkIndex);
- FoundChunkLocations.push_back(m_Locations[KeyIt->second].Get(m_PayloadAlignment));
+ IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]);
+ if (!AsyncCallback(ChunkIndex, Chunk))
+ {
+ return false;
+ }
}
+ return true;
}
auto DoOneBlock = [&](std::span<const size_t> ChunkIndexes) {