InnoDB Plugin  1.0
Data Structures | Macros | Enumerations | Functions | Variables
buf0buf.h File Reference
#include "univ.i"
#include "fil0fil.h"
#include "mtr0types.h"
#include "buf0types.h"
#include "hash0hash.h"
#include "ut0byte.h"
#include "page0types.h"
#include "ut0rbt.h"
#include "os0proc.h"
#include "log0log.h"
#include "buf0buf.ic"
Include dependency graph for buf0buf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  buf_pool_info_t
struct  buf_pools_list_size_t
struct  buf_page_t
struct  buf_block_t
struct  buf_buddy_free_t
struct  buf_pool_stat_t
 The buffer pool statistics structure. More...
struct  buf_buddy_stat_t
struct  buf_pool_t
 The buffer pool structure. More...
struct  CheckInLRUList
struct  CheckInFreeList
struct  CheckUnzipLRUAndLRUList

Macros

#define MAX_BUFFER_POOLS_BITS   6
#define MAX_BUFFER_POOLS   (1 << MAX_BUFFER_POOLS_BITS)
#define BUF_POOL_WATCH_SIZE   (srv_n_purge_threads + 1)
#define MAX_PAGE_HASH_LOCKS   1024
#define BUF_NO_CHECKSUM_MAGIC   0xDEADBEEFUL
#define buf_page_get(SP, ZS, OF, LA, MTR)
#define buf_page_get_with_no_latch(SP, ZS, OF, MTR)
#define buf_page_try_get(space_id, page_no, mtr)   buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
#define buf_block_buf_fix_inc(b, f, l)   buf_block_buf_fix_inc_func(f,l,b)
#define buf_block_get_page_zip(block)   ((block)->page.zip.data ? &(block)->page.zip : NULL)
#define buf_pool_is_block_mutex(m)   buf_pointer_is_block_field((const void*)(m))
#define buf_pool_is_block_lock(l)   buf_pointer_is_block_field((const void*)(l))
#define buf_page_hash_get_s_locked(b, s, o, l)   buf_page_hash_get_locked(b, s, o, l, RW_LOCK_SHARED)
#define buf_page_hash_get_x_locked(b, s, o, l)   buf_page_hash_get_locked(b, s, o, l, RW_LOCK_EX)
#define buf_page_hash_get(b, s, o)   buf_page_hash_get_locked(b, s, o, NULL, 0)
#define buf_page_get_also_watch(b, s, o)   buf_page_hash_get_locked(b, s, o, NULL, 0, true)
#define buf_block_hash_get_s_locked(b, s, o, l)   buf_block_hash_get_locked(b, s, o, l, RW_LOCK_SHARED)
#define buf_block_hash_get_x_locked(b, s, o, l)   buf_block_hash_get_locked(b, s, o, l, RW_LOCK_EX)
#define buf_block_hash_get(b, s, o)   buf_block_hash_get_locked(b, s, o, NULL, 0)
#define BUF_PAGE_STATE_BITS   3
#define buf_block_state_valid(block)
Modes for buf_page_get_gen
#define BUF_GET   10
#define BUF_GET_IF_IN_POOL   11
#define BUF_PEEK_IF_IN_POOL   12
#define BUF_GET_NO_LATCH   14
#define BUF_GET_IF_IN_POOL_OR_WATCH   15
#define BUF_GET_POSSIBLY_FREED   16
Modes for buf_page_get_known_nowait
#define BUF_MAKE_YOUNG   51
#define BUF_KEEP_OLD   52
#define BUF_POOL_ZIP_FOLD_PTR(ptr)   ((ulint) (ptr) / UNIV_PAGE_SIZE)
#define BUF_POOL_ZIP_FOLD(b)   BUF_POOL_ZIP_FOLD_PTR((b)->frame)
#define BUF_POOL_ZIP_FOLD_BPAGE(b)   BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
Accessors for buf_pool->mutex.

Use these instead of accessing buf_pool->mutex directly.

