函数flst_get_last

flst_node_t中存有12个字节的内容,前6个字节(page:4 boffset:2)表示相对自己前一个node的fil_addr_t信息,后6个字节表示相对自己后1个node的fil_addr_t。除了flst_node_t以外,磁盘链表还有一个头信息

flst_base_node_t,头信息是一个节点个数FLST_LEN(4字节) + FLST_FIRST (6字节)+ FLST_LAST(6字节)

/********************************************************************//**
Gets list last node address.
@return    file address */
UNIV_INLINE
fil_addr_t
flst_get_last(
/*==========*/
    const flst_base_node_t*    base,    /*!< in: pointer to base node */
    mtr_t*            mtr)    /*!< in: mini-transaction handle */
{
    return(flst_read_addr(base + FLST_LAST, mtr));
}

/********************************************************************//**
Reads a file address.
@return    file address */
UNIV_INLINE
fil_addr_t
flst_read_addr(
/*===========*/
    const fil_faddr_t*    faddr,    /*!< in: pointer to file faddress */
    mtr_t*            mtr)    /*!< in: mini-transaction handle */
{
    fil_addr_t    addr;

    ut_ad(faddr && mtr);

    addr.page = mtr_read_ulint(faddr + FIL_ADDR_PAGE, MLOG_4BYTES, mtr);
    addr.boffset = mtr_read_ulint(faddr + FIL_ADDR_BYTE, MLOG_2BYTES,
                      mtr);
    ut_a(addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA);
    ut_a(ut_align_offset(faddr, UNIV_PAGE_SIZE) >= FIL_PAGE_DATA);
    return(addr);
}

#define FIL_ADDR_PAGE 0 /* first in address is the page offset */
#define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/

 
上一篇:蓝牙BLE: ATT协议层中属性(Attribute)


下一篇:测试文章111