Motr
M0
|
Catalogue service exports BE btrees (be/btree.[ch]) to the network.
Some of definitions are copied from HLD (see References).
Additional requirements that are not covered in HLD (see References)
* +----------------------------+ * | | * V !cas_op_checked | * FOPH_INIT---------------+ | * | | | * | V | * | CAS_CHECK_PRE | * | | | * | V | * | CAS_CHECK----+ * | | * | | cas_op_check() failed * V | * [generic phases] FAILURE * . * . meta_op * . +---------------------+ * V | | * TXN_INIT-------------->CAS_START<-------+ | * | | | * V | | * TXN_OPEN<-----+ CAS_META_LOCK | | * | | | | | * | | V | | * [generic phases] | CAS_META_LOOKUP | | * . | | | | * . | V | | * !meta_op . | CAS_META_LOOKUP_DONE | | * +---------CAS_TXN_OPENED | | | | * | | | | | | * V | | | | | * CAS_META_UNLOCK------->| | | | | * | | | ctg_crow | | * | | +----------+ | | * +----------------------->| | | | | | * | | | | V | | * | +-CAS_DTM0<-+ | | | CAS_CTG_CROW_DONE | * | | | | | | | * | | |dtm0 | | | | * | V | | | | | * | SUCCESS<-------+-CAS_LOOP<----+ | | | * | | | | V | * | index drop | | | +->CAS_LOAD_KEY<--------------+ * | +---------------+ | | | | * | | | | | | V * | V | | | | CAS_LOAD_VAL * | CAS_INSERT_TO_DEAD | | | | | * | | | | | | V * | V | | | +--CAS_LOAD_DONE * | CAS_DELETE_FROM_META->| | | | * | | | | | * | ctidx_op_needed | | | | * | +-----------------+ | | | * | | | | | | * | V | | | | * | CAS_CTIDX------------>| | | | index drop * | | | | +-------------+ * | index drop | | | | | * | +----------------+ | | | V * | | | | | |<---CAS_DEAD_INDEX_LOCK * | V | | | | * +--CAS_IDROP_LOOP | | | | * | | | | | * V | | | | * CAS_IDROP_LOCK_LOOP | | | | * | | | | | | * | V | | | | * | CAS_IDROP_LOCKED-->| | | | * | | | | | * V | | | | * CAS_IDROP_START_GC | | | | * | V | | | * V CAS_PREPARE_SEND | | | * SUCCESS | | | | * |next_key| | | * +------->| | | * | | | CAS_LOCK------------+ * V | | | | * CAS_SEND_KEY | | |meta_op | * | | | | | * V | | V | * CAS_SEND_VAL | | CAS_CTIDX_LOCK | * | | | | | * V | | V | * CAS_DONE----+ +--------CAS_PREP<-----------+ * *
Catalogues (including meta catalogue) are protected with "multiple readers/single writer" lock (see m0_cas_ctg::cc_lock). Writer starvation is not possible due to FOM long lock design, because writer has priority over readers.
B-tree structure has internal rwlock (m0_be_btree::bb_lock), but it's not convenient for usage inside FOM since it blocks the execution thread. Also, index should be locked before FOM BE TX credit calculation, because amount of credits depends on the height of BE tree. Index is unlocked when all necessary B-tree operations are done.
Memory for all indices (including meta-index) is allocated in the first segment (m0_be_domain_seg_first()) of Motr global BE domain (m0::i_be_dom). Address of a meta-index is stored in this segment dictionary. Meta-index btree stores information about existing indices (including itself) as key-value pairs, where key is a FID of an index and value is a pointer to it.