diff options
Diffstat (limited to 'storage/innobase/include/buf0flu.h')
-rw-r--r-- | storage/innobase/include/buf0flu.h | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index c772f84147d..13a9363922b 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -24,21 +24,20 @@ The database buffer pool flush algorithm Created 11/5/1995 Heikki Tuuri *******************************************************/ -#ifndef buf0flu_h -#define buf0flu_h +#pragma once #include "ut0byte.h" #include "log0log.h" -#include "buf0types.h" +#include "buf0buf.h" -/** Number of pages flushed. Protected by buf_pool.mutex. */ -extern ulint buf_flush_page_count; /** Number of pages flushed via LRU. Protected by buf_pool.mutex. -Also included in buf_flush_page_count. */ +Also included in buf_pool.stat.n_pages_written. */ extern ulint buf_lru_flush_page_count; +/** Number of pages freed without flushing. Protected by buf_pool.mutex. */ +extern ulint buf_lru_freed_page_count; /** Flag indicating if the page_cleaner is in active state. */ -extern bool buf_page_cleaner_is_active; +extern Atomic_relaxed<bool> buf_page_cleaner_is_active; /** Remove all dirty pages belonging to a given tablespace when we are deleting the data file of that tablespace. @@ -85,15 +84,18 @@ buf_flush_init_for_writing( bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed= nullptr) MY_ATTRIBUTE((warn_unused_result)); -/** Write out dirty blocks from buf_pool.LRU. +/** Write out dirty blocks from buf_pool.LRU, +and move clean blocks to buf_pool.free. +The caller must invoke buf_dblwr.flush_buffered_writes() +after releasing buf_pool.mutex. @param max_n wished maximum mumber of blocks flushed -@return the number of processed pages +@param evict whether to evict pages after flushing +@return evict ? number of processed pages : number of pages written @retval 0 if a buf_pool.LRU batch is already running */ -ulint buf_flush_LRU(ulint max_n); +ulint buf_flush_LRU(ulint max_n, bool evict); -/** Wait until a flush batch ends. -@param lru true=buf_pool.LRU; false=buf_pool.flush_list */ -void buf_flush_wait_batch_end(bool lru); +/** Wait until a LRU flush batch ends. */ +void buf_flush_wait_LRU_batch_end(); /** Wait until all persistent pages are flushed up to a limit. @param sync_lsn buf_pool.get_oldest_modification(LSN_MAX) to wait for */ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn); @@ -106,22 +108,30 @@ ATTRIBUTE_COLD void buf_flush_ahead(lsn_t lsn, bool furious); 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. */ -UNIV_INLINE -void -buf_flush_note_modification( -/*========================*/ - buf_block_t* block, /*!< in: block which is modified */ - lsn_t start_lsn, /*!< in: start lsn of the first mtr in a - set of mtr's */ - lsn_t end_lsn); /*!< in: end lsn of the last mtr in the - set of mtr's */ +inline void buf_flush_note_modification(buf_block_t *b, lsn_t start, lsn_t end) +{ + ut_ad(!srv_read_only_mode); + ut_d(const auto s= b->page.state()); + ut_ad(s > buf_page_t::FREED); + ut_ad(s < buf_page_t::READ_FIX); + ut_ad(mach_read_from_8(b->page.frame + FIL_PAGE_LSN) <= end); + mach_write_to_8(b->page.frame + FIL_PAGE_LSN, end); + if (UNIV_LIKELY_NULL(b->page.zip.data)) + memcpy_aligned<8>(FIL_PAGE_LSN + b->page.zip.data, + FIL_PAGE_LSN + b->page.frame, 8); + + const lsn_t oldest_modification= b->page.oldest_modification(); + + if (oldest_modification > 1) + ut_ad(oldest_modification <= start); + else + buf_pool.insert_into_flush_list(b, start); + srv_stats.buf_pool_write_requests.inc(); +} /** Initialize page_cleaner. */ ATTRIBUTE_COLD void buf_flush_page_cleaner_init(); -/** Wait for pending flushes to complete. */ -void buf_flush_wait_batch_end_acquiring_mutex(bool lru); - /** Flush the buffer pool on shutdown. */ ATTRIBUTE_COLD void buf_flush_buffer_pool(); @@ -137,7 +147,3 @@ void buf_flush_sync_batch(lsn_t lsn); /** Synchronously flush dirty blocks. NOTE: The calling thread is not allowed to hold any buffer page latches! */ void buf_flush_sync(); - -#include "buf0flu.inl" - -#endif |