#define buf_pool_mutex_own(b)   mutex_own(&b->mutex)
#define buf_pool_mutex_enter(b)
#define buf_flush_list_mutex_own(b)   mutex_own(&b->flush_list_mutex)
#define buf_flush_list_mutex_enter(b)
#define buf_flush_list_mutex_exit(b)
#define buf_block_mutex_own(b)   mutex_own(&(b)->mutex)
#define buf_block_mutex_enter(b)
#define buf_block_mutex_exit(b)
#define buf_page_hash_lock_get(b, f)   hash_get_lock(b->page_hash, f)
#define buf_page_hash_lock_held_s(b, p)
#define buf_page_hash_lock_held_x(b, p)
#define buf_page_hash_lock_held_s_or_x(b, p)
#define buf_block_hash_lock_held_s(b, p)   buf_page_hash_lock_held_s(b, &(p->page))
#define buf_block_hash_lock_held_x(b, p)   buf_page_hash_lock_held_x(b, &(p->page))
#define buf_block_hash_lock_held_s_or_x(b, p)   buf_page_hash_lock_held_s_or_x(b, &(p->page))
#define buf_pool_mutex_exit_forbid(b)
#define buf_pool_mutex_exit_allow(b)
#define buf_pool_mutex_exit(b)

Enumerations

enum  buf_page_state {
  BUF_BLOCK_POOL_WATCH, BUF_BLOCK_ZIP_PAGE, BUF_BLOCK_ZIP_DIRTY, BUF_BLOCK_NOT_USED,
  BUF_BLOCK_READY_FOR_USE, BUF_BLOCK_FILE_PAGE, BUF_BLOCK_MEMORY, BUF_BLOCK_REMOVE_HASH
}
 States of a control block. More...
enum  buf_page_print_flags { BUF_PAGE_PRINT_NO_CRASH = 1, BUF_PAGE_PRINT_NO_FULL = 2 }

Functions

UNIV_INLINE void buf_pool_mutex_enter_all (void)
UNIV_INLINE void buf_pool_mutex_exit_all (void)
UNIV_INTERN dberr_t buf_pool_init (ulint 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_INLINE ulint buf_pool_get_curr_size (void)
UNIV_INLINE ulint buf_pool_get_n_pages (void)
UNIV_INTERN lsn_t buf_pool_get_oldest_modification (void)
UNIV_INLINE buf_page_tbuf_page_alloc_descriptor (void))
UNIV_INLINE void buf_page_free_descriptor (buf_page_t *bpage))
UNIV_INTERN buf_block_tbuf_block_alloc (buf_pool_t *buf_pool)
UNIV_INLINE void buf_block_free (buf_block_t *block)
UNIV_INLINE byte * buf_frame_copy (byte *buf, const buf_frame_t *frame)
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_INTERN buf_page_tbuf_page_get_zip (ulint space, ulint zip_size, ulint offset)
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 buf_block_tbuf_page_create (ulint space, ulint offset, ulint zip_size, mtr_t *mtr)
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_INTERN void buf_page_make_young (buf_page_t *bpage)
UNIV_INLINE ibool buf_page_peek (ulint space, ulint offset)
UNIV_INTERN buf_page_tbuf_page_set_file_page_was_freed (ulint space, ulint offset)
UNIV_INTERN buf_page_tbuf_page_reset_file_page_was_freed (ulint space, ulint offset)
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 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_buf_fix_inc_func (const char *file, ulint line, buf_block_t *block))
UNIV_INLINE void buf_block_fix (buf_block_t *block)
UNIV_INLINE void buf_block_unfix (buf_block_t *block)
UNIV_INTERN ibool buf_page_is_corrupted (bool check_lsn, const byte *read_buf, ulint zip_size))
bool buf_page_is_zeroes (const byte *read_buf, const ulint zip_size)
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_INTERN buf_block_tbuf_pool_contains_zip (buf_pool_t *buf_pool, const void *data)
UNIV_INLINE buf_frame_tbuf_frame_align (byte *ptr)
UNIV_INTERN ibool buf_validate (void)
UNIV_INTERN void buf_print (void)
UNIV_INTERN void buf_page_print (const byte *read_buf, ulint zip_size, ulint flags) UNIV_COLD)
UNIV_INTERN ibool buf_zip_decompress (buf_block_t *block, ibool check)
UNIV_INTERN ulint buf_get_latched_pages_number (void)
UNIV_INTERN ulint buf_get_n_pending_read_ios (void)
UNIV_INTERN void buf_print_io (FILE *file)
UNIV_INTERN void buf_stats_get_pool_info (buf_pool_t *buf_pool, ulint pool_id, buf_pool_info_t *all_pool_info)
UNIV_INTERN ulint buf_get_modified_ratio_pct (void)
UNIV_INTERN void buf_refresh_io_stats (buf_pool_t *buf_pool)
UNIV_INTERN void buf_refresh_io_stats_all (void)
UNIV_INTERN ibool buf_all_freed (void)
UNIV_INTERN ulint buf_pool_check_no_pending_io (void)
UNIV_INTERN void buf_pool_invalidate (void)
UNIV_INLINE void buf_block_dbg_add_level (buf_block_t *block, ulint level)
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 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_INTERN buf_block_tbuf_block_align (const byte *ptr)
UNIV_INTERN ibool buf_pointer_is_block_field (const void *ptr)
UNIV_INLINE const page_zip_des_tbuf_frame_get_page_zip (const byte *ptr)
UNIV_INTERN buf_page_tbuf_page_init_for_read (dberr_t *err, ulint mode, ulint space, ulint zip_size, ibool unzip, ib_int64_t tablespace_version, ulint offset)
UNIV_INTERN bool buf_page_io_complete (buf_page_t *bpage)
UNIV_INLINE ulint buf_page_address_fold (ulint space, ulint offset))
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 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=false)
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_INTERN ulint buf_get_free_list_len (void)
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_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_INLINE buf_block_tbuf_get_nth_chunk_block (const buf_pool_t *buf_pool, ulint n, ulint *chunk_size)
UNIV_INTERN void buf_flush_update_zip_checksum (buf_frame_t *page, ulint zip_size, lsn_t lsn)

