2009-02-17 07:56:33 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
|
|
|
Copyright (c) 2008, Google Inc.
|
|
|
|
|
|
|
|
Portions of this file contain modifications contributed and copyrighted by
|
|
|
|
Google, Inc. Those modifications are gratefully acknowledged and are described
|
|
|
|
briefly in the InnoDB documentation. The contributions by Google are
|
|
|
|
incorporated with their permission, and subject to the conditions contained in
|
|
|
|
the file COPYING.Google.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************//**
|
|
|
|
@file include/buf0buf.ic
|
2005-10-27 07:29:40 +00:00
|
|
|
The database buffer buf_pool
|
|
|
|
|
|
|
|
Created 11/5/1995 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#include "mtr0mtr.h"
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
2005-10-27 07:29:40 +00:00
|
|
|
#include "buf0flu.h"
|
|
|
|
#include "buf0lru.h"
|
|
|
|
#include "buf0rea.h"
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the freed_page_clock of a buffer block.
|
|
|
|
@return freed_page_clock */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_freed_page_clock(
|
|
|
|
/*==========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
2009-01-12 16:56:11 +00:00
|
|
|
/* This is sometimes read without holding buf_pool_mutex. */
|
2006-11-30 12:27:49 +00:00
|
|
|
return(bpage->freed_page_clock);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the freed_page_clock of a buffer block.
|
|
|
|
@return freed_page_clock */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_freed_page_clock(
|
|
|
|
/*===========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
return(buf_page_get_freed_page_clock(&block->page));
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Recommends a move of a block to the start of the LRU list if there is danger
|
|
|
|
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
|
2009-05-25 05:30:14 +00:00
|
|
|
mutex.
|
|
|
|
@return TRUE if should be made younger */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
2007-08-01 11:18:43 +00:00
|
|
|
buf_page_peek_if_too_old(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: block to make younger */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2009-09-10 09:47:09 +00:00
|
|
|
if (UNIV_UNLIKELY(buf_pool->freed_page_clock == 0)) {
|
|
|
|
/* If eviction has not started yet, do not update the
|
|
|
|
statistics or move blocks in the LRU list. This is
|
|
|
|
either the warm-up phase or an in-memory workload. */
|
|
|
|
return(FALSE);
|
|
|
|
} else if (buf_LRU_old_threshold_ms && bpage->old) {
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
unsigned access_time = buf_page_is_accessed(bpage);
|
|
|
|
|
2009-09-10 09:47:09 +00:00
|
|
|
if (access_time > 0
|
|
|
|
&& (ut_time_ms() - access_time)
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
>= buf_LRU_old_threshold_ms) {
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2009-08-27 15:00:27 +00:00
|
|
|
buf_pool->stat.n_pages_not_made_young++;
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
return(FALSE);
|
|
|
|
} else {
|
|
|
|
/* FIXME: bpage->freed_page_clock is 31 bits */
|
2009-09-09 06:00:59 +00:00
|
|
|
return((buf_pool->freed_page_clock & ((1UL << 31) - 1))
|
2009-09-10 09:47:09 +00:00
|
|
|
> ((ulint) bpage->freed_page_clock
|
|
|
|
+ (buf_pool->curr_size
|
|
|
|
* (BUF_LRU_OLD_RATIO_DIV - buf_LRU_old_ratio)
|
|
|
|
/ (BUF_LRU_OLD_RATIO_DIV * 4))));
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the current size of buffer buf_pool in bytes.
|
|
|
|
@return size in bytes */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_pool_get_curr_size(void)
|
|
|
|
/*========================*/
|
|
|
|
{
|
2006-10-30 15:15:19 +00:00
|
|
|
return(buf_pool->curr_size * UNIV_PAGE_SIZE);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets the smallest oldest_modification lsn for any page in the pool. Returns
|
2009-05-25 05:30:14 +00:00
|
|
|
zero if all modified pages have been flushed to disk.
|
|
|
|
@return oldest modification in pool, zero if none */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_pool_get_oldest_modification(void)
|
|
|
|
/*==================================*/
|
|
|
|
{
|
2006-11-27 14:12:09 +00:00
|
|
|
buf_page_t* bpage;
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t lsn;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_enter();
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-11-27 14:12:09 +00:00
|
|
|
bpage = UT_LIST_GET_LAST(buf_pool->flush_list);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-11-27 14:12:09 +00:00
|
|
|
if (bpage == NULL) {
|
2006-11-24 13:05:01 +00:00
|
|
|
lsn = 0;
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2007-01-09 12:35:42 +00:00
|
|
|
ut_ad(bpage->in_flush_list);
|
2006-11-27 14:12:09 +00:00
|
|
|
lsn = bpage->oldest_modification;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_exit();
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-01-12 16:56:11 +00:00
|
|
|
/* The returned answer may be out of date: the flush_list can
|
|
|
|
change after the mutex has been released. */
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(lsn);
|
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the state of a block.
|
|
|
|
@return state */
|
2006-11-23 13:26:01 +00:00
|
|
|
UNIV_INLINE
|
2006-11-24 08:32:18 +00:00
|
|
|
enum buf_page_state
|
2006-11-27 14:12:09 +00:00
|
|
|
buf_page_get_state(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2006-11-23 13:26:01 +00:00
|
|
|
{
|
2007-08-01 10:38:07 +00:00
|
|
|
enum buf_page_state state = (enum buf_page_state) bpage->state;
|
2006-11-23 13:26:01 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
switch (state) {
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_FREE:
|
2006-11-24 08:32:18 +00:00
|
|
|
case BUF_BLOCK_ZIP_PAGE:
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_DIRTY:
|
2006-11-23 13:26:01 +00:00
|
|
|
case BUF_BLOCK_NOT_USED:
|
|
|
|
case BUF_BLOCK_READY_FOR_USE:
|
|
|
|
case BUF_BLOCK_FILE_PAGE:
|
|
|
|
case BUF_BLOCK_MEMORY:
|
|
|
|
case BUF_BLOCK_REMOVE_HASH:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ut_error;
|
|
|
|
}
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
|
|
|
|
return(state);
|
|
|
|
}
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the state of a block.
|
|
|
|
@return state */
|
2006-11-27 14:12:09 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_page_state
|
|
|
|
buf_block_get_state(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2006-11-27 14:12:09 +00:00
|
|
|
{
|
|
|
|
return(buf_page_get_state(&block->page));
|
|
|
|
}
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-23 14:12:58 +00:00
|
|
|
Sets the state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-11-30 12:27:49 +00:00
|
|
|
buf_page_set_state(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: pointer to control block */
|
|
|
|
enum buf_page_state state) /*!< in: state */
|
2006-11-23 14:12:58 +00:00
|
|
|
{
|
|
|
|
#ifdef UNIV_DEBUG
|
2006-11-30 12:27:49 +00:00
|
|
|
enum buf_page_state old_state = buf_page_get_state(bpage);
|
2006-11-23 14:12:58 +00:00
|
|
|
|
|
|
|
switch (old_state) {
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_FREE:
|
2006-12-15 14:47:04 +00:00
|
|
|
ut_error;
|
|
|
|
break;
|
2006-11-24 08:32:18 +00:00
|
|
|
case BUF_BLOCK_ZIP_PAGE:
|
2006-12-15 14:47:04 +00:00
|
|
|
ut_a(state == BUF_BLOCK_ZIP_DIRTY);
|
|
|
|
break;
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_DIRTY:
|
2006-12-15 14:47:04 +00:00
|
|
|
ut_a(state == BUF_BLOCK_ZIP_PAGE);
|
2006-11-24 08:32:18 +00:00
|
|
|
break;
|
2006-11-23 14:12:58 +00:00
|
|
|
case BUF_BLOCK_NOT_USED:
|
|
|
|
ut_a(state == BUF_BLOCK_READY_FOR_USE);
|
|
|
|
break;
|
|
|
|
case BUF_BLOCK_READY_FOR_USE:
|
|
|
|
ut_a(state == BUF_BLOCK_MEMORY
|
2006-11-23 15:12:53 +00:00
|
|
|
|| state == BUF_BLOCK_FILE_PAGE
|
|
|
|
|| state == BUF_BLOCK_NOT_USED);
|
2006-11-23 14:12:58 +00:00
|
|
|
break;
|
|
|
|
case BUF_BLOCK_MEMORY:
|
|
|
|
ut_a(state == BUF_BLOCK_NOT_USED);
|
|
|
|
break;
|
|
|
|
case BUF_BLOCK_FILE_PAGE:
|
|
|
|
ut_a(state == BUF_BLOCK_NOT_USED
|
2006-11-23 15:12:53 +00:00
|
|
|
|| state == BUF_BLOCK_REMOVE_HASH);
|
2006-11-23 14:12:58 +00:00
|
|
|
break;
|
|
|
|
case BUF_BLOCK_REMOVE_HASH:
|
|
|
|
ut_a(state == BUF_BLOCK_MEMORY);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /* UNIV_DEBUG */
|
2006-11-30 12:27:49 +00:00
|
|
|
bpage->state = state;
|
|
|
|
ut_ad(buf_page_get_state(bpage) == state);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Sets the state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_state(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: pointer to control block */
|
|
|
|
enum buf_page_state state) /*!< in: state */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
buf_page_set_state(&block->page, state);
|
2006-11-23 14:12:58 +00:00
|
|
|
}
|
2006-11-27 14:12:09 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Determines if a block is mapped to a tablespace.
|
|
|
|
@return TRUE if mapped */
|
2006-11-29 13:23:28 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_in_file(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
2006-11-29 13:23:28 +00:00
|
|
|
{
|
|
|
|
switch (buf_page_get_state(bpage)) {
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_FREE:
|
|
|
|
/* This is a free page in buf_pool->zip_free[].
|
|
|
|
Such pages should only be accessed by the buddy allocator. */
|
|
|
|
ut_error;
|
|
|
|
break;
|
2006-11-29 13:23:28 +00:00
|
|
|
case BUF_BLOCK_ZIP_PAGE:
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_DIRTY:
|
2006-11-29 13:23:28 +00:00
|
|
|
case BUF_BLOCK_FILE_PAGE:
|
|
|
|
return(TRUE);
|
|
|
|
case BUF_BLOCK_NOT_USED:
|
|
|
|
case BUF_BLOCK_READY_FOR_USE:
|
|
|
|
case BUF_BLOCK_MEMORY:
|
|
|
|
case BUF_BLOCK_REMOVE_HASH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Determines if a block should be on unzip_LRU list.
|
|
|
|
@return TRUE if block belongs to unzip_LRU */
|
2008-03-03 12:48:38 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_belongs_to_unzip_LRU(
|
|
|
|
/*==========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
2008-03-03 12:48:38 +00:00
|
|
|
{
|
|
|
|
ut_ad(buf_page_in_file(bpage));
|
|
|
|
|
|
|
|
return(bpage->zip.data
|
|
|
|
&& buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the mutex of a block.
|
|
|
|
@return pointer to mutex protecting bpage */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
mutex_t*
|
|
|
|
buf_page_get_mutex(
|
2006-12-05 12:10:30 +00:00
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
switch (buf_page_get_state(bpage)) {
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_FREE:
|
|
|
|
ut_error;
|
branches/zip: Fix most MSVC (Windows) compilation warnings.
lock_get_table(), locks_row_eq_lock(), buf_page_get_mutex(): Add return
after ut_error. On Windows, ut_error is not declared as "noreturn".
Add explicit type casts when assigning ulint to byte to get rid of
"possible loss of precision" warnings.
struct i_s_table_cache_struct: Declare rows_used, rows_allocd as ulint
instead of ullint. 32 bits should be enough.
fill_innodb_trx_from_cache(), i_s_zip_fill_low(): Cast 64-bit unsigned
integers to longlong when calling Field::store(longlong, bool is_unsigned).
Otherwise, the compiler would implicitly convert them to double and
invoke Field::store(double) instead.
recv_truncate_group(), recv_copy_group(), recv_calc_lsn_on_data_add():
Cast ib_uint64_t expressions to ulint to get rid of "possible loss of
precision" warnings. (There should not be any loss of precision in
these cases.)
log_close(), log_checkpoint_margin(): Declare some variables as ib_uint64_t
instead of ulint, so that there won't be any potential loss of precision.
mach_write_ull(): Cast the second argument of mach_write_to_4() to ulint.
OS_FILE_FROM_FD(): Cast the return value of _get_osfhandle() to HANDLE.
row_merge_dict_table_get_index(): Cast the parameter of mem_free() to (void*)
in order to get rid of the bogus MSVC warning C4090, which has been reported
as MSVC bug 101661:
<http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101661>
row_mysql_read_blob_ref(): To get rid of a bogus MSVC warning C4090,
drop a const qualifier.
2008-03-04 08:57:07 +00:00
|
|
|
return(NULL);
|
2006-11-30 12:27:49 +00:00
|
|
|
case BUF_BLOCK_ZIP_PAGE:
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_DIRTY:
|
2008-01-10 09:37:13 +00:00
|
|
|
return(&buf_pool_zip_mutex);
|
2006-11-30 12:27:49 +00:00
|
|
|
default:
|
|
|
|
return(&((buf_block_t*) bpage)->mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Get the flush type of a page.
|
|
|
|
@return flush type */
|
2006-11-27 14:12:09 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_flush
|
|
|
|
buf_page_get_flush_type(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: buffer page */
|
2006-11-27 14:12:09 +00:00
|
|
|
{
|
2007-08-01 10:38:07 +00:00
|
|
|
enum buf_flush flush_type = (enum buf_flush) bpage->flush_type;
|
2006-11-27 14:12:09 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
switch (flush_type) {
|
|
|
|
case BUF_FLUSH_LRU:
|
|
|
|
case BUF_FLUSH_SINGLE_PAGE:
|
|
|
|
case BUF_FLUSH_LIST:
|
|
|
|
return(flush_type);
|
|
|
|
case BUF_FLUSH_N_TYPES:
|
2006-11-28 11:08:33 +00:00
|
|
|
break;
|
2006-11-27 14:12:09 +00:00
|
|
|
}
|
|
|
|
ut_error;
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
return(flush_type);
|
|
|
|
}
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-27 14:12:09 +00:00
|
|
|
Set the flush type of a page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_flush_type(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in: buffer page */
|
|
|
|
enum buf_flush flush_type) /*!< in: flush type */
|
2006-11-27 14:12:09 +00:00
|
|
|
{
|
2006-11-30 10:33:35 +00:00
|
|
|
bpage->flush_type = flush_type;
|
2006-11-27 14:12:09 +00:00
|
|
|
ut_ad(buf_page_get_flush_type(bpage) == flush_type);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-23 14:12:58 +00:00
|
|
|
Map a block to a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_file_page(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: pointer to control block */
|
|
|
|
ulint space, /*!< in: tablespace id */
|
|
|
|
ulint page_no)/*!< in: page number */
|
2006-11-23 14:12:58 +00:00
|
|
|
{
|
|
|
|
buf_block_set_state(block, BUF_BLOCK_FILE_PAGE);
|
2006-11-24 08:32:18 +00:00
|
|
|
block->page.space = space;
|
|
|
|
block->page.offset = page_no;
|
2006-11-23 14:12:58 +00:00
|
|
|
}
|
2006-11-23 13:26:01 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the io_fix state of a block.
|
|
|
|
@return io_fix state */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_io_fix
|
|
|
|
buf_page_get_io_fix(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
2007-08-01 10:38:07 +00:00
|
|
|
enum buf_io_fix io_fix = (enum buf_io_fix) bpage->io_fix;
|
2006-11-30 12:27:49 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
switch (io_fix) {
|
|
|
|
case BUF_IO_NONE:
|
|
|
|
case BUF_IO_READ:
|
|
|
|
case BUF_IO_WRITE:
|
|
|
|
return(io_fix);
|
|
|
|
}
|
|
|
|
ut_error;
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
return(io_fix);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the io_fix state of a block.
|
|
|
|
@return io_fix state */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_io_fix
|
|
|
|
buf_block_get_io_fix(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
return(buf_page_get_io_fix(&block->page));
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Sets the io_fix state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_io_fix(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
enum buf_io_fix io_fix) /*!< in: io_fix state */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
2008-01-10 09:37:13 +00:00
|
|
|
ut_ad(buf_pool_mutex_own());
|
2007-01-18 18:29:12 +00:00
|
|
|
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
|
|
|
|
|
2006-11-30 12:27:49 +00:00
|
|
|
bpage->io_fix = io_fix;
|
|
|
|
ut_ad(buf_page_get_io_fix(bpage) == io_fix);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Sets the io_fix state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_io_fix(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: control block */
|
|
|
|
enum buf_io_fix io_fix) /*!< in: io_fix state */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
buf_page_set_io_fix(&block->page, io_fix);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2007-01-04 21:40:10 +00:00
|
|
|
Determine if a buffer block can be relocated in memory. The block
|
|
|
|
can be dirty, but it must not be I/O-fixed or bufferfixed. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_can_relocate(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< control block being relocated */
|
2007-01-04 21:40:10 +00:00
|
|
|
{
|
2008-01-10 09:37:13 +00:00
|
|
|
ut_ad(buf_pool_mutex_own());
|
branches/zip: Remove const warnings reported by GCC 4.2.1.
page_cur_set_before_first(), page_cur_set_after_last(),
page_cur_position(): Add const qualifiers to buf_block_t and rec.
A better solution would be to define a const_page_cur_t and a
set of accessors, but it would lead to severe code duplication.
page_rec_get_n_recs_before(): Add const qualifiers.
page_dir_get_nth_slot(): Define as a const-preserving macro.
page_dir_slot_get_rec(), page_dir_slot_get_n_owned(),
page_dir_find_owner_slot(), page_check_dir(): Add const qualifiers.
page_rec_get_next_low(): Add const qualifiers.
page_rec_get_next_const(), page_rec_get_prev_const(): New functions,
based on the const-less page_rec_get_next() and page_rec_get_prev().
page_cur_get_page(), page_cur_get_block(), page_cur_get_page_zip(),
page_cur_get_rec(): Define as const-preserving macros.
page_cur_try_search_shortcut(), page_cur_search_with_match():
Add const qualifiers.
buf_page_get_mutex(): Add a const qualifier to buf_page_t*.
rec_get_next_ptr_const(): Const variant of rec_get_next_ptr().
2007-10-18 07:12:05 +00:00
|
|
|
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
|
2007-01-04 21:40:10 +00:00
|
|
|
ut_ad(buf_page_in_file(bpage));
|
|
|
|
ut_ad(bpage->in_LRU_list);
|
|
|
|
|
|
|
|
return(buf_page_get_io_fix(bpage) == BUF_IO_NONE
|
|
|
|
&& bpage->buf_fix_count == 0);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Determine if a block has been flagged old.
|
|
|
|
@return TRUE if old */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_is_old(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
ut_ad(buf_page_in_file(bpage));
|
2009-01-12 16:56:11 +00:00
|
|
|
ut_ad(buf_pool_mutex_own());
|
2006-11-30 12:27:49 +00:00
|
|
|
|
|
|
|
return(bpage->old);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Flag a block old. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_old(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
ibool old) /*!< in: old */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
ut_a(buf_page_in_file(bpage));
|
2008-01-10 09:37:13 +00:00
|
|
|
ut_ad(buf_pool_mutex_own());
|
2008-08-18 18:06:33 +00:00
|
|
|
ut_ad(bpage->in_LRU_list);
|
2006-11-30 12:27:49 +00:00
|
|
|
|
2008-08-18 18:28:20 +00:00
|
|
|
#ifdef UNIV_LRU_DEBUG
|
2009-10-29 11:04:11 +00:00
|
|
|
ut_a((buf_pool->LRU_old_len == 0) == (buf_pool->LRU_old == NULL));
|
|
|
|
/* If a block is flagged "old", the LRU_old list must exist. */
|
|
|
|
ut_a(!old || buf_pool->LRU_old);
|
|
|
|
|
2009-10-28 14:10:34 +00:00
|
|
|
if (UT_LIST_GET_PREV(LRU, bpage) && UT_LIST_GET_NEXT(LRU, bpage)) {
|
|
|
|
const buf_page_t* prev = UT_LIST_GET_PREV(LRU, bpage);
|
|
|
|
const buf_page_t* next = UT_LIST_GET_NEXT(LRU, bpage);
|
|
|
|
if (prev->old == next->old) {
|
|
|
|
ut_a(prev->old == old);
|
|
|
|
} else {
|
|
|
|
ut_a(!prev->old);
|
2009-10-29 11:04:11 +00:00
|
|
|
ut_a(buf_pool->LRU_old == (old ? bpage : next));
|
2009-10-28 14:10:34 +00:00
|
|
|
}
|
2008-08-18 18:28:20 +00:00
|
|
|
}
|
|
|
|
#endif /* UNIV_LRU_DEBUG */
|
|
|
|
|
2006-11-30 12:27:49 +00:00
|
|
|
bpage->old = old;
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-09-09 06:25:00 +00:00
|
|
|
Determine the time of first access of a block in the buffer pool.
|
|
|
|
@return ut_time_ms() at the time of first access, 0 if not accessed */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
unsigned
|
2006-11-30 12:27:49 +00:00
|
|
|
buf_page_is_accessed(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
ut_ad(buf_page_in_file(bpage));
|
|
|
|
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
return(bpage->access_time);
|
2006-11-30 12:27:49 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Flag a block accessed. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_accessed(
|
|
|
|
/*==================*/
|
2009-09-10 09:47:09 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
ulint time_ms) /*!< in: ut_time_ms() */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
ut_a(buf_page_in_file(bpage));
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
ut_ad(buf_pool_mutex_own());
|
2006-11-30 12:27:49 +00:00
|
|
|
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
if (!bpage->access_time) {
|
|
|
|
/* Make this the time of the first access. */
|
2009-09-10 09:47:09 +00:00
|
|
|
bpage->access_time = time_ms;
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
}
|
2006-11-30 12:27:49 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2007-09-28 12:04:04 +00:00
|
|
|
Gets the buf_block_t handle of a buffered file block if an uncompressed
|
2009-05-25 05:30:14 +00:00
|
|
|
page frame exists, or NULL.
|
|
|
|
@return control block, or NULL */
|
2007-09-28 12:04:04 +00:00
|
|
|
UNIV_INLINE
|
2007-10-01 07:32:45 +00:00
|
|
|
buf_block_t*
|
2007-09-28 12:04:04 +00:00
|
|
|
buf_page_get_block(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage) /*!< in: control block, or NULL */
|
2007-09-28 12:04:04 +00:00
|
|
|
{
|
2007-10-01 07:32:45 +00:00
|
|
|
if (UNIV_LIKELY(bpage != NULL)) {
|
|
|
|
ut_ad(buf_page_in_file(bpage));
|
2007-09-28 12:04:04 +00:00
|
|
|
|
2007-10-01 07:32:45 +00:00
|
|
|
if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
|
|
|
|
return((buf_block_t*) bpage);
|
|
|
|
}
|
2007-09-28 12:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(NULL);
|
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2007-09-28 12:04:04 +00:00
|
|
|
|
2007-09-28 06:26:21 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets a pointer to the memory frame of a block.
|
|
|
|
@return pointer to the frame */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
buf_frame_t*
|
|
|
|
buf_block_get_frame(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(block);
|
2007-09-28 06:26:21 +00:00
|
|
|
|
2006-11-30 15:09:33 +00:00
|
|
|
switch (buf_block_get_state(block)) {
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_FREE:
|
2006-11-30 15:09:33 +00:00
|
|
|
case BUF_BLOCK_ZIP_PAGE:
|
2006-12-05 12:10:30 +00:00
|
|
|
case BUF_BLOCK_ZIP_DIRTY:
|
|
|
|
case BUF_BLOCK_NOT_USED:
|
2006-11-30 15:09:33 +00:00
|
|
|
ut_error;
|
|
|
|
break;
|
|
|
|
case BUF_BLOCK_FILE_PAGE:
|
2009-03-23 14:21:34 +00:00
|
|
|
# ifndef UNIV_HOTBACKUP
|
2006-11-30 15:09:33 +00:00
|
|
|
ut_a(block->page.buf_fix_count > 0);
|
2009-03-23 14:21:34 +00:00
|
|
|
# endif /* !UNIV_HOTBACKUP */
|
2006-11-30 15:09:33 +00:00
|
|
|
/* fall through */
|
|
|
|
case BUF_BLOCK_READY_FOR_USE:
|
|
|
|
case BUF_BLOCK_MEMORY:
|
|
|
|
case BUF_BLOCK_REMOVE_HASH:
|
|
|
|
goto ok;
|
|
|
|
}
|
|
|
|
ut_error;
|
|
|
|
ok:
|
2007-09-28 06:26:21 +00:00
|
|
|
return((buf_frame_t*) block->frame);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2007-09-28 06:26:21 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the space id of a block.
|
|
|
|
@return space id */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_space(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
ut_ad(bpage);
|
|
|
|
ut_a(buf_page_in_file(bpage));
|
|
|
|
|
|
|
|
return(bpage->space);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the space id of a block.
|
|
|
|
@return space id */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_space(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(block);
|
2006-11-23 14:12:58 +00:00
|
|
|
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-11-24 08:32:18 +00:00
|
|
|
return(block->page.space);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the page number of a block.
|
|
|
|
@return page number */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_page_no(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
ut_ad(bpage);
|
|
|
|
ut_a(buf_page_in_file(bpage));
|
|
|
|
|
|
|
|
return(bpage->offset);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the page number of a block.
|
|
|
|
@return page number */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_page_no(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(block);
|
2006-11-23 14:12:58 +00:00
|
|
|
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-11-24 08:32:18 +00:00
|
|
|
return(block->page.offset);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the compressed page size of a block.
|
|
|
|
@return compressed page size, or 0 */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_zip_size(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
{
|
|
|
|
return(bpage->zip.ssize ? 512 << bpage->zip.ssize : 0);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the compressed page size of a block.
|
|
|
|
@return compressed page size, or 0 */
|
2006-10-12 11:05:22 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_zip_size(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2006-10-12 11:05:22 +00:00
|
|
|
{
|
2006-11-27 13:44:32 +00:00
|
|
|
return(block->page.zip.ssize ? 512 << block->page.zip.ssize : 0);
|
2006-10-12 11:05:22 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2006-11-02 09:06:49 +00:00
|
|
|
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-10-12 11:05:22 +00:00
|
|
|
Gets the compressed page descriptor corresponding to an uncompressed page
|
2009-05-25 05:30:14 +00:00
|
|
|
if applicable.
|
|
|
|
@return compressed page descriptor, or NULL */
|
2006-10-12 11:05:22 +00:00
|
|
|
UNIV_INLINE
|
2007-10-03 12:22:29 +00:00
|
|
|
const page_zip_des_t*
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_frame_get_page_zip(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const byte* ptr) /*!< in: pointer to the page */
|
2006-10-12 11:05:22 +00:00
|
|
|
{
|
2009-01-26 20:33:20 +00:00
|
|
|
return(buf_block_get_page_zip(buf_block_align(ptr)));
|
2006-10-12 11:05:22 +00:00
|
|
|
}
|
2006-10-18 11:39:31 +00:00
|
|
|
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2006-10-12 11:05:22 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets the space id, page offset, and byte offset within page of a
|
|
|
|
pointer pointing to a buffer frame containing a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_ptr_get_fsp_addr(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const void* ptr, /*!< in: pointer to a buffer frame */
|
|
|
|
ulint* space, /*!< out: space id */
|
|
|
|
fil_addr_t* addr) /*!< out: page offset and byte offset */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2007-10-03 12:22:29 +00:00
|
|
|
const page_t* page = (const page_t*) ut_align_down(ptr,
|
2007-08-01 10:38:07 +00:00
|
|
|
UNIV_PAGE_SIZE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-13 13:03:06 +00:00
|
|
|
*space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
|
|
|
|
addr->page = mach_read_from_4(page + FIL_PAGE_OFFSET);
|
2006-10-09 16:22:47 +00:00
|
|
|
addr->boffset = ut_align_offset(ptr, UNIV_PAGE_SIZE);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets the hash value of the page the pointer is pointing to. This can be used
|
2009-05-25 05:30:14 +00:00
|
|
|
in searches in the lock hash table.
|
|
|
|
@return lock hash value */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
2006-10-13 11:55:27 +00:00
|
|
|
buf_block_get_lock_hash_val(
|
2005-10-27 07:29:40 +00:00
|
|
|
/*========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: block */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
return(block->lock_hash_val);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Allocates a buffer block.
|
|
|
|
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
|
2006-08-17 11:57:51 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
buf_block_t*
|
|
|
|
buf_block_alloc(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size) /*!< in: compressed page size in bytes,
|
2006-08-17 11:57:51 +00:00
|
|
|
or 0 if uncompressed tablespace */
|
|
|
|
{
|
|
|
|
buf_block_t* block;
|
|
|
|
|
|
|
|
block = buf_LRU_get_free_block(zip_size);
|
|
|
|
|
2006-12-13 14:58:54 +00:00
|
|
|
buf_block_set_state(block, BUF_BLOCK_MEMORY);
|
|
|
|
|
2006-08-17 11:57:51 +00:00
|
|
|
return(block);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2006-08-17 11:57:51 +00:00
|
|
|
Frees a buffer block which does not contain a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_free(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block) /*!< in, own: block to be freed */
|
2006-08-17 11:57:51 +00:00
|
|
|
{
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_enter();
|
2006-08-17 11:57:51 +00:00
|
|
|
|
2006-11-10 11:15:59 +00:00
|
|
|
mutex_enter(&block->mutex);
|
|
|
|
|
2006-11-23 13:26:01 +00:00
|
|
|
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
|
2006-11-10 11:15:59 +00:00
|
|
|
|
2006-08-17 11:57:51 +00:00
|
|
|
buf_LRU_block_free_non_file_page(block);
|
|
|
|
|
2006-11-10 11:15:59 +00:00
|
|
|
mutex_exit(&block->mutex);
|
|
|
|
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_exit();
|
2006-08-17 11:57:51 +00:00
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2006-08-17 11:57:51 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Copies contents of a buffer frame to a given buffer.
|
|
|
|
@return buf */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
byte*
|
|
|
|
buf_frame_copy(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
byte* buf, /*!< in: buffer to copy to */
|
|
|
|
const buf_frame_t* frame) /*!< in: buffer frame */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(buf && frame);
|
|
|
|
|
|
|
|
ut_memcpy(buf, frame, UNIV_PAGE_SIZE);
|
|
|
|
|
|
|
|
return(buf);
|
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Calculates a folded value of a file page address to use in the page hash
|
2009-05-25 05:30:14 +00:00
|
|
|
table.
|
|
|
|
@return the folded value */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_address_fold(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset) /*!< in: offset of the page within space */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
return((space << 20) + space + offset);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2006-11-24 13:05:01 +00:00
|
|
|
Gets the youngest modification log sequence number for a frame.
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns zero if not file page or no modification occurred yet.
|
|
|
|
@return newest modification to page */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t
|
2006-11-30 15:09:33 +00:00
|
|
|
buf_page_get_newest_modification(
|
|
|
|
/*=============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: block containing the
|
2006-11-30 15:09:33 +00:00
|
|
|
page frame */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t lsn;
|
2009-01-12 12:25:22 +00:00
|
|
|
mutex_t* block_mutex = buf_page_get_mutex(bpage);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-01-12 12:25:22 +00:00
|
|
|
mutex_enter(block_mutex);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-11-30 15:09:33 +00:00
|
|
|
if (buf_page_in_file(bpage)) {
|
|
|
|
lsn = bpage->newest_modification;
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-11-24 13:05:01 +00:00
|
|
|
lsn = 0;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 12:25:22 +00:00
|
|
|
mutex_exit(block_mutex);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(lsn);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Increments the modify clock of a frame by 1. The caller must (1) own the
|
|
|
|
buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock
|
|
|
|
on the block. */
|
|
|
|
UNIV_INLINE
|
2006-10-13 11:55:27 +00:00
|
|
|
void
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_block_modify_clock_inc(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block) /*!< in: block */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
2008-01-10 09:37:13 +00:00
|
|
|
ut_ad((buf_pool_mutex_own()
|
2006-11-30 12:27:49 +00:00
|
|
|
&& (block->page.buf_fix_count == 0))
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
2006-11-24 13:05:01 +00:00
|
|
|
block->modify_clock++;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2006-02-23 19:25:29 +00:00
|
|
|
Returns the value of the modify clock. The caller must have an s-lock
|
2009-05-25 05:30:14 +00:00
|
|
|
or x-lock on the block.
|
|
|
|
@return value */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_block_get_modify_clock(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block) /*!< in: block */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
return(block->modify_clock);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Increments the bufferfix count. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-11-30 09:24:57 +00:00
|
|
|
buf_block_buf_fix_inc_func(
|
|
|
|
/*=======================*/
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
2009-05-25 05:30:14 +00:00
|
|
|
const char* file, /*!< in: file name */
|
|
|
|
ulint line, /*!< in: line */
|
2006-11-30 09:24:57 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2009-05-26 12:28:49 +00:00
|
|
|
buf_block_t* block) /*!< in/out: block to bufferfix */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-11-30 09:24:57 +00:00
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool ret;
|
|
|
|
|
2009-02-09 23:36:25 +00:00
|
|
|
ret = rw_lock_s_lock_nowait(&(block->debug_latch), file, line);
|
2006-08-16 09:35:36 +00:00
|
|
|
ut_a(ret);
|
2006-11-30 09:24:57 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2007-01-18 18:29:12 +00:00
|
|
|
ut_ad(mutex_own(&block->mutex));
|
|
|
|
|
2006-11-30 12:27:49 +00:00
|
|
|
block->page.buf_fix_count++;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-11-30 09:24:57 +00:00
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Increments the bufferfix count.
|
|
|
|
@param b in/out: block to bufferfix
|
|
|
|
@param f in: file name where requested
|
|
|
|
@param l in: line number where requested */
|
2006-11-30 09:24:57 +00:00
|
|
|
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(f,l,b)
|
2005-10-27 07:29:40 +00:00
|
|
|
#else /* UNIV_SYNC_DEBUG */
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Increments the bufferfix count.
|
|
|
|
@param b in/out: block to bufferfix
|
|
|
|
@param f in: file name where requested
|
|
|
|
@param l in: line number where requested */
|
2006-11-30 09:24:57 +00:00
|
|
|
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(b)
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2006-11-30 09:24:57 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2007-10-01 07:25:02 +00:00
|
|
|
Decrements the bufferfix count. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_buf_fix_dec(
|
|
|
|
/*==================*/
|
2009-05-26 12:28:49 +00:00
|
|
|
buf_block_t* block) /*!< in/out: block to bufferunfix */
|
2007-10-01 07:25:02 +00:00
|
|
|
{
|
|
|
|
ut_ad(mutex_own(&block->mutex));
|
|
|
|
|
|
|
|
block->page.buf_fix_count--;
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
rw_lock_s_unlock(&block->debug_latch);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns the control block of a file page, NULL if not found.
|
|
|
|
@return block, NULL if not found */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 13:23:28 +00:00
|
|
|
buf_page_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_page_hash_get(
|
|
|
|
/*==============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset) /*!< in: offset of the page within space */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-11-29 13:23:28 +00:00
|
|
|
buf_page_t* bpage;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint fold;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(buf_pool);
|
2008-01-10 09:37:13 +00:00
|
|
|
ut_ad(buf_pool_mutex_own());
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Look for the page in the hash table */
|
|
|
|
|
|
|
|
fold = buf_page_address_fold(space, offset);
|
|
|
|
|
2007-08-01 08:13:22 +00:00
|
|
|
HASH_SEARCH(hash, buf_pool->page_hash, fold, buf_page_t*, bpage,
|
branches/zip: In hash table lookups, assert that the traversed items
satisfy some conditions when UNIV_DEBUG is defined.
HASH_SEARCH(): New parameter: ASSERTION. All users will pass an appropriate
ut_ad() or nothing.
dict_table_add_to_columns(): Assert that the table being added to the data
dictionary cache is not already being pointed to by the name_hash and
id_hash tables.
HASH_SEARCH_ALL(): New macro, for use in dict_table_add_to_columns().
dict_mem_table_free(): Set ut_d(table->cached = FALSE), so that we can
check ut_ad(table->cached) when traversing the hash tables, as in
HASH_SEARCH(name_hash, dict_sys->table_hash, ...) and
HASH_SEARCH(id_hash, dict_sys->table_id_hash, ...).
dict_table_get_low(), dict_table_get_on_id_low(): Assert
ut_ad(!table || table->cached).
fil_space_get_by_id(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(hash, fil_system->spaces, ...).
fil_space_get_by_name(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(name_hash, fil_system->name_hash, ...).
buf_buddy_block_free(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->zip_hash, ...).
buf_page_hash_get(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->page_hash, ...).
get_share(), free_share(): Check ut_ad(share->use_count > 0) in
HASH_SEARCH(table_name_hash, innobase_open_tables, ...).
This was posted as rb://75 for tracking down errors similar to Issue #153.
2009-01-13 19:46:22 +00:00
|
|
|
ut_ad(bpage->in_page_hash && !bpage->in_zip_hash
|
|
|
|
&& buf_page_in_file(bpage)),
|
2006-11-29 13:23:28 +00:00
|
|
|
bpage->space == space && bpage->offset == offset);
|
2007-10-30 09:27:09 +00:00
|
|
|
if (bpage) {
|
|
|
|
ut_a(buf_page_in_file(bpage));
|
|
|
|
ut_ad(bpage->in_page_hash);
|
2007-11-05 10:17:38 +00:00
|
|
|
ut_ad(!bpage->in_zip_hash);
|
2007-10-30 09:27:09 +00:00
|
|
|
UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-11-29 13:23:28 +00:00
|
|
|
return(bpage);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2007-10-01 07:32:45 +00:00
|
|
|
Returns the control block of a file page, NULL if not found
|
2009-05-25 05:30:14 +00:00
|
|
|
or an uncompressed page frame does not exist.
|
|
|
|
@return block, NULL if not found */
|
2007-10-01 07:32:45 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
buf_block_t*
|
|
|
|
buf_block_hash_get(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset) /*!< in: offset of the page within space */
|
2007-10-01 07:32:45 +00:00
|
|
|
{
|
|
|
|
return(buf_page_get_block(buf_page_hash_get(space, offset)));
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 08:09:45 +00:00
|
|
|
Returns TRUE if the page can be found in the buffer pool hash table.
|
|
|
|
|
|
|
|
NOTE that it is possible that the page is not yet read from disk,
|
|
|
|
though.
|
|
|
|
|
|
|
|
@return TRUE if found in the page hash table */
|
2007-01-05 11:19:56 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_peek(
|
|
|
|
/*==========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset) /*!< in: page number */
|
2007-01-05 11:19:56 +00:00
|
|
|
{
|
|
|
|
const buf_page_t* bpage;
|
|
|
|
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_enter();
|
2007-01-05 11:19:56 +00:00
|
|
|
|
|
|
|
bpage = buf_page_hash_get(space, offset);
|
|
|
|
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_exit();
|
2007-01-05 11:19:56 +00:00
|
|
|
|
|
|
|
return(bpage != NULL);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2007-01-18 23:10:49 +00:00
|
|
|
Releases a compressed-only page acquired with buf_page_get_zip(). */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_release_zip(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage) /*!< in: buffer block */
|
2007-01-18 23:10:49 +00:00
|
|
|
{
|
|
|
|
buf_block_t* block;
|
|
|
|
|
|
|
|
ut_ad(bpage);
|
|
|
|
ut_a(bpage->buf_fix_count > 0);
|
|
|
|
|
|
|
|
switch (buf_page_get_state(bpage)) {
|
|
|
|
case BUF_BLOCK_ZIP_PAGE:
|
|
|
|
case BUF_BLOCK_ZIP_DIRTY:
|
2008-01-10 09:37:13 +00:00
|
|
|
mutex_enter(&buf_pool_zip_mutex);
|
2007-01-18 23:10:49 +00:00
|
|
|
bpage->buf_fix_count--;
|
2008-01-10 09:37:13 +00:00
|
|
|
mutex_exit(&buf_pool_zip_mutex);
|
2007-01-18 23:10:49 +00:00
|
|
|
return;
|
|
|
|
case BUF_BLOCK_FILE_PAGE:
|
|
|
|
block = (buf_block_t*) bpage;
|
|
|
|
mutex_enter(&block->mutex);
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
rw_lock_s_unlock(&block->debug_latch);
|
|
|
|
#endif
|
|
|
|
bpage->buf_fix_count--;
|
|
|
|
mutex_exit(&block->mutex);
|
|
|
|
return;
|
|
|
|
case BUF_BLOCK_ZIP_FREE:
|
|
|
|
case BUF_BLOCK_NOT_USED:
|
|
|
|
case BUF_BLOCK_READY_FOR_USE:
|
|
|
|
case BUF_BLOCK_MEMORY:
|
|
|
|
case BUF_BLOCK_REMOVE_HASH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_error;
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Decrements the bufferfix count of a buffer control block and releases
|
|
|
|
a latch, if specified. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_release(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: buffer block */
|
|
|
|
ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH,
|
2005-10-27 07:29:40 +00:00
|
|
|
RW_NO_LATCH */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(block);
|
|
|
|
|
2006-11-23 13:26:01 +00:00
|
|
|
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
|
2006-11-30 12:27:49 +00:00
|
|
|
ut_a(block->page.buf_fix_count > 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (rw_latch == RW_X_LATCH && mtr->modifications) {
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_enter();
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_flush_note_modification(block, mtr);
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_exit();
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-11-10 11:15:59 +00:00
|
|
|
mutex_enter(&block->mutex);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
rw_lock_s_unlock(&(block->debug_latch));
|
|
|
|
#endif
|
2006-11-30 12:27:49 +00:00
|
|
|
block->page.buf_fix_count--;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-11-10 11:15:59 +00:00
|
|
|
mutex_exit(&block->mutex);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (rw_latch == RW_S_LATCH) {
|
|
|
|
rw_lock_s_unlock(&(block->lock));
|
|
|
|
} else if (rw_latch == RW_X_LATCH) {
|
|
|
|
rw_lock_x_unlock(&(block->lock));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Adds latch level info for the rw-lock protecting the buffer frame. This
|
|
|
|
should be called in the debug version after a successful latching of a
|
2006-10-12 11:05:22 +00:00
|
|
|
page if we know the latching order level of the acquired latch. */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: buffer page
|
2006-02-23 19:25:29 +00:00
|
|
|
where we have acquired latch */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint level) /*!< in: latching order level */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
sync_thread_add_level(&block->lock, level);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|