从innodb buffer pool的freelist中获得空块buf_LRU_get_free_only

720阅读 0评论2013-02-25 gladness
分类:Mysql/postgreSQL

/******************************************************************//**

Returns a free block from the buf_pool.  The block is taken off the

free list.  If it is empty, returns NULL.

@return  a free control block, or NULL if the buf_block->free list is empty */

UNIV_INTERN

buf_block_t*

buf_LRU_get_free_only(

/*==================*/

     buf_pool_t*   buf_pool)

{

     buf_block_t*  block;

 

     ut_ad(buf_pool_mutex_own(buf_pool));

     /* 取list中的第一个节点 */

     block = (buf_block_t*) UT_LIST_GET_FIRST(buf_pool->free);

 

     if (block) {

 

         ut_ad(block->page.in_free_list);

         ut_d(block->page.in_free_list = FALSE);

         ut_ad(!block->page.in_flush_list);

         ut_ad(!block->page.in_LRU_list);

         ut_a(!buf_page_in_file(&block->page));

        /*从list中删除取得的节点,即此块已经被占用,不在freelist中了*/

         UT_LIST_REMOVE(list, buf_pool->free, (&block->page));

 

         mutex_enter(&block->mutex);

 

         buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);

         UNIV_MEM_ALLOC(block->frame, UNIV_PAGE_SIZE);

 

         ut_ad(buf_pool_from_block(block) == buf_pool);

 

         mutex_exit(&block->mutex);

     }

 

     return(block);

}


上一篇:innodb读取innodb buffer page的函数buf_page_get_gen
下一篇:打开表时load table中的btr_pcur_open_on_user_rec_func调用