Variables

buf_pool_tbuf_pool_ptr
ibool buf_debug_prints
ulint srv_buf_pool_instances
ulint srv_buf_pool_curr_size

Detailed Description

The database buffer pool high-level routines

Created 11/5/1995 Heikki Tuuri

Macro Definition Documentation

#define buf_block_buf_fix_inc (   b,
  f,
 
)    buf_block_buf_fix_inc_func(f,l,b)
Increments the bufferfix count.
Parameters
bin/out: block to bufferfix
fin: file name where requested
lin: line number where requested
#define buf_block_get_page_zip (   block)    ((block)->page.zip.data ? &(block)->page.zip : NULL)

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

#define buf_block_mutex_enter (   b)
Value:
do { \
mutex_enter(&(b)->mutex); \
} while (0)

Acquire the block->mutex.

#define buf_block_mutex_exit (   b)
Value:
do { \
mutex_exit(&(b)->mutex); \
} while (0)

Release the trx->mutex.

#define buf_block_mutex_own (   b)    mutex_own(&(b)->mutex)

Test if block->mutex is owned.

#define buf_block_state_valid (   block)
Value:
Check if a buf_block_t object is in a valid state
Parameters
blockbuffer block
Returns
TRUE if valid
#define buf_flush_list_mutex_enter (   b)
Value:
do { \
mutex_enter(&b->flush_list_mutex); \
} while (0)

Acquire the flush list mutex.

#define buf_flush_list_mutex_exit (   b)
Value:
do { \
mutex_exit(&b->flush_list_mutex); \
} while (0)

Release the flush list mutex.

#define buf_flush_list_mutex_own (   b)    mutex_own(&b->flush_list_mutex)

Test if flush list mutex is owned.

#define BUF_GET   10

get always

#define BUF_GET_IF_IN_POOL   11

get if in pool

#define BUF_GET_IF_IN_POOL_OR_WATCH   15

Get the page only if it's in the buffer pool, if not then set a watch on the page.

#define BUF_GET_NO_LATCH   14

