InnoDB Plugin  1.0
Data Structures | Functions
buf0buf.ic File Reference
#include "mtr0mtr.h"
#include "buf0flu.h"
#include "buf0lru.h"
#include "buf0rea.h"
Include dependency graph for buf0buf.ic:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  buf_chunk_t

Functions

UNIV_INLINE ulint buf_pool_get_curr_size (void)
UNIV_INLINE ulint buf_pool_index (const buf_pool_t *buf_pool)
UNIV_INLINE buf_pool_tbuf_pool_from_bpage (const buf_page_t *bpage)
UNIV_INLINE buf_pool_tbuf_pool_from_block (const buf_block_t *block)
UNIV_INLINE ulint buf_pool_get_n_pages (void)
UNIV_INLINE ulint buf_page_get_freed_page_clock (const buf_page_t *bpage)
UNIV_INLINE ulint buf_block_get_freed_page_clock (const buf_block_t *block)
UNIV_INLINE ibool buf_page_peek_if_young (const buf_page_t *bpage)
UNIV_INLINE ibool buf_page_peek_if_too_old (const buf_page_t *bpage)
UNIV_INLINE enum buf_page_state buf_page_get_state (const buf_page_t *bpage)
UNIV_INLINE enum buf_page_state buf_block_get_state (const buf_block_t *block)
UNIV_INLINE void buf_page_set_state (buf_page_t *bpage, enum buf_page_state state)
UNIV_INLINE void buf_block_set_state (buf_block_t *block, enum buf_page_state state)
UNIV_INLINE ibool buf_page_in_file (const buf_page_t *bpage)
UNIV_INLINE ibool buf_page_belongs_to_unzip_LRU (const buf_page_t *bpage)
UNIV_INLINE ib_mutex_tbuf_page_get_mutex (const buf_page_t *bpage)
UNIV_INLINE buf_flush_t buf_page_get_flush_type (const buf_page_t *bpage)
UNIV_INLINE void buf_page_set_flush_type (buf_page_t *bpage, buf_flush_t flush_type)
UNIV_INLINE void buf_block_set_file_page (buf_block_t *block, ulint space, ulint page_no)
UNIV_INLINE enum buf_io_fix buf_page_get_io_fix (const buf_page_t *bpage)
UNIV_INLINE enum buf_io_fix buf_block_get_io_fix (const buf_block_t *block)
UNIV_INLINE void buf_page_set_io_fix (buf_page_t *bpage, enum buf_io_fix io_fix)
UNIV_INLINE void buf_block_set_io_fix (buf_block_t *block, enum buf_io_fix io_fix)
UNIV_INLINE void buf_page_set_sticky (buf_page_t *bpage)
UNIV_INLINE void buf_page_unset_sticky (buf_page_t *bpage)
UNIV_INLINE ibool buf_page_can_relocate (const buf_page_t *bpage)
UNIV_INLINE ibool buf_page_is_old (const buf_page_t *bpage)
UNIV_INLINE void buf_page_set_old (buf_page_t *bpage, ibool old)
UNIV_INLINE unsigned buf_page_is_accessed (const buf_page_t *bpage)
UNIV_INLINE void buf_page_set_accessed (buf_page_t *bpage)
UNIV_INLINE buf_block_tbuf_page_get_block (buf_page_t *bpage)
UNIV_INLINE buf_frame_tbuf_block_get_frame (const buf_block_t *block)
UNIV_INLINE ulint buf_page_get_space (const buf_page_t *bpage)
UNIV_INLINE ulint buf_block_get_space (const buf_block_t *block)
UNIV_INLINE ulint buf_page_get_page_no (const buf_page_t *bpage)
UNIV_INLINE buf_frame_tbuf_frame_align (byte *ptr)
UNIV_INLINE ulint buf_block_get_page_no (const buf_block_t *block)
UNIV_INLINE ulint buf_page_get_zip_size (const buf_page_t *bpage)
UNIV_INLINE ulint buf_block_get_zip_size (const buf_block_t *block)
UNIV_INLINE const page_zip_des_tbuf_frame_get_page_zip (const byte *ptr)
UNIV_INLINE void buf_ptr_get_fsp_addr (const void *ptr, ulint *space, fil_addr_t *addr)
UNIV_INLINE ulint buf_block_get_lock_hash_val (const buf_block_t *block)
UNIV_INLINE buf_page_tbuf_page_alloc_descriptor (void)
UNIV_INLINE void buf_page_free_descriptor (buf_page_t *bpage)
UNIV_INLINE void buf_block_free (buf_block_t *block)
UNIV_INLINE byte * buf_frame_copy (byte *buf, const buf_frame_t *frame)
UNIV_INLINE ulint buf_page_address_fold (ulint space, ulint offset)
UNIV_INLINE lsn_t buf_page_get_newest_modification (const buf_page_t *bpage)
UNIV_INLINE void buf_block_modify_clock_inc (buf_block_t *block)
UNIV_INLINE ib_uint64_t buf_block_get_modify_clock (buf_block_t *block)
UNIV_INLINE void buf_block_fix (buf_block_t *block)
UNIV_INLINE void buf_block_buf_fix_inc_func (const char *file, ulint line, buf_block_t *block)
UNIV_INLINE void buf_block_unfix (buf_block_t *block)
UNIV_INLINE void buf_block_buf_fix_dec (buf_block_t *block)
UNIV_INLINE buf_pool_tbuf_pool_get (ulint space, ulint offset)
UNIV_INLINE buf_pool_tbuf_pool_from_array (ulint index)
UNIV_INLINE buf_page_tbuf_page_hash_get_low (buf_pool_t *buf_pool, ulint space, ulint offset, ulint fold)
UNIV_INLINE buf_page_tbuf_page_hash_get_locked (buf_pool_t *buf_pool, ulint space, ulint offset, rw_lock_t **lock, ulint lock_mode, bool watch)
UNIV_INLINE buf_block_tbuf_block_hash_get_locked (buf_pool_t *buf_pool, ulint space, ulint offset, rw_lock_t **lock, ulint lock_mode)
UNIV_INLINE ibool buf_page_peek (ulint space, ulint offset)
UNIV_INLINE void buf_page_release_zip (buf_page_t *bpage)
UNIV_INLINE void buf_page_release (buf_block_t *block, ulint rw_latch)
UNIV_INLINE void buf_block_dbg_add_level (buf_block_t *block, ulint level)
UNIV_INLINE void buf_pool_mutex_enter_all (void)
UNIV_INLINE void buf_pool_mutex_exit_all (void)
UNIV_INLINE buf_block_tbuf_get_nth_chunk_block (const buf_pool_t *buf_pool, ulint n, ulint *chunk_size)

