上图中是为了表现几个数据结构之间的关系,有简化
__wt_ckpt
在src/include/meta.h文件中定义的,是元数据信息相关的结构体
源码中是这个注释的:
Encapsulation of checkpoint information, shared by the metadata, the btree engine, and the block manager.
丰封装了checkpoint信息,共享于元数据、btree引擎、和block manager
struct __wt_ckpt {
char *name; /* Name or NULL; WiredTigerCheckpoint.127594 */
WT_ITEM addr; /* Checkpoint cookie string */
WT_ITEM raw; /* Checkpoint cookie raw */
int64_t order; /* Checkpoint order */
uintmax_t sec; /* Timestamp */
uint64_t ckpt_size; /* Checkpoint size */
uint64_t write_gen; /* Write generation */
void *bpriv; /* Block manager private */
/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_CKPT_ADD 0x1u /* Checkpoint to be added */
#define WT_CKPT_DELETE 0x2u /* Checkpoint to be deleted */
#define WT_CKPT_FAKE 0x4u /* Checkpoint is a fake */
#define WT_CKPT_UPDATE 0x8u /* Checkpoint requires update */
/* AUTOMATIC FLAG VALUE GENERATION STOP */
uint32_t flags;
};
__wt_block_ckpt
在src/include/block.h文件中定义的,
源码中是这么注释的:
- Checkpoint cookie: carries a version number as I don’t want to rev the schema
- file version should the default block manager checkpoint format change.
- Version #1 checkpoint cookie format:
- [1] [root addr] [alloc addr] [avail addr] [discard addr]
- [file size] [checkpoint size] [write generation]
*/
struct __wt_block_ckpt {
uint8_t version; /* Version */
wt_off_t root_offset; /* The root */
uint32_t root_checksum, root_size;
WT_EXTLIST alloc; /* Extents allocated */
WT_EXTLIST avail; /* Extents available */
WT_EXTLIST discard; /* Extents discarded */
wt_off_t file_size; /* Checkpoint file size */
uint64_t ckpt_size; /* Checkpoint byte count */
WT_EXTLIST ckpt_avail; /* Checkpoint free'd extents */
/*
* Checkpoint archive: the block manager may potentially free a lot of
* memory from the allocation and discard extent lists when checkpoint
* completes. Put it off until the checkpoint resolves, that lets the
* upper btree layer continue eviction sooner.
*/
WT_EXTLIST ckpt_alloc; /* Checkpoint archive */
WT_EXTLIST ckpt_discard; /* Checkpoint archive */
};
__wt_block
在src/include/block.h文件中定义的,
Block manager handle, references a single file.
每一个数据文件对应一个WT_BLOCK
struct __wt_block {
const char *name; /* Name */ //文件名 数据文件的文件名, xxxx.wt
uint64_t name_hash; /* Hash of name */
/* A list of block manager handles, sharing a file descriptor. */
uint32_t ref; /* References */
TAILQ_ENTRY(__wt_block) q; /* Linked list of handles */
TAILQ_ENTRY(__wt_block) hashq; /* Hashed list of handles */
WT_FH *fh; /* Backing file handle */
wt_off_t size; /* File size */ 文件大小
wt_off_t extend_size; /* File extended size */ 当前ckpt的extend_size,也就是文件的有效大小
wt_off_t extend_len; /* File extend chunk size */
/* Configuration information, set when the file is opened. */
uint32_t allocfirst; /* Allocation is first-fit */
uint32_t allocsize; /* Allocation size */
size_t os_cache; /* System buffer cache flush max */
size_t os_cache_max;
size_t os_cache_dirty; /* System buffer cache write max */
size_t os_cache_dirty_max;
u_int block_header; /* Header length */
/*
* There is only a single checkpoint in a file that can be written. The
* information could logically live in the WT_BM structure, but then we
* would be re-creating it every time we opened a new checkpoint and I'd
* rather not do that. So, it's stored here, only accessed by one WT_BM
* handle.
*/
WT_SPINLOCK live_lock; /* Live checkpoint lock */
WT_BLOCK_CKPT live; /* Live checkpoint */ //目前正在使用的ckpt
#ifdef HAVE_DIAGNOSTIC
bool live_open; /* Live system is open */
#endif
/* Live checkpoint status */
enum {
WT_CKPT_NONE=0, WT_CKPT_INPROGRESS,
WT_CKPT_PANIC_ON_FAILURE, WT_CKPT_SALVAGE } ckpt_state; //checkpoint的状态
/* Compaction support */
int compact_pct_tenths; /* Percent to compact */
uint64_t compact_pages_reviewed;/* Pages reviewed */
uint64_t compact_pages_skipped; /* Pages skipped */
uint64_t compact_pages_written; /* Pages rewritten */
/* Salvage support */
wt_off_t slvg_off; /* Salvage file offset */
/* Verification support */
bool verify;