MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
buf0buf.cc File Reference
#include "buf0buf.h"
#include "mem0mem.h"
#include "btr0btr.h"
#include "fil0fil.h"
#include "buf0buddy.h"
#include "lock0lock.h"
#include "btr0sea.h"
#include "ibuf0ibuf.h"
#include "trx0undo.h"
#include "log0log.h"
#include "srv0srv.h"
#include "dict0dict.h"
#include "log0recv.h"
#include "page0zip.h"
#include "srv0mon.h"
#include "buf0checksum.h"
Include dependency graph for buf0buf.cc:

Go to the source code of this file.

Macros

#define MONITOR_RW_COUNTER(io_type, counter)

Functions

UNIV_INTERN lsn_t buf_pool_get_oldest_modification (void)
UNIV_INTERN void buf_get_total_list_len (ulint *LRU_len, ulint *free_len, ulint *flush_list_len)
UNIV_INTERN void buf_get_total_list_size_in_bytes (buf_pools_list_size_t *buf_pools_list_size)
UNIV_INTERN void buf_get_total_stat (buf_pool_stat_t *tot_stat)
UNIV_INTERN buf_block_tbuf_block_alloc (buf_pool_t *buf_pool)
UNIV_INTERN ibool buf_page_is_corrupted (bool check_lsn, const byte *read_buf, ulint zip_size)
UNIV_INTERN void buf_page_print (const byte *read_buf, ulint zip_size, ulint flags)
UNIV_INTERN ulint buf_pool_init_instance (buf_pool_t *buf_pool, ulint buf_pool_size, ulint instance_no)
UNIV_INTERN dberr_t buf_pool_init (ulint total_size, ulint n_instances)
UNIV_INTERN void buf_pool_free (ulint n_instances)
UNIV_INTERN void buf_pool_clear_hash_index (void)
UNIV_INTERN void buf_relocate (buf_page_t *bpage, buf_page_t *dpage)
UNIV_INTERN ibool buf_pool_watch_is_sentinel (buf_pool_t *buf_pool, const buf_page_t *bpage)
UNIV_INTERN buf_page_tbuf_pool_watch_set (ulint space, ulint offset, ulint fold)
UNIV_INTERN void buf_pool_watch_unset (ulint space, ulint offset)
UNIV_INTERN ibool buf_pool_watch_occurred (ulint space, ulint offset)
UNIV_INTERN void buf_page_make_young (buf_page_t *bpage)
UNIV_INTERN void buf_reset_check_index_page_at_flush (ulint space, ulint offset)
UNIV_INTERN buf_page_tbuf_page_get_zip (ulint space, ulint zip_size, ulint offset)
UNIV_INLINE void buf_block_init_low (buf_block_t *block)
UNIV_INTERN ibool buf_zip_decompress (buf_block_t *block, ibool check)
UNIV_INTERN buf_block_tbuf_block_align_instance (buf_pool_t *buf_pool, const byte *ptr)
UNIV_INTERN buf_block_tbuf_block_align (const byte *ptr)
UNIV_INTERN ibool buf_pointer_is_block_field (const void *ptr)
UNIV_INTERN buf_block_tbuf_page_get_gen (ulint space, ulint zip_size, ulint offset, ulint rw_latch, buf_block_t *guess, ulint mode, const char *file, ulint line, mtr_t *mtr)
UNIV_INTERN ibool buf_page_optimistic_get (ulint rw_latch, buf_block_t *block, ib_uint64_t modify_clock, const char *file, ulint line, mtr_t *mtr)
UNIV_INTERN ibool buf_page_get_known_nowait (ulint rw_latch, buf_block_t *block, ulint mode, const char *file, ulint line, mtr_t *mtr)
UNIV_INTERN const buf_block_tbuf_page_try_get_func (ulint space_id, ulint page_no, const char *file, ulint line, mtr_t *mtr)
UNIV_INLINE void buf_page_init_low (buf_page_t *bpage)