Detailed Description

The database buffer buf_pool

Created 11/5/1995 Heikki Tuuri

Function Documentation

UNIV_INLINE void buf_block_buf_fix_dec ( buf_block_t block)

Decrements the bufferfix count.

Parameters
blockin/out: block to bufferunfix
UNIV_INLINE void buf_block_buf_fix_inc_func ( const char *  file,
ulint  line,
buf_block_t block 
)

Increments the bufferfix count.

Parameters
filein: file name
linein: line
blockin/out: block to bufferfix
UNIV_INLINE void buf_block_dbg_add_level ( buf_block_t block,
ulint  level 
)

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 page if we know the latching order level of the acquired latch.

Parameters
blockin: buffer page where we have acquired latch
levelin: latching order level
UNIV_INLINE void buf_block_fix ( buf_block_t block)

Increments the bufferfix count.

Parameters
blockin/out: block to bufferfix
UNIV_INLINE void buf_block_free ( buf_block_t block)

Frees a buffer block which does not contain a file page.

Parameters
blockin, own: block to be freed
UNIV_INLINE buf_frame_t* buf_block_get_frame ( const buf_block_t block)

Gets a pointer to the memory frame of a block.

Returns
pointer to the frame
Parameters
blockin: pointer to the control block
UNIV_INLINE ulint buf_block_get_freed_page_clock ( const buf_block_t block)

Reads the freed_page_clock of a buffer block.

Returns
freed_page_clock
Parameters
blockin: block
UNIV_INLINE enum buf_io_fix buf_block_get_io_fix ( const buf_block_t block)

Gets the io_fix state of a block.

Returns
io_fix state
Parameters
blockin: pointer to the control block
UNIV_INLINE ulint buf_block_get_lock_hash_val ( const buf_block_t block)

Gets the hash value of the page the pointer is pointing to. This can be used in searches in the lock hash table.

Returns
lock hash value
Parameters
blockin: block
UNIV_INLINE ib_uint64_t buf_block_get_modify_clock ( buf_block_t block)

Returns the value of the modify clock. The caller must have an s-lock or x-lock on the block.

Returns
value
Parameters
blockin: block
UNIV_INLINE ulint buf_block_get_page_no ( const buf_block_t block)

