#include "univ.i"
#include "ut0byte.h"
#include "mtr0types.h"
#include "buf0types.h"
#include "log0log.h"
Go to the source code of this file.
Classes | |
struct | buf_flush_stat_struct |
Statistics for selecting flush rate based on redo log generation speed. More... | |
Macros | |
#define | buf0flu_h |
#define | BUF_FLUSH_FREE_BLOCK_MARGIN(b) (5 + BUF_READ_AHEAD_AREA(b)) |
#define | BUF_FLUSH_EXTRA_MARGIN(b) |
Typedefs | |
typedef struct buf_flush_stat_struct | buf_flush_stat_t |
Functions | |
UNIV_INTERN void | buf_flush_remove (buf_page_t *bpage) |
UNIV_INTERN void | buf_flush_relocate_on_flush_list (buf_page_t *bpage, buf_page_t *dpage) |
UNIV_INTERN void | buf_flush_write_complete (buf_page_t *bpage) |
UNIV_INTERN void | buf_flush_free_margin (buf_pool_t *buf_pool) |
UNIV_INTERN void | buf_flush_free_margins (void) |
UNIV_INTERN void | buf_flush_init_for_writing (byte *page, void *page_zip_, ib_uint64_t newest_lsn) |
UNIV_INTERN ulint | buf_flush_LRU (buf_pool_t *buf_pool, ulint min_n) |
UNIV_INTERN ulint | buf_flush_list (ulint min_n, ib_uint64_t lsn_limit) |
UNIV_INTERN void | buf_flush_wait_batch_end (buf_pool_t *buf_pool, enum buf_flush type) |
UNIV_INLINE void | buf_flush_note_modification (buf_block_t *block, mtr_t *mtr) |
UNIV_INLINE void | buf_flush_recv_note_modification (buf_block_t *block, ib_uint64_t start_lsn, ib_uint64_t end_lsn) |
UNIV_INTERN ibool | buf_flush_ready_for_replace (buf_page_t *bpage) |
UNIV_INTERN void | buf_flush_stat_update (void) |
UNIV_INTERN ulint | buf_flush_get_desired_flush_rate (void) |
UNIV_INTERN void | buf_flush_init_flush_rbt (void) |
UNIV_INTERN void | buf_flush_free_flush_rbt (void) |
The database buffer pool flush algorithm
Created 11/5/1995 Heikki Tuuri
Definition in file buf0flu.h.
#define BUF_FLUSH_EXTRA_MARGIN | ( | b) |
Extra margin to apply above BUF_FLUSH_FREE_BLOCK_MARGIN
#define BUF_FLUSH_FREE_BLOCK_MARGIN | ( | b) | (5 + BUF_READ_AHEAD_AREA(b)) |
typedef struct buf_flush_stat_struct buf_flush_stat_t |
UNIV_INTERN void buf_flush_free_flush_rbt | ( | void | ) |
Frees up the red-black tree.
Definition at line 223 of file buf0flu.cc.
References buf_block_get_zip_size(), buf_flush_list_mutex_enter, buf_flush_list_mutex_exit, buf_pool_from_array(), buf_pool_struct::flush_rbt, rbt_free(), srv_buf_pool_instances, and ut_a.
UNIV_INTERN void buf_flush_free_margin | ( | buf_pool_t * | buf_pool) |
Flushes pages from the end of the LRU list if there is too small a margin of replaceable pages there. If buffer pool is NULL it means flush free margin on all buffer pool instances.
Flushes pages from the end of the LRU list if there is too small a margin of replaceable pages there or in the free list. VERY IMPORTANT: this function is called also by threads which have locks on pages. To avoid deadlocks, we flush only pages such that the s-lock required for flushing can be acquired immediately, without waiting.
buf_pool | in: Buffer pool instance |
Definition at line 2020 of file buf0flu.cc.
References BUF_FLUSH_LRU.
UNIV_INTERN void buf_flush_free_margins | ( | void | ) |
Flushes pages from the end of all the LRU lists.
Definition at line 2046 of file buf0flu.cc.
References buf_pool_from_array(), and srv_buf_pool_instances.
UNIV_INTERN void buf_flush_init_flush_rbt | ( | void | ) |
Initialize the red-black tree to speed up insertions into the flush_list during recovery process. Should be called at the start of recovery process before any page has been read/written.
Definition at line 199 of file buf0flu.cc.
References buf_flush_list_mutex_enter, buf_flush_list_mutex_exit, buf_pool_from_array(), buf_pool_struct::flush_rbt, rbt_create(), and srv_buf_pool_instances.
UNIV_INTERN void buf_flush_init_for_writing | ( | byte * | page, |
void * | page_zip_, | ||
ib_uint64_t | newest_lsn | ||
) |
Initializes a page for writing to the tablespace. in: newest modification lsn to the page
Initializes a page for writing to the tablespace.
page | in/out: page |
page_zip_ | in/out: compressed page, or NULL |
newest_lsn | in: newest modification lsn to the page |
Definition at line 985 of file buf0flu.cc.
References BUF_NO_CHECKSUM_MAGIC, page_zip_des_struct::data, FIL_PAGE_END_LSN_OLD_CHKSUM, FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_IBUF_BITMAP, FIL_PAGE_INDEX, FIL_PAGE_INODE, FIL_PAGE_LSN, FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_TYPE_ALLOCATED, FIL_PAGE_TYPE_FSP_HDR, FIL_PAGE_TYPE_XDES, FIL_PAGE_TYPE_ZBLOB, FIL_PAGE_TYPE_ZBLOB2, mach_write_to_4(), mach_write_to_8(), page_zip_calc_checksum(), page_zip_get_size(), ut_ad, ut_error, ut_is_2pow, ut_print_buf(), and ut_print_timestamp().
UNIV_INTERN ulint buf_flush_list | ( | ulint | min_n, |
ib_uint64_t | lsn_limit | ||
) |
This utility flushes dirty blocks from the end of the flush_list of all buffer pool instances. NOTE: The calling thread is not allowed to own any latches on pages!
This utility flushes dirty blocks from the end of the flush list of all buffer pool instances. NOTE: The calling thread is not allowed to own any latches on pages!
min_n | in: wished minimum mumber of blocks flushed (it is not guaranteed that the actual number is that big, though) |
lsn_limit | in the case BUF_FLUSH_LIST all blocks whose oldest_modification is smaller than this should be flushed (if their number does not exceed min_n), otherwise ignored |
Definition at line 1897 of file buf0flu.cc.
References BUF_FLUSH_LIST, buf_pool_from_array(), and srv_buf_pool_instances.
UNIV_INTERN ulint buf_flush_LRU | ( | buf_pool_t * | buf_pool, |
ulint | min_n | ||
) |
This utility flushes dirty blocks from the end of the LRU list. NOTE: The calling thread may own latches to pages: to avoid deadlocks, this function must be written so that it cannot end up waiting for these latches!
This utility flushes dirty blocks from the end of the LRU list. NOTE: The calling thread may own latches to pages: to avoid deadlocks, this function must be written so that it cannot end up waiting for these latches!
buf_pool | in: buffer pool instance |
min_n | in: wished minimum mumber of blocks flushed (it is not guaranteed that the actual number is that big, though) |
Definition at line 1867 of file buf0flu.cc.
References BUF_FLUSH_LRU.
UNIV_INLINE void buf_flush_note_modification | ( | buf_block_t * | block, |
mtr_t * | mtr | ||
) |
This function should be called at a mini-transaction commit, if a page was modified in it. Puts the block to the list of modified blocks, if it not already in it. in: mtr
block | in: block which is modified |
UNIV_INTERN ibool buf_flush_ready_for_replace | ( | buf_page_t * | bpage) |
Returns TRUE if the file page block is immediately suitable for replacement, i.e., transition FILE_PAGE => NOT_USED allowed.
Returns TRUE if the file page block is immediately suitable for replacement, i.e., the transition FILE_PAGE => NOT_USED allowed.
bpage | in: buffer control block, must be buf_page_in_file(bpage) and in the LRU list |
Definition at line 420 of file buf0flu.cc.
References buf_page_struct::buf_fix_count, BUF_IO_NONE, buf_page_get_io_fix(), buf_page_get_mutex(), buf_page_get_state(), buf_page_in_file(), buf_pool_from_bpage(), buf_pool_mutex_own, buf_page_struct::oldest_modification, ut_ad, ut_print_buf(), and ut_print_timestamp().
UNIV_INLINE void buf_flush_recv_note_modification | ( | buf_block_t * | block, |
ib_uint64_t | start_lsn, | ||
ib_uint64_t | end_lsn | ||
) |
This function should be called when recovery has modified a buffer page. in: end lsn of the last mtr in the set of mtr's
block | in: block which is modified |
start_lsn | in: start lsn of the first mtr in a set of mtr's |
Referenced by recv_recover_page_func().
UNIV_INTERN void buf_flush_relocate_on_flush_list | ( | buf_page_t * | bpage, |
buf_page_t * | dpage | ||
) |
Relocates a buffer control block on the flush_list. Note that it is assumed that the contents of bpage has already been copied to dpage. in/out: destination block
Relocates a buffer control block on the flush_list. Note that it is assumed that the contents of bpage have already been copied to dpage. IMPORTANT: When this function is called bpage and dpage are not exact copies of each other. For example, they both will have different ::state. Also the ::list pointers in dpage may be stale. We need to use the current list node (bpage) to do the list manipulation because the list pointers could have changed between the time that we copied the contents of bpage to the dpage and the flush list manipulation below.
bpage | in/out: control block being moved |
dpage | in/out: destination block |
Definition at line 557 of file buf0flu.cc.
References buf_flush_list_mutex_enter, buf_flush_list_mutex_exit, buf_page_get_mutex(), buf_pool_from_bpage(), buf_pool_mutex_own, buf_pool_struct::flush_rbt, ut_a, ut_ad, ut_d, UT_LIST_ADD_FIRST, UT_LIST_GET_PREV, UT_LIST_INSERT_AFTER, and UT_LIST_REMOVE.
UNIV_INTERN void buf_flush_remove | ( | buf_page_t * | bpage) |
Remove a block from the flush list of modified blocks. in: pointer to the block in question
Remove a block from the flush list of modified blocks.
bpage | in: pointer to the block in question |
Definition at line 494 of file buf0flu.cc.
References BUF_BLOCK_FILE_PAGE, BUF_BLOCK_MEMORY, BUF_BLOCK_NOT_USED, BUF_BLOCK_READY_FOR_USE, BUF_BLOCK_REMOVE_HASH, BUF_BLOCK_ZIP_DIRTY, BUF_BLOCK_ZIP_FREE, BUF_BLOCK_ZIP_PAGE, buf_flush_list_mutex_enter, buf_flush_list_mutex_exit, buf_page_get_mutex(), buf_page_get_state(), buf_page_set_state(), buf_pool_from_bpage(), buf_pool_mutex_own, buf_pool_struct::flush_rbt, buf_page_struct::oldest_modification, ut_a, ut_ad, ut_d, ut_error, and UT_LIST_REMOVE.
UNIV_INTERN void buf_flush_wait_batch_end | ( | buf_pool_t * | buf_pool, |
enum buf_flush | type | ||
) |
Waits until a flush batch of the given type ends in: BUF_FLUSH_LRU or BUF_FLUSH_LIST
Waits until a flush batch of the given type ends
buf_pool | buffer pool instance |
type | in: BUF_FLUSH_LRU or BUF_FLUSH_LIST |
Definition at line 1837 of file buf0flu.cc.
References BUF_FLUSH_LIST, BUF_FLUSH_LRU, buf_pool_from_array(), buf_pool_struct::no_flush, srv_buf_pool_instances, and ut_ad.
UNIV_INTERN void buf_flush_write_complete | ( | buf_page_t * | bpage) |
Updates the flush system data structures when a write is completed. in: pointer to the block in question
Updates the flush system data structures when a write is completed.
bpage | in: pointer to the block in question |
Definition at line 626 of file buf0flu.cc.
References BUF_FLUSH_LRU, buf_page_get_flush_type(), buf_pool_from_bpage(), buf_pool_struct::init_flush, buf_pool_struct::LRU_flush_ended, buf_pool_struct::n_flush, buf_pool_struct::no_flush, os_event_set(), and ut_ad.