/******************************************************************//**
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));
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));
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);
}