Gets the page number of a block.

Returns
page number
Parameters
blockin: pointer to the control block
UNIV_INLINE ulint buf_block_get_space ( const buf_block_t block)

Gets the space id of a block.

Returns
space id
Parameters
blockin: pointer to the control block
UNIV_INLINE enum buf_page_state buf_block_get_state ( const buf_block_t block)

Gets the state of a block.

Returns
state
Parameters
blockin: pointer to the control block
UNIV_INLINE ulint buf_block_get_zip_size ( const buf_block_t block)

Gets the compressed page size of a block.

Returns
compressed page size, or 0
Parameters
blockin: pointer to the control block
UNIV_INLINE buf_block_t* buf_block_hash_get_locked ( buf_pool_t buf_pool,
ulint  space,
ulint  offset,
rw_lock_t **  lock,
ulint  lock_mode 
)

Returns the control block of a file page, NULL if not found. If the block is found and lock is not NULL then the appropriate page_hash lock is acquired in the specified lock mode. Otherwise, mode value is ignored. It is up to the caller to release the lock. If the block is found and the lock is NULL then the page_hash lock is released by this function.

Returns
block, NULL if not found
Parameters
buf_poolout: pointer to the bpage, or NULL; if NULL, hash_lock is also NULL. buffer pool instance
spacein: space id
offsetin: page number
lockin/out: lock of the page hash acquired if bpage is found. NULL otherwise. If NULL is passed then the hash_lock is released by this function
lock_modein: RW_LOCK_EX or RW_LOCK_SHARED. Ignored if lock == NULL
UNIV_INLINE void buf_block_modify_clock_inc ( buf_block_t block)

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.

Parameters
blockin: block
UNIV_INLINE void buf_block_set_file_page ( buf_block_t block,
ulint  space,
ulint  page_no 
)

Map a block to a file page.

Parameters
blockin/out: pointer to control block
spacein: tablespace id
page_noin: page number
UNIV_INLINE void buf_block_set_io_fix ( buf_block_t block,
enum buf_io_fix  io_fix 
)

Sets the io_fix state of a block.

Parameters
blockin/out: control block
io_fixin: io_fix state
UNIV_INLINE void buf_block_set_state ( buf_block_t block,
enum buf_page_state  state 
)

Sets the state of a block.

Parameters
blockin/out: pointer to control block
statein: state
UNIV_INLINE void buf_block_unfix ( buf_block_t block)

Decrements the bufferfix count.

Parameters
blockin/out: block to bufferunfix
UNIV_INLINE byte* buf_frame_copy ( byte *  buf,
const buf_frame_t frame 
)

Copies contents of a buffer frame to a given buffer.

Returns
buf
Parameters
bufin: buffer to copy to
framein: buffer frame
UNIV_INLINE const page_zip_des_t* buf_frame_get_page_zip ( const byte *  ptr)

Gets the compressed page descriptor corresponding to an uncompressed page if applicable.

Returns
compressed page descriptor, or NULL
Parameters
ptrin: pointer to the page
UNIV_INLINE buf_block_t* buf_get_nth_chunk_block ( const buf_pool_t buf_pool,
ulint  n,
ulint *  chunk_size 
)

Get the nth chunk's buffer block in the specified buffer pool.

Returns
the nth chunk's buffer block.
Parameters
buf_poolin: buffer pool instance
nin: nth chunk in the buffer pool
chunk_sizein: chunk size
UNIV_INLINE ulint buf_page_address_fold ( ulint  space,
ulint  offset 
)

Calculates a folded value of a file page address to use in the page hash table.

Returns
the folded value
Parameters
spacein: space id
offsetin: offset of the page within space
UNIV_INLINE buf_page_t* buf_page_alloc_descriptor ( void  )

Allocates a buf_page_t descriptor. This function must succeed. In case of failure we assert in this function.

Returns
: the allocated descriptor.
UNIV_INLINE ibool buf_page_belongs_to_unzip_LRU ( const buf_page_t bpage)

Determines if a block should be on unzip_LRU list.

Returns
TRUE if block belongs to unzip_LRU
Parameters
bpagein: pointer to control block
UNIV_INLINE ibool buf_page_can_relocate ( const buf_page_t bpage)

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.

Parameters
bpagecontrol block being relocated
UNIV_INLINE void buf_page_free_descriptor ( buf_page_t bpage)

Free a buf_page_t descriptor.