get and bufferfix, but set no latch; we have separated this case, because it is error-prone programming not to set a latch, and it should be used with care

#define BUF_GET_POSSIBLY_FREED   16

Like BUF_GET, but do not mind if the file page has been freed.

#define BUF_KEEP_OLD   52

Preserve the current LRU position of the block.

#define BUF_MAKE_YOUNG   51

Move the block to the start of the LRU list if there is a danger that the block would drift out of the buffer pool

#define BUF_NO_CHECKSUM_MAGIC   0xDEADBEEFUL

Magic value to use instead of checksums when they are disabled

#define buf_page_get (   SP,
  ZS,
  OF,
  LA,
  MTR 
)
Value:
SP, ZS, OF, LA, NULL,\
BUF_GET, __FILE__, __LINE__, MTR)

NOTE! The following macros should be used instead of buf_page_get_gen, to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed in LA!

#define buf_page_get_with_no_latch (   SP,
  ZS,
  OF,
  MTR 
)
Value:
SP, ZS, OF, RW_NO_LATCH, NULL,\
BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)

Use these macros to bufferfix a page with no latching. Remember not to read the contents of the page unless you know it is safe. Do not modify the contents of the page! We have separated this case, because it is error-prone programming not to set a latch, and it should be used with care.

#define buf_page_hash_lock_get (   b,
 
)    hash_get_lock(b->page_hash, f)

Get appropriate page_hash_lock.

#define buf_page_hash_lock_held_s (   b,
 
)
Value:
p->offset)), \
RW_LOCK_SHARED)

Test if page_hash lock is held in s-mode.

#define buf_page_hash_lock_held_s_or_x (   b,
 
)
Value:

Test if page_hash lock is held in x or s-mode.

#define buf_page_hash_lock_held_x (   b,
 
)
Value:
p->offset)), \
RW_LOCK_EX)

Test if page_hash lock is held in x-mode.

#define BUF_PAGE_STATE_BITS   3
The common buffer control block structure

for compressed and uncompressed frames Number of bits used for buffer page states.

#define buf_page_try_get (   space_id,
  page_no,
  mtr 
)    buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
Tries to get a page. If the page is not in the buffer pool it is

not loaded. Suitable for using when holding the lock_sys_t::mutex.

Parameters
space_idin: tablespace id
page_noin: page number
mtrin: mini-transaction
Returns
the page if in buffer pool, NULL if not
#define BUF_PEEK_IF_IN_POOL   12

get if in pool, do not make the block young in the LRU list

#define buf_pool_is_block_lock (   l)    buf_pointer_is_block_field((const void*)(l))
Find out if a pointer corresponds to a buf_block_t::lock.
Parameters
lin: rw-lock candidate
Returns
TRUE if l is a buf_block_t::lock
#define buf_pool_is_block_mutex (   m)    buf_pointer_is_block_field((const void*)(m))
Find out if a pointer corresponds to a buf_block_t::mutex.
Parameters
min: mutex candidate
Returns
TRUE if m is a buf_block_t::mutex
#define buf_pool_mutex_enter (   b)
Value:
do { \
ut_ad(!mutex_own(&b->zip_mutex)); \
mutex_enter(&b->mutex); \
} while (0)

Acquire a buffer pool mutex.

#define buf_pool_mutex_exit (   b)
Value:
do { \
ut_a(!b->mutex_exit_forbidden); \
mutex_exit(&b->mutex); \
} while (0)

Release the buffer pool mutex.

#define buf_pool_mutex_exit_allow (   b)
Value:
do { \
ut_ad(buf_pool_mutex_own(b)); \
ut_a(b->mutex_exit_forbidden); \
b->mutex_exit_forbidden--; \
} while (0)

Allow the release of the buffer pool mutex.

#define buf_pool_mutex_exit_forbid (   b)
Value:
do { \
ut_ad(buf_pool_mutex_own(b)); \
b->mutex_exit_forbidden++; \
} while (0)

Forbid the release of the buffer pool mutex.

#define buf_pool_mutex_own (   b)    mutex_own(&b->mutex)

Test if a buffer pool mutex is owned.

