コード例 #1
0
ファイル: buf0lru.c プロジェクト: Abner-Sun/mysql5.1-vx-pre1
ibool
buf_LRU_free_block(
/*===============*/
				/* out: TRUE if freed */
	buf_block_t*	block)	/* in/out: block to be freed */
{
	if (!buf_flush_ready_for_replace(block)) {
		return(FALSE);
	}

#ifdef UNIV_DEBUG
	if (buf_debug_prints) {
		fprintf(stderr,
			"Putting space %lu page %lu"
			" to free list\n",
			(ulong) block->space,
			(ulong) block->offset);
	}
#endif /* UNIV_DEBUG */

	buf_LRU_block_remove_hashed_page(block);

	mutex_exit(&(buf_pool->mutex));
	mutex_exit(&block->mutex);

	/* Remove possible adaptive hash index built on the
	page; in the case of AWE the block may not have a
	frame at all */

	if (block->frame) {
		/* The page was declared uninitialized
		by buf_LRU_block_remove_hashed_page().
		We need to flag the contents of the
		page valid (which it still is) in
		order to avoid bogus Valgrind
		warnings. */
		UNIV_MEM_VALID(block->frame, UNIV_PAGE_SIZE);
		btr_search_drop_page_hash_index(block->frame);
		UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
	}

	ut_a(block->buf_fix_count == 0);

	mutex_enter(&(buf_pool->mutex));
	mutex_enter(&block->mutex);

	buf_LRU_block_free_hashed_page(block);

	return(TRUE);
}
コード例 #2
0
ファイル: buf0flu.c プロジェクト: zylishiyu/mysql-timeout-ms
/**********************************************************************
Gives a recommendation of how many blocks should be flushed to establish
a big enough margin of replaceable blocks near the end of the LRU list
and in the free list. */
static
ulint
buf_flush_LRU_recommendation(void)
/*==============================*/
			/* out: number of blocks which should be flushed
			from the end of the LRU list */
{
	buf_block_t*	block;
	ulint		n_replaceable;
	ulint		distance	= 0;

	mutex_enter(&(buf_pool->mutex));

	n_replaceable = UT_LIST_GET_LEN(buf_pool->free);

	block = UT_LIST_GET_LAST(buf_pool->LRU);

	while ((block != NULL)
	       && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN
		   + BUF_FLUSH_EXTRA_MARGIN)
	       && (distance < BUF_LRU_FREE_SEARCH_LEN)) {

		mutex_enter(&block->mutex);

		if (buf_flush_ready_for_replace(block)) {
			n_replaceable++;
		}

		mutex_exit(&block->mutex);

		distance++;

		block = UT_LIST_GET_PREV(LRU, block);
	}

	mutex_exit(&(buf_pool->mutex));

	if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {

		return(0);
	}

	return(BUF_FLUSH_FREE_BLOCK_MARGIN + BUF_FLUSH_EXTRA_MARGIN
	       - n_replaceable);
}