Parameters
bpagein: bpage descriptor to free.
UNIV_INLINE buf_block_t* buf_page_get_block ( buf_page_t bpage)

Gets the buf_block_t handle of a buffered file block if an uncompressed page frame exists, or NULL.

Returns
control block, or NULL
Parameters
bpagein: control block, or NULL
UNIV_INLINE buf_flush_t buf_page_get_flush_type ( const buf_page_t bpage)

Get the flush type of a page.

Returns
flush type
Parameters
bpagein: buffer page
UNIV_INLINE ulint buf_page_get_freed_page_clock ( const buf_page_t bpage)

Reads the freed_page_clock of a buffer block.

Returns
freed_page_clock
Parameters
bpagein: block
UNIV_INLINE enum buf_io_fix buf_page_get_io_fix ( const buf_page_t bpage)

Gets the io_fix state of a block.

Returns
io_fix state
Parameters
bpagein: pointer to the control block
UNIV_INLINE ib_mutex_t* buf_page_get_mutex ( const buf_page_t bpage)

Gets the mutex of a block.

Returns
pointer to mutex protecting bpage
Parameters
bpagein: pointer to control block
UNIV_INLINE lsn_t buf_page_get_newest_modification ( const buf_page_t bpage)

Gets the youngest modification log sequence number for a frame. Returns zero if not file page or no modification occurred yet.

Returns
newest modification to page
Parameters
bpagein: block containing the page frame
UNIV_INLINE ulint buf_page_get_page_no ( const buf_page_t bpage)

Gets the page number of a block.

Returns
page number
Parameters
bpagein: pointer to the control block
UNIV_INLINE ulint buf_page_get_space ( const buf_page_t bpage)

Gets the space id of a block.

Returns
space id
Parameters
bpagein: pointer to the control block
UNIV_INLINE enum buf_page_state buf_page_get_state ( const buf_page_t bpage)

Gets the state of a block.

Returns
state
Parameters
bpagein: pointer to the control block
UNIV_INLINE ulint buf_page_get_zip_size ( const buf_page_t bpage)

Gets the compressed page size of a block.

Returns
compressed page size, or 0
Parameters
bpagein: pointer to the control block
UNIV_INLINE buf_page_t* buf_page_hash_get_locked ( buf_pool_t buf_pool,
ulint  space,
ulint  offset,
rw_lock_t **  lock,
ulint  lock_mode,
bool  watch 
)

Returns the control block of a file page, NULL if not found. If the block is found and lock is not NULL then the appropriate page_hash lock is acquired in the specified lock mode. Otherwise, mode value is ignored. It is up to the caller to release the lock. If the block is found and the lock is NULL then the page_hash lock is released by this function.

Returns
block, NULL if not found, or watch sentinel (if watch is true)
Parameters
buf_poolout: pointer to the bpage, or NULL; if NULL, hash_lock is also NULL. buffer pool instance
spacein: space id
offsetin: page number
lockin/out: lock of the page hash acquired if bpage is found. NULL otherwise. If NULL is passed then the hash_lock is released by this function
lock_modein: RW_LOCK_EX or RW_LOCK_SHARED. Ignored if lock == NULL
watchin: if true, return watch sentinel also.
UNIV_INLINE buf_page_t* buf_page_hash_get_low ( buf_pool_t buf_pool,
ulint  space,
ulint  offset,
ulint  fold 
)

Returns the control block of a file page, NULL if not found.

Returns
block, NULL if not found
Parameters
buf_poolbuffer pool instance
spacein: space id
offsetin: offset of the page within space
foldin: buf_page_address_fold(space, offset)
UNIV_INLINE ibool buf_page_in_file ( const buf_page_t bpage)

Determines if a block is mapped to a tablespace.

Returns
TRUE if mapped
Parameters
bpagein: pointer to control block
UNIV_INLINE unsigned buf_page_is_accessed ( const buf_page_t bpage)

Determine the time of first access of a block in the buffer pool.

Returns
ut_time_ms() at the time of first access, 0 if not accessed
Parameters
bpagein: control block
UNIV_INLINE ibool buf_page_is_old ( const buf_page_t bpage)

Determine if a block has been flagged old.

Returns
TRUE if old
Parameters
bpagein: control block
UNIV_INLINE ibool buf_page_peek ( ulint  space,
ulint  offset 
)

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.

Returns
TRUE if found in the page hash table
Parameters
spacein: space id
offsetin: page number
UNIV_INLINE ibool buf_page_peek_if_too_old ( const buf_page_t bpage)

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 mutex.