#define BUF_POOL_WATCH_SIZE   (srv_n_purge_threads + 1)

Maximum number of concurrent buffer pool watches

#define BUF_POOL_ZIP_FOLD_PTR (   ptr)    ((ulint) (ptr) / UNIV_PAGE_SIZE)

Compute the hash fold value for blocks in buf_pool->zip_hash.

#define MAX_BUFFER_POOLS   (1 << MAX_BUFFER_POOLS_BITS)

The maximum number of buffer pools that can be defined

#define MAX_BUFFER_POOLS_BITS   6

Number of bits to representing a buffer pool ID

#define MAX_PAGE_HASH_LOCKS   1024

The maximum number of page_hash locks

Enumeration Type Documentation

Enumerator:
BUF_PAGE_PRINT_NO_CRASH 

Do not crash at the end of buf_page_print().

BUF_PAGE_PRINT_NO_FULL 

Do not print the full page dump.

States of a control block.

See Also
buf_page_t

The enumeration values must be 0..7.

Enumerator:
BUF_BLOCK_POOL_WATCH 

a sentinel for the buffer pool watch, element of buf_pool->watch[]

BUF_BLOCK_ZIP_PAGE 

contains a clean compressed page

BUF_BLOCK_ZIP_DIRTY 

contains a compressed page that is in the buf_pool->flush_list

BUF_BLOCK_NOT_USED 

is in the free list; must be after the BUF_BLOCK_ZIP_ constants for compressed-only pages

See Also
buf_block_state_valid()
BUF_BLOCK_READY_FOR_USE 

when buf_LRU_get_free_block returns a block, it is in this state

BUF_BLOCK_FILE_PAGE 

contains a buffered file page

BUF_BLOCK_MEMORY 

contains some main memory object

BUF_BLOCK_REMOVE_HASH 

hash index should be removed before putting to the free list

Function Documentation

UNIV_INTERN ibool buf_all_freed ( void  )

Asserts that all file pages in the buffer are in a replaceable state.

Returns
TRUE
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 in: pointer to a frame
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 in: buffer pool instance, or NULL for round-robin selection of the buffer pool
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. in: latching order 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. in/out: block to bufferfix

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. in, own: block to be freed

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 a block. This can be used in searches in the lock hash table.

Returns
lock hash value

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 in: 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 in: RW_LOCK_EX or RW_LOCK_SHARED. Ignored if lock == NULL

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. in: 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. in: page number

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. in: io_fix state

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. in: 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)

Increments the bufferfix count. in/out: block to bufferfix

Decrements the bufferfix count.

Parameters
blockin/out: block to bufferunfix
UNIV_INTERN void buf_flush_update_zip_checksum ( buf_frame_t page,
ulint  zip_size,
lsn_t  lsn 
)

Calculate the checksum of a page from compressed table and update the page. in: Lsn to stamp on the page

Parameters
pagein/out: Page to update
zip_sizein: Compressed page size
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 in: buffer 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 in: pointer to the page

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_INTERN ulint buf_get_free_list_len ( void  )

Gets the current length of the free list of buffer blocks.

Returns
length of the free list
UNIV_INTERN ulint buf_get_latched_pages_number ( void  )

Returns the number of latched pages in the buffer pool.

Returns
number of latched pages
UNIV_INTERN ulint buf_get_modified_ratio_pct ( void  )

Returns the ratio in percents of modified pages in the buffer pool / database pages in the buffer pool.

Returns
modified page percentage ratio
UNIV_INTERN ulint buf_get_n_pending_read_ios ( void  )

Returns the number of pending buf pool read ios.

Returns
number of pending read I/O operations
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. in: 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_INTERN void buf_get_total_list_len ( ulint *  LRU_len,
ulint *  free_len,
ulint *  flush_list_len 
)

Get total buffer pool statistics. out: length of all flush lists

Parameters
LRU_lenout: length of all LRU lists
free_lenout: length of all free lists
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. out: list sizes in all buffer pools

UNIV_INTERN void buf_get_total_stat ( buf_pool_stat_t tot_stat)

