ceph version: 11.0.0
bluestore 包含一个非常重要的结构, Blob, 本节主要分析 Blob, 注意 ceph 版本是基于 11.0.0 的。
1. Blob
struct Blob : public boost::intrusive::set_base_hook<> {
int64_t id = 0; ///< id
bluestore_blob_t blob; ///< blob metadata
BufferSpace bc; ///< buffer cache
...
}
Blob 包含三个数据:
id: id
blob: blob metadata
bc: 逻辑 extent 到 buffeffer 映射
之后是 Blob 的构造函数和析构函数等。
2. bluestore_blob_t
struct bluestore_blob_t {
...
vector<bluestore_pextent_t> extents;///< raw data position on device
uint32_t compressed_length = 0; ///< compressed length if any
uint32_t flags = 0; ///< FLAG_*
uint8_t csum_type = CSUM_NONE; ///< CSUM_*
uint8_t csum_chunk_order = 0; ///< csum block size is 1<<block_order bytes
bluestore_extent_ref_map_t ref_map; ///< references (empty when in onode)
bufferptr csum_data; ///< opaque vector of csum data
typedef uint16_t unused_uint_t;
typedef std::bitset<sizeof(unused_uint_t) * 8> unused_t;
unused_t unused; ///< portion that has never been written to
...
}
extents: 对应物理设备上的原始数据
compresed_length: 数据压缩后的长度
flags:
FLAG_MUTABLE = 1, ///< blob can be overwritten or split
FLAG_COMPRESSED = 2, ///< blob is compressed
FLAG_CSUM = 4, ///< blob has checksums
FLAG_HAS_UNUSED = 8, ///< blob has unused map
csum_type:
CSUM_NONE = 0,
CSUM_XXHASH32 = 1,
CSUM_XXHASH64 = 2,
CSUM_CRC32C = 3,
CSUM_CRC32C_16 = 4, // low 16 bits of crc32c
CSUM_CRC32C_8 = 5, // low 8 bits of crc32c
CSUM_MAX,
csum_chunk_order: csum 块大小, 1 << csum_chunk_order
ref_map: references
csum_data: check sum data
3. BufferSpace
struct BufferSpace {
...
map<uint64_t,std::unique_ptr<Buffer>> buffer_map;
Cache *cache;
state_list_t writing;
...
}