Returns
TRUE if should be made younger
Parameters
bpagein: block to make younger
UNIV_INLINE ibool buf_page_peek_if_young ( const buf_page_t bpage)

Tells if a block is still close enough to the MRU end of the LRU list meaning that it is not in danger of getting evicted and also implying that it has been accessed recently. Note that this is for heuristics only and does not reserve buffer pool mutex.

Returns
TRUE if block is close to MRU end of LRU
Parameters
bpagein: block
UNIV_INLINE void buf_page_release ( buf_block_t block,
ulint  rw_latch 
)

Decrements the bufferfix count of a buffer control block and releases a latch, if specified.

Parameters
blockin: buffer block
rw_latchin: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH
UNIV_INLINE void buf_page_release_zip ( buf_page_t bpage)

Releases a compressed-only page acquired with buf_page_get_zip().

Parameters
bpagein: buffer block
UNIV_INLINE void buf_page_set_accessed ( buf_page_t bpage)

Flag a block accessed.

Parameters
bpagein/out: control block
UNIV_INLINE void buf_page_set_flush_type ( buf_page_t bpage,
buf_flush_t  flush_type 
)

Set the flush type of a page.

Parameters
bpagein: buffer page
flush_typein: flush type
UNIV_INLINE void buf_page_set_io_fix ( buf_page_t bpage,
enum buf_io_fix  io_fix 
)

Sets the io_fix state of a block.

Parameters
bpagein/out: control block
io_fixin: io_fix state
UNIV_INLINE void buf_page_set_old ( buf_page_t bpage,
ibool  old 
)

Flag a block old.

Parameters
bpagein/out: control block
oldin: old
UNIV_INLINE void buf_page_set_state ( buf_page_t bpage,
enum buf_page_state  state 
)

Sets the state of a block.

Parameters
bpagein/out: pointer to control block
statein: state
UNIV_INLINE void buf_page_set_sticky ( buf_page_t bpage)

Makes a block sticky. A sticky block implies that even after we release the buf_pool->mutex and the block->mutex: it cannot be removed from the flush_list the block descriptor cannot be relocated it cannot be removed from the LRU list Note that: the block can still change its position in the LRU list the next and previous pointers can change.

Parameters
bpagein/out: control block
UNIV_INLINE void buf_page_unset_sticky ( buf_page_t bpage)

Removes stickiness of a block.

Parameters
bpagein/out: control block
UNIV_INLINE buf_pool_t* buf_pool_from_array ( ulint  index)

Returns the buffer pool instance given its array index

Returns
buffer pool
Parameters
indexin: array index to get buffer pool instance from
UNIV_INLINE buf_pool_t* buf_pool_from_block ( const buf_block_t block)

Returns the buffer pool instance given a block instance

Returns
buf_pool
Parameters
blockin: block
UNIV_INLINE buf_pool_t* buf_pool_from_bpage ( const buf_page_t bpage)

Returns the buffer pool instance given a page instance

Returns
buf_pool
Parameters
bpagein: buffer pool page
UNIV_INLINE buf_pool_t* buf_pool_get ( ulint  space,
ulint  offset 
)

Returns the buffer pool instance given space and offset of page

Returns
buffer pool
Parameters
spacein: space id
offsetin: offset of the page within space
UNIV_INLINE ulint buf_pool_get_curr_size ( void  )

Gets the current size of buffer buf_pool in bytes.

Returns
size in bytes
UNIV_INLINE ulint buf_pool_get_n_pages ( void  )

Gets the current size of buffer buf_pool in pages.

Returns
size in pages
UNIV_INLINE ulint buf_pool_index ( const buf_pool_t buf_pool)

Calculates the index of a buffer pool to the buf_pool[] array.

Returns
the position of the buffer pool in buf_pool[]
Parameters
buf_poolin: buffer pool
UNIV_INLINE void buf_pool_mutex_enter_all ( void  )

Acquire mutex on all buffer pool instances.

UNIV_INLINE void buf_pool_mutex_exit_all ( void  )

Release mutex on all buffer pool instances.

UNIV_INLINE void buf_ptr_get_fsp_addr ( const void *  ptr,
ulint *  space,
fil_addr_t addr 
)

Gets the space id, page offset, and byte offset within page of a pointer pointing to a buffer frame containing a file page.

Parameters
ptrin: pointer to a buffer frame
spaceout: space id
addrout: page offset and byte offset