Get total buffer pool statistics. out: buffer pool stats

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.

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_INTERN buf_block_t* buf_page_create ( ulint  space,
ulint  offset,
ulint  zip_size,
mtr_t mtr 
)

Initializes a page to the buffer buf_pool. The page is usually not read from a file even if it cannot be found in the buffer buf_pool. This is one of the functions which perform to a block a state transition NOT_USED => FILE_PAGE (the other is buf_page_get_gen).

Returns
pointer to the block, page bufferfixed in: mini-transaction handle
Parameters
spacein: space id
offsetin: offset of the page within space in units of a page
zip_sizein: compressed page size, or 0
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. Note: even though bpage is not declared a const we don't update its value. It is safe to make this pure.

Returns
control block, or NULL

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_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 in: mini-transaction
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
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_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.

Returns
TRUE if success in: mini-transaction
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
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 in: block containing the page frame

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 in: pointer to the control block

Gets the state of a block.

Returns
state
Parameters
bpagein: pointer to the control block
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, or NULL if not compressed in: page number
Parameters
spacein: space id
zip_sizein: compressed page size
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) in: if true, return watch sentinel also.

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 in: buf_page_address_fold(space, offset)

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_INTERN buf_page_t* buf_page_init_for_read ( dberr_t err,
ulint  mode,
ulint  space,
ulint  zip_size,
ibool  unzip,
ib_int64_t  tablespace_version,
ulint  offset 
)

Function which inits a page for read to the buffer buf_pool. If the page is (1) already in buf_pool, or (2) if we specify to read only ibuf pages and the page is not an ibuf page, or (3) if the space is deleted or being deleted, then this function does nothing. Sets the io_fix flag to BUF_IO_READ and sets a non-recursive exclusive lock on the buffer frame. The io-handler must take care that the flag is cleared and the lock released later.

Returns
pointer to the block or NULL in: page number
Parameters
errout: DB_SUCCESS or DB_TABLESPACE_DELETED
modein: BUF_READ_IBUF_PAGES_ONLY, ...
spacein: space id
zip_sizein: compressed page size, or 0
unzipin: TRUE=request uncompressed page
tablespace_versionin: prevents reading from a wrong version of the tablespace in case we have done DISCARD + IMPORT
UNIV_INTERN bool buf_page_io_complete ( buf_page_t bpage)

Completes an asynchronous read or write request of a file page to or from the buffer pool.

Returns
true if successful in: pointer to the block in question
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_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 the and complain about the LSN
read_bufin: a database page
zip_sizein: size of compressed page; 0 for uncompressed pages
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
bool buf_page_is_zeroes ( const byte *  read_buf,
const ulint  zip_size 
)

Checks if a page is all zeroes.

Returns
TRUE if the page is all zeroes in: size of compressed page; 0 for uncompressed pages
Parameters
read_bufin: a database page
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. in: buffer block of a file page

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 in: mini-transaction
Parameters
rw_latchin: RW_S_LATCH, RW_X_LATCH
blockin: guessed block
modify_clockin: modify clock value
filein: file name
linein: line where called
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 in: page number

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 in: block to make younger

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 in: block

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_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
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. in: RW_S_LATCH, RW_X_LATCH, RW_NO_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(). in: buffer block

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

Parameters
bpagein: buffer block
UNIV_INTERN buf_page_t* buf_page_reset_file_page_was_freed ( ulint  space,
ulint  offset 
)

Sets file_page_was_freed FALSE if the page is found in the buffer pool. This function should be called when we free a file page and want the debug version to check that it is not accessed any more unless reallocated.

Returns
control block if found in page hash table, otherwise NULL in: page number
Parameters
spacein: space id
UNIV_INLINE void buf_page_set_accessed ( buf_page_t bpage)

Flag a block accessed.

Parameters
bpagein/out: control block
UNIV_INTERN buf_page_t* buf_page_set_file_page_was_freed ( ulint  space,
ulint  offset 
)

Sets file_page_was_freed TRUE if the page is found in the buffer pool. This function should be called when we free a file page and want the debug version to check that it is not accessed any more unless reallocated.

