Curve文件系统元数据管理com/abseil/abseil-cpp/tree/master/absl/c ontainer 实现了btree map和btree set,(Apache)。 google, https://code.google.com/archive/p/cpp-btree/, btree_map , btree_set, btree_multimap, and btree_multiset ,( ) Apache B+tree table O(1)~O(n) O(n) + table 需要占用额外空间,性能和hash表的大小有关,最理想可以达到O(1)复杂度,最差O(n)复杂度。 c++ stl unordered_map moose,使用c实现 4、curve文件系统的元数据内存组织 curve文件系统元数据主要有3个类型,inode, dentry, 。 extent 4 nlink; /* ref count for hard link */ int64_t size; FileType type; SpaceList std::map; // string symLink; /* for symLink only */ // 0 码力 | 24 页 | 204.67 KB | 6 月前3
Curve文件系统元数据持久化方案设计+------+------------+-----+----------------+---------+----------+ 字段 字节数 说明 type 1 操作类型,共有以下 2 类: SET (0X01):ADD 和 UPDATE 都可以转换成 SET 操作 DEL (0X02):当为 DEL 操作时,value_length 和 value 则为空 key_length 4 key 长度 key $key_length 消耗却更少,推介使用 protobuf 进行序列化 2、KVStore 将当前实现中的 MemoryDentryStorage 和 MemoryInodeStorage 抽象成一个 KVStore,对外提供 SET/GET/DEL 等接口,inode/dentry 均编码后以 key-value 的形式存入 KVStore 当前实现可先只实现 KVStore(提供方便 API),Raft 等可以后续接入(目前实现中持久化可以在 OP_TYPE_SET, OP_TYPE_DEL, }; public: bool Init(); int Set(const std::string& key, const std::string& value); int Get(const std::string& key, std::string* value); int Delete(const std::string&0 码力 | 12 页 | 384.47 KB | 6 月前3
Curve支持S3 数据缓存方案该缓存方案主要针对的场景是顺序写和顺序 读,而对于随机写和随机读来说也会有一定性能提升,但效果可能不会太好。 元数据采用2层索引 由于chunk大小是固定的(默认64M),所以Inode中采用maps3ChunkInfoMap用于保存对象存储的位置信息。采用2级索引的好处是,根据操作的offset可以快速定位到index,则只需要遍历inde // TYPE_SYM_LINK only optional VolumeExtentList volumeExtentList = 13; // TYPE_FILE only map s3ChunkInfoMap = 14; // TYPE_S3 only, first is chunk index optional uint64 ClientS3Adaptor () {} void Init(const S3ClientAdaptorOption option, S3Client *client, std::shared_ptr inodeManager);© XXX Page 5 of 9 int Write(Inode *inode, uint64_t offset, 0 码力 | 9 页 | 179.72 KB | 6 月前3
BRPC与UCX集成指南●BRPC是Curve的基础通讯框架 ●支持远程过程调用 –C++ –TCP传输 –bthread协程(m:n调度,减少基于内核的下文切换 ,减少cache miss) ●多协议支持 –baidu_std,http,grpc… ●protobuf3 BRPC简介 ●Client/Server架构 ●使用Protobuf定义协议文件 –例如: echo.proto:4 BRPC简介 client ●读socket通过EventDispatcher触发 ●上层发送网络数据通过写socket完成,不能立刻完成的,则去启动后台bthread去完成。11 BRPC SocketMap ●根据EndPoint作为一个map的Key,Value是Socket对象 ●Socket对象引用计数,多个Channel可以共享一个Socket对象 ●往SocketMap里调用Insert,要么返回已经存在的Socket对象(引用计数加一),要么创建一 UCT ●Memory domain open/close ●Active message ●Memory get/put ●Memory atomic fetch, compare and set ●Tag match ●client/server模式的Listener, Ep(endpoint)26 UCP ●构建于uct之上,实现更加高级的功能,容易使用,但有一定开销。 ●UC0 码力 | 66 页 | 16.29 MB | 6 月前3
CurveFS S3本地缓存盘方案{ TrimStop(); } int Init(const std::string cacheDir); int Write(std::string name, const char* buf, uint64_t length); int Read(std::string name, char* buf, uint64_t offset, uint64_t length); int CreateDir(); uint64_t GetCachedSize(); std::string GetCacheDir(); std::string GetCacheReadFullDir(); std::string GetCacheWriteFullDir(); /** * @brief tell whether whether the obj is cached in local cache disk. */ bool IsCached(std::string name); void addCache(std::string name); /** * @brief tell whether the cache disk is full or not. */0 码力 | 9 页 | 150.46 KB | 6 月前3
Open Flags 调研store anything in fi->fh. There are also some flags (direct_io, keep_cache) which the filesystem may set in fi, to change the way the file is opened. See fuse_file_info structure infor more details. If this request is answered with an error code of ENOSYS and FUSE_CAP_NO_OPEN_SUPPORT is set in fuse_conn_info.capable, this is treated as success and future calls to open and release will also ,在后续读写等操作中依据该状态进行处理。 // cephfs Inode Fh.flags(cephfsFh struct Inode : RefCountedObject { ... std::set fhs; } // file handle for any open file state struct Fh { InodeRef inode; int _ref; 0 码力 | 23 页 | 524.47 KB | 6 月前3
CurveFS Copyset与FS对应关系partitions and ranges directly. Use the helper functions instead. // Partition map indexed by ID partitions map[uint64]*MetaPartition // Partition tree indexed by Start, in order to find a :: ( , , :: < > ) CopysetManager GenCopyset const ClusterInfo& cluster int numCopysets std vector Copyset * out 6.6、topology topology参考curve的topology的实现,由于curve的physical pool和logic pool在c0 码力 | 19 页 | 383.29 KB | 6 月前3
Curve文件系统空间分配方案B为例,具体大小可配置)是否分配出去。 第二层为free extent list,表示每个已分配的块,哪些仍然是空闲的(offset, length),以offset为key进行排序(这里可以用map或者btree对所有的free extent进行管理)。 当前设计不考虑持久化问题,空间分配器只作为内存结构,负责空间的分配与回收。在初始化时,扫描文件系统所有inode中已使用的空间。 空间分配流程 rightOffset = 0; }; struct Extent { uint64_t offset = 0; uint32_t len = 0; }; using Extents = std::vector; class Allocator { public: Allocator(...) {} virtual ~Allocator() = default;© 0 码力 | 11 页 | 159.17 KB | 6 月前3
Curve核心组件之mds – 网易数帆zone2 zone3 server1 server2 server3 192.168.0.1:8200 192.168.0.2:8200 192.168.0.3:8200 cluster_map: servers: - name: server1 internalip: 192.168.0.1 internalport: 8200 externalip: 192.168.0.1 externalport: Copyset的生成策略:Source code : curve/src/mds/copyset/ bool GenCopyset(const ClusterInfo& cluster, int numCopysets, std::vector* out); 例如要在(zone1 zone2 zone3 zone4)中创建8个copyset: result: cs1 [copyset-1, copyset-7] 0 码力 | 23 页 | 1.74 MB | 6 月前3
CurveFS Client 概要设计+getlk +setlk +bmap +ioctl +ioctl +poll +write_buf +retrieve_reply +forget_multi +flock +fallocate© XXX Page 5 of 11 +readdirplus +copy_file_range +lseek 关键接口分析 (fuse_req_t req, fuse_ino_t ino, struct stat *attr, int to_set, struct fuse_file_info *fi); 根据inode id 找到inode id 对应的inode 结构(从缓存或者metaserver) 根据to_set字段设置相应的attr字段,然后持久化到metaserver,并更新本地缓存。 access 可先不支持,返回ENOSYS Client的重要部分,就是上述这些cache的组织,基于以下几点考虑cache的组织方式: 1.由于cache不命中情况下,损失了cache查找这部分时间,因此,应当选用cache查找尽可能快的结构,这里考虑采用hash_map。 2. 由于fuse一次mount是一个独立的进程,因此,不需要考虑在同一个进程中支持多文件系统,每个文件系统对应独立进程。 3. cache应当有淘汰策略,元数据cache如果不淘汰,那么缓0 码力 | 11 页 | 487.92 KB | 6 月前3
共 19 条
- 1
- 2