Variables

UNIV_INTERN buf_pool_tbuf_pool_ptr
static ulint space
static ulint ulint offset
static ulint ulint ulint fold
static ulint ulint ulint ulint zip_size

Detailed Description

The database buffer buf_pool

Created 11/5/1995 Heikki Tuuri

Definition in file buf0buf.cc.

Macro Definition Documentation

#define MONITOR_RW_COUNTER (   io_type,
  counter 
)
Value:
((io_type == BUF_IO_READ) \
? (counter##_READ) \
: (counter##_WRITTEN))
Macro to determine whether the read of write counter is used depending

on the io_type

Definition at line 301 of file buf0buf.cc.

Function Documentation

UNIV_INTERN buf_block_t* buf_block_align ( const byte *  ptr)

Gets the block to whose frame the pointer is pointing to.

Returns
pointer to block, never NULL
Parameters
ptrin: pointer to a frame

Definition at line 2294 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN buf_block_t* buf_block_align_instance ( buf_pool_t buf_pool,
const byte *  ptr 
)

Gets the block to whose frame the pointer is pointing to if found in this buffer pool instance.

Returns
pointer to block
Parameters
buf_poolin: buffer in which the block resides
ptrin: pointer to a frame

Definition at line 2204 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN buf_block_t* buf_block_alloc ( buf_pool_t buf_pool)

Allocates a buffer block.

Returns
own: the allocated block, in state BUF_BLOCK_MEMORY
Parameters
buf_poolin/out: buffer pool instance, or NULL for round-robin selection of the buffer pool

Definition at line 444 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE void buf_block_init_low ( buf_block_t block)

Initialize some fields of a control block.

Parameters
blockin: block to init

Definition at line 2115 of file buf0buf.cc.

Here is the caller graph for this function:

UNIV_INTERN void buf_get_total_list_len ( ulint *  LRU_len,
ulint *  free_len,
ulint *  flush_list_len 
)

Get total buffer pool statistics.

Parameters
LRU_lenout: length of all LRU lists
free_lenout: length of all free lists
flush_list_lenout: length of all flush lists

Definition at line 357 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_get_total_list_size_in_bytes ( buf_pools_list_size_t buf_pools_list_size)

Get total list size in bytes from all buffer pools.

Parameters
buf_pools_list_sizeout: list sizes in all buffer pools

Definition at line 384 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_get_total_stat ( buf_pool_stat_t tot_stat)

Get total buffer pool statistics.

Parameters
tot_statout: buffer pool stats

Definition at line 410 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN buf_block_t* buf_page_get_gen ( ulint  space,
ulint  zip_size,
ulint  offset,
ulint  rw_latch,
buf_block_t guess,
ulint  mode,
const char *  file,
ulint  line,
mtr_t mtr 
)

This is the general function used to get access to a database page.

Returns
pointer to the block or NULL
Parameters
spacein: space id
zip_sizein: compressed page size in bytes or 0 for uncompressed pages
offsetin: page number
rw_latchin: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH
guessin: guessed block or NULL
modein: BUF_GET, BUF_GET_IF_IN_POOL, BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH
filein: file name
linein: line where called
mtrin: mini-transaction

Definition at line 2416 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool buf_page_get_known_nowait ( ulint  rw_latch,
buf_block_t block,
ulint  mode,
const char *  file,
ulint  line,
mtr_t mtr 
)

This is used to get access to a known database page, when no waiting can be done. For example, if a search in an adaptive hash index leads us to this frame.

Returns
TRUE if success
Parameters
rw_latchin: RW_S_LATCH, RW_X_LATCH
blockin: the known page
modein: BUF_MAKE_YOUNG or BUF_KEEP_OLD
filein: file name
linein: line where called
mtrin: mini-transaction

Definition at line 3049 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN buf_page_t* buf_page_get_zip ( ulint  space,
ulint  zip_size,
ulint  offset 
)

Get read access to a compressed page (usually of type FIL_PAGE_TYPE_ZBLOB or FIL_PAGE_TYPE_ZBLOB2). The page must be released with buf_page_release_zip(). NOTE: the page is not protected by any latch. Mutual exclusion has to be implemented at a higher level. In other words, all possible accesses to a given page through this function must be protected by the same set of mutexes or latches.

Returns
pointer to the block
Parameters
spacein: space id
zip_sizein: compressed page size
offsetin: page number

Definition at line 1983 of file buf0buf.cc.

Here is the call graph for this function:

UNIV_INLINE void buf_page_init_low ( buf_page_t bpage)

Initialize some fields of a control block.

Parameters
bpagein: block to init

Definition at line 3243 of file buf0buf.cc.

UNIV_INTERN ibool buf_page_is_corrupted ( bool  check_lsn,
const byte *  read_buf,
ulint  zip_size 
)

Checks if a page is corrupt.

Returns
TRUE if corrupted
Parameters
check_lsnin: true if we need to check and complain about the LSN
read_bufin: a database page
zip_sizein: size of compressed page; 0 for uncompressed pages

Definition at line 474 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_page_make_young ( buf_page_t bpage)

Moves a page to the start of the buffer pool LRU list. This high-level function can be used to prevent an important page from slipping out of the buffer pool.

Parameters
bpagein: buffer block of a file page

Definition at line 1812 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool buf_page_optimistic_get ( ulint  rw_latch,
buf_block_t block,
ib_uint64_t  modify_clock,
const char *  file,
ulint  line,
mtr_t mtr 
)

This is the general function used to get optimistic access to a database page.

Returns
TRUE if success
Parameters
rw_latchin: RW_S_LATCH, RW_X_LATCH
blockin: guessed buffer block
modify_clockin: modify clock value
filein: file name
linein: line where called
mtrin: mini-transaction

Definition at line 2931 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_page_print ( const byte *  read_buf,
ulint  zip_size,
ulint  flags 
)

Prints a page to stderr.

Parameters
read_bufin: a database page
zip_sizein: compressed page size, or 0 for uncompressed pages
flagsin: 0 or BUF_PAGE_PRINT_NO_CRASH or BUF_PAGE_PRINT_NO_FULL

Definition at line 706 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN const buf_block_t* buf_page_try_get_func ( ulint  space_id,
ulint  page_no,
const char *  file,
ulint  line,
mtr_t mtr 
)

Given a tablespace id and page number tries to get that page. If the page is not in the buffer pool it is not loaded and NULL is returned. Suitable for using when holding the lock_sys_t::mutex.

Returns
pointer to a page or NULL
Parameters
space_idin: tablespace id
page_noin: page number
filein: file name
linein: line where called
mtrin: mini-transaction

Definition at line 3154 of file buf0buf.cc.

Here is the call graph for this function:

UNIV_INTERN ibool buf_pointer_is_block_field ( const void *  ptr)

Find out if a pointer belongs to a buf_block_t. It can be a pointer to the buf_block_t itself or a member of it

Returns
TRUE if ptr belongs to a buf_block_t struct
Parameters
ptrin: pointer not dereferenced

Definition at line 2351 of file buf0buf.cc.

Here is the call graph for this function:

UNIV_INTERN void buf_pool_clear_hash_index ( void  )

Clears the adaptive hash index on all pages in the buffer pool.

Definition at line 1419 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_pool_free ( ulint  n_instances)

Frees the buffer pool at shutdown. This must not be invoked before freeing all mutexes.

Parameters
n_instancesin: numbere of instances to free

Definition at line 1401 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN lsn_t buf_pool_get_oldest_modification ( void  )

Gets the smallest oldest_modification lsn for any page in the pool. Returns zero if all modified pages have been flushed to disk.

Returns
oldest modification in pool, zero if none

Definition at line 312 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t buf_pool_init ( ulint  total_size,
ulint  n_instances 
)

Creates the buffer pool.

Returns
DB_SUCCESS if success, DB_ERROR if not enough memory or error
Parameters
total_sizein: size of the total pool in bytes
n_instancesin: number of instances

Definition at line 1361 of file buf0buf.cc.

Here is the call graph for this function:

UNIV_INTERN ulint buf_pool_init_instance ( buf_pool_t buf_pool,
ulint  buf_pool_size,
ulint  instance_no 
)

Initialize a buffer pool instance.

Returns
DB_SUCCESS if all goes well.
Parameters
buf_poolin: buffer pool instance
buf_pool_sizein: size in bytes
instance_noin: id of the instance

Definition at line 1230 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool buf_pool_watch_is_sentinel ( buf_pool_t buf_pool,
const buf_page_t bpage 
)

Determine if a block is a sentinel for a buffer pool watch.

Returns
TRUE if a sentinel for a buffer pool watch, FALSE if not
Parameters
buf_poolbuffer pool instance
bpagein: block

Definition at line 1552 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool buf_pool_watch_occurred ( ulint  space,
ulint  offset 
)

Check if the page has been read in. This may only be called after buf_pool_watch_set(space,offset) has returned NULL and before invoking buf_pool_watch_unset(space,offset).

Returns
FALSE if the given page was not read in, TRUE if it was
Parameters
spacein: space id
offsetin: page number

Definition at line 1782 of file buf0buf.cc.

Here is the call graph for this function:

UNIV_INTERN buf_page_t* buf_pool_watch_set ( ulint  space,
ulint  offset,
ulint  fold 
)

Add watch for the given page to be read in. Caller must have appropriate hash_lock for the bpage. This function may release the hash_lock and reacquire it.

Returns
NULL if watch set, block if the page is in the buffer pool
Parameters
spacein: space id
offsetin: page number
foldin: buf_page_address_fold(space, offset)

Definition at line 1585 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_pool_watch_unset ( ulint  space,
ulint  offset 
)

Stop watching if the page has been read in. buf_pool_watch_set(space,offset) must have returned NULL before.

Parameters
spacein: space id
offsetin: page number

Definition at line 1731 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_relocate ( buf_page_t bpage,
buf_page_t dpage 
)

Relocate a buffer control block. Relocates the block on the LRU list and in buf_pool->page_hash. Does not relocate bpage->list. The caller must take care of relocating bpage->list.

Parameters
bpagein/out: control block being relocated; buf_page_get_state(bpage) must be BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE
dpagein/out: destination control block

Definition at line 1465 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_reset_check_index_page_at_flush ( ulint  space,
ulint  offset 
)

Resets the check_index_page_at_flush field of a page if found in the buffer pool.

Parameters
spacein: space id
offsetin: page number

Definition at line 1854 of file buf0buf.cc.

Here is the call graph for this function:

UNIV_INTERN ibool buf_zip_decompress ( buf_block_t block,
ibool  check 
)

Decompress a block.

Returns
TRUE if successful
Parameters
blockin/out: block
checkin: TRUE=verify the page checksum

Definition at line 2134 of file buf0buf.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

UNIV_INTERN buf_pool_t* buf_pool_ptr

The buffer pools of the database

Definition at line 252 of file buf0buf.cc.

ulint ulint ulint fold

in: buf_page_address_fold(space,offset)

Definition at line 3267 of file buf0buf.cc.

static ulint ulint offset

in: offset of the page within space in units of a page

in: page offset; if equal to the free limit, we try to add new extents to the space free list

Definition at line 3267 of file buf0buf.cc.

ulint space

< in/out: buffer pool in: space id

Definition at line 3267 of file buf0buf.cc.

static ulint zip_size

in: compressed page size, or 0

< in: space id in: compressed page size in bytes or 0 for uncompressed pages

Definition at line 3267 of file buf0buf.cc.