Returns
control block if found in page hash table, otherwise NULL in: page number
Parameters
spacein: space id
UNIV_INLINE void buf_page_set_flush_type ( buf_page_t bpage,
buf_flush_t  flush_type 
)

Set the flush type of a page. in: 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. in: io_fix state

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. in: 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. in: 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. in/out: control block

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_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. in: mini-transaction

Parameters
space_idin: tablespace id
page_noin: page number
filein: file name
linein: line where called
UNIV_INLINE void buf_page_unset_sticky ( buf_page_t bpage)

Removes stickiness of a block. in/out: control block

Removes stickiness of a block.

Parameters
bpagein/out: control block
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 in: pointer not dereferenced
UNIV_INTERN ulint buf_pool_check_no_pending_io ( void  )

Checks that there currently are no pending i/o-operations for the buffer pool.

Returns
number of pending i/o operations
UNIV_INTERN void buf_pool_clear_hash_index ( void  )

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

UNIV_INTERN buf_block_t* buf_pool_contains_zip ( buf_pool_t buf_pool,
const void *  data 
)

Finds a block in the buffer pool that points to a given compressed page.

Returns
buffer block pointing to the compressed page, or NULL in: pointer to compressed page
Parameters
buf_poolin: buffer pool instance
UNIV_INTERN void buf_pool_free ( ulint  n_instances)

Frees the buffer pool at shutdown. This must not be invoked before freeing all mutexes. in: numbere of instances to free

UNIV_INLINE buf_pool_t* buf_pool_from_array ( ulint  index)

Returns the buffer pool instance given its array index

Returns
buffer pool in: array index to get buffer pool instance from

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 in: 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 in: buffer pool page

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 in: offset of the page within space

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

Returns
size in pages

Gets the current size of buffer buf_pool in pages.

Returns
size in pages
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
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_INTERN dberr_t buf_pool_init ( ulint  size,
ulint  n_instances 
)

Creates the buffer pool.

Returns
DB_SUCCESS if success, DB_ERROR if not enough memory or error in: Number of instances
Parameters
sizein: Size of the total pool in bytes
UNIV_INTERN void buf_pool_invalidate ( void  )

Invalidates the file pages in the buffer pool when an archive recovery is completed. All the file pages buffered must be in a replaceable state when this function is called: not latched and not modified.

UNIV_INLINE void buf_pool_mutex_enter_all ( void  )

Acquire mutex on all buffer pool instances

Acquire mutex on all buffer pool instances.

UNIV_INLINE void buf_pool_mutex_exit_all ( void  )

Release mutex on all buffer pool instances

Release mutex on all buffer pool instances.

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
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
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 the buffer pool

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)
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. in: page number

Parameters
spacein: space id
UNIV_INTERN void buf_print ( void  )

Prints info of the buffer pool data structure.

UNIV_INTERN void buf_print_io ( FILE *  file)

Prints info of the buffer i/o. in: file where to print

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. out: page offset and byte offset

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
UNIV_INTERN void buf_refresh_io_stats ( buf_pool_t buf_pool)

Refreshes the statistics used to print per-second averages. buffer pool instance

UNIV_INTERN void buf_refresh_io_stats_all ( void  )

Refreshes the statistics used to print per-second averages.

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
UNIV_INTERN void buf_stats_get_pool_info ( buf_pool_t buf_pool,
ulint  pool_id,
buf_pool_info_t all_pool_info 
)

Collect buffer pool stats information for a buffer pool. Also record aggregated stats if there are more than one buffer pool in the server in/out: buffer pool info to fill

Parameters
buf_poolin: buffer pool
pool_idin: buffer pool ID
UNIV_INTERN ibool buf_validate ( void  )

Validates the buffer pool data structure.

Returns
TRUE
UNIV_INTERN ibool buf_zip_decompress ( buf_block_t block,
ibool  check 
)

Decompress a block.

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

Variable Documentation

ibool buf_debug_prints

If this is set TRUE, the program prints info whenever read or flush occurs

buf_pool_t* buf_pool_ptr

The buffer pools of the database