blob: 04ffffdd2980d35c0f9451ef4c4616b8cbc15ba2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include <zencore/zencore.h>
#include <zencore/filesystem.h>
#include <zencore/iobuffer.h>
#include <zencore/iohash.h>
#include <zencore/thread.h>
#include <zenstore/CAS.h>
#include <functional>
namespace spdlog {
class logger;
}
namespace zen {
class BasicFile;
/** CAS storage strategy using a file-per-chunk storage strategy
*/
struct FileCasStrategy
{
FileCasStrategy(const CasStoreConfiguration& Config);
~FileCasStrategy();
CasStore::InsertResult InsertChunk(const void* ChunkData, size_t ChunkSize, const IoHash& ChunkHash);
CasStore::InsertResult InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash);
IoBuffer FindChunk(const IoHash& ChunkHash);
bool HaveChunk(const IoHash& ChunkHash);
void FilterChunks(CasChunkSet& InOutChunks);
void Flush();
void GarbageCollect(GcContext& GcCtx);
void Scrub(ScrubContext& Ctx);
private:
const CasStoreConfiguration& m_Config;
RwLock m_Lock;
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; }
inline RwLock& LockForHash(const IoHash& Hash) { return m_ShardLocks[Hash.Hash[19]]; }
void IterateChunks(std::function<void(const IoHash& Hash, BasicFile& PayloadFile)>&& Callback);
void DeleteChunk(const IoHash& ChunkHash, std::error_code& Ec);
struct ShardingHelper
{
ShardingHelper(const std::filesystem::path& RootPath, const IoHash& ChunkHash);
size_t Shard2len = 0;
ExtendablePathBuilder<128> ShardedPath;
};
};
void filecas_forcelink();
} // namespace zen
|