标签:
从inode page中申请inode entry
inode = fsp_alloc_seg_inode(space_header, mtr);
/**********************************************************************//** Allocates a new file segment inode. @return segment inode, or NULL if not enough space */ static fseg_inode_t* fsp_alloc_seg_inode( /*================*/ fsp_header_t* space_header, /*!< in: space header */ mtr_t* mtr) /*!< in: mini-transaction handle */ { ulint page_no; buf_block_t* block; page_t* page; fseg_inode_t* inode; ibool success; ulint zip_size; ulint n; ut_ad(page_offset(space_header) == FSP_HEADER_OFFSET); if (flst_get_len(space_header + FSP_SEG_INODES_FREE, mtr) == 0) { /* Allocate a new segment inode page */ success = fsp_alloc_seg_inode_page(space_header, mtr);//申请innode page,详见 if (!success) { return(NULL); } } page_no = flst_get_first(space_header + FSP_SEG_INODES_FREE, mtr).page; //详见 zip_size = dict_table_flags_to_zip_size(mach_read_from_4(FSP_SPACE_FLAGS + space_header));
/**
*page_align 详见
*page_get_space_id 详见
*buf_page_get 详见
*
*/ block = buf_page_get(page_get_space_id(page_align(space_header)),zip_size, page_no, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_FSP_PAGE); page = buf_block_get_frame(block); n = fsp_seg_inode_page_find_free(page, 0, zip_size, mtr);//详见 ut_a(n != ULINT_UNDEFINED); inode = fsp_seg_inode_page_get_nth_inode(page, n, zip_size, mtr);//得到第N个inode entry if (ULINT_UNDEFINED == fsp_seg_inode_page_find_free(page, n + 1,zip_size, mtr)) { //查看是否有空余的seg inode entry 详见 /* There are no other unused headers left on the page: move it to another list */ /**
*#define FSEG_INODE_PAGE_NODE FSEG_PAGE_DATA
*#define FSEG_PAGE_DATA FIL_PAGE_DATA
*#define FIL_PAGE_DATA 38
*/ flst_remove(space_header + FSP_SEG_INODES_FREE, page + FSEG_INODE_PAGE_NODE, mtr); flst_add_last(space_header + FSP_SEG_INODES_FULL, page + FSEG_INODE_PAGE_NODE, mtr); } ut_ad(!mach_read_from_8(inode + FSEG_ID) || mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); return(inode); }
标签:
原文地址:http://www.cnblogs.com/taek/p/4989618.html