summaryrefslogtreecommitdiff
path: root/storage/innobase/include/buf0buf.h
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2016-08-12 11:17:45 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2016-09-02 13:22:28 +0300
commit2e814d4702d71a04388386a9f591d14a35980bfe (patch)
treef3f9b48d116a3738c5e71f3a360ca61f16cfb632 /storage/innobase/include/buf0buf.h
parent848d211c5c4df00b819cd84d7530cf7d29bb0524 (diff)
downloadmariadb-git-2e814d4702d71a04388386a9f591d14a35980bfe.tar.gz
Merge InnoDB 5.7 from mysql-5.7.9.
Contains also MDEV-10547: Test multi_update_innodb fails with InnoDB 5.7 The failure happened because 5.7 has changed the signature of the bool handler::primary_key_is_clustered() const virtual function ("const" was added). InnoDB was using the old signature which caused the function not to be used. MDEV-10550: Parallel replication lock waits/deadlock handling does not work with InnoDB 5.7 Fixed mutexing problem on lock_trx_handle_wait. Note that rpl_parallel and rpl_optimistic_parallel tests still fail. MDEV-10156 : Group commit tests fail on 10.2 InnoDB (branch bb-10.2-jan) Reason: incorrect merge MDEV-10550: Parallel replication can't sync with master in InnoDB 5.7 (branch bb-10.2-jan) Reason: incorrect merge
Diffstat (limited to 'storage/innobase/include/buf0buf.h')
-rw-r--r--storage/innobase/include/buf0buf.h1202
1 files changed, 670 insertions, 532 deletions
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index c737f3a6f1d..6e147ce95c5 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -31,6 +31,7 @@ Created 11/5/1995 Heikki Tuuri
#include "fil0fil.h"
#include "mtr0types.h"
#include "buf0types.h"
+#ifndef UNIV_INNOCHECKSUM
#include "hash0hash.h"
#include "ut0byte.h"
#include "page0types.h"
@@ -38,6 +39,11 @@ Created 11/5/1995 Heikki Tuuri
#include "ut0rbt.h"
#include "os0proc.h"
#include "log0log.h"
+#include "srv0srv.h"
+#include <ostream>
+
+// Forward declaration
+struct fil_addr_t;
/** @name Modes for buf_page_get_gen */
/* @{ */
@@ -85,18 +91,25 @@ Created 11/5/1995 Heikki Tuuri
extern buf_pool_t* buf_pool_ptr; /*!< The buffer pools
of the database */
+
+extern volatile bool buf_pool_withdrawing; /*!< true when withdrawing buffer
+ pool pages might cause page relocation */
+
+extern volatile ulint buf_withdraw_clock; /*!< the clock is incremented
+ every time a pointer to a page may
+ become obsolete */
+
#ifdef UNIV_DEBUG
-extern ibool buf_debug_prints;/*!< If this is set TRUE, the program
- prints info whenever read or flush
- occurs */
+extern my_bool buf_disable_resize_buffer_pool_debug; /*!< if TRUE, resizing
+ buffer pool is not allowed. */
#endif /* UNIV_DEBUG */
-extern ulint srv_buf_pool_instances;
-extern ulint srv_buf_pool_curr_size;
#else /* !UNIV_HOTBACKUP */
extern buf_block_t* back_block1; /*!< first block, for --apply-log */
extern buf_block_t* back_block2; /*!< second block, for page reorganize */
#endif /* !UNIV_HOTBACKUP */
+#endif /* !UNIV_INNOCHECKSUM */
+#ifndef UNIV_INNOCHECKSUM
/** @brief States of a control block
@see buf_page_t
@@ -204,6 +217,127 @@ struct buf_pools_list_size_t {
ulint flush_list_bytes; /*!< flush_list size in bytes */
};
+/** Page identifier. */
+class page_id_t {
+public:
+
+ /** Constructor from (space, page_no).
+ @param[in] space tablespace id
+ @param[in] page_no page number */
+ page_id_t(ulint space, ulint page_no)
+ :
+ m_space(static_cast<ib_uint32_t>(space)),
+ m_page_no(static_cast<ib_uint32_t>(page_no)),
+ m_fold(ULINT_UNDEFINED)
+ {
+ ut_ad(space <= 0xFFFFFFFFU);
+ ut_ad(page_no <= 0xFFFFFFFFU);
+ }
+
+ /** Retrieve the tablespace id.
+ @return tablespace id */
+ inline ib_uint32_t space() const
+ {
+ return(m_space);
+ }
+
+ /** Retrieve the page number.
+ @return page number */
+ inline ib_uint32_t page_no() const
+ {
+ return(m_page_no);
+ }
+
+ /** Retrieve the fold value.
+ @return fold value */
+ inline ulint fold() const
+ {
+ /* Initialize m_fold if it has not been initialized yet. */
+ if (m_fold == ULINT_UNDEFINED) {
+ m_fold = (m_space << 20) + m_space + m_page_no;
+ ut_ad(m_fold != ULINT_UNDEFINED);
+ }
+
+ return(m_fold);
+ }
+
+ /** Copy the values from a given page_id_t object.
+ @param[in] src page id object whose values to fetch */
+ inline void copy_from(const page_id_t& src)
+ {
+ m_space = src.space();
+ m_page_no = src.page_no();
+ m_fold = src.fold();
+ }
+
+ /** Reset the values from a (space, page_no).
+ @param[in] space tablespace id
+ @param[in] page_no page number */
+ inline void reset(ulint space, ulint page_no)
+ {
+ m_space = static_cast<ib_uint32_t>(space);
+ m_page_no = static_cast<ib_uint32_t>(page_no);
+ m_fold = ULINT_UNDEFINED;
+
+ ut_ad(space <= 0xFFFFFFFFU);
+ ut_ad(page_no <= 0xFFFFFFFFU);
+ }
+
+ /** Reset the page number only.
+ @param[in] page_no page number */
+ inline void set_page_no(ulint page_no)
+ {
+ m_page_no = static_cast<ib_uint32_t>(page_no);
+ m_fold = ULINT_UNDEFINED;
+
+ ut_ad(page_no <= 0xFFFFFFFFU);
+ }
+
+ /** Check if a given page_id_t object is equal to the current one.
+ @param[in] a page_id_t object to compare
+ @return true if equal */
+ inline bool equals_to(const page_id_t& a) const
+ {
+ return(a.space() == m_space && a.page_no() == m_page_no);
+ }
+
+private:
+
+ /** Tablespace id. */
+ ib_uint32_t m_space;
+
+ /** Page number. */
+ ib_uint32_t m_page_no;
+
+ /** A fold value derived from m_space and m_page_no,
+ used in hashing. */
+ mutable ulint m_fold;
+
+ /* Disable implicit copying. */
+ void operator=(const page_id_t&);
+
+ /** Declare the overloaded global operator<< as a friend of this
+ class. Refer to the global declaration for further details. Print
+ the given page_id_t object.
+ @param[in,out] out the output stream
+ @param[in] page_id the page_id_t object to be printed
+ @return the output stream */
+ friend
+ std::ostream&
+ operator<<(
+ std::ostream& out,
+ const page_id_t& page_id);
+};
+
+/** Print the given page_id_t object.
+@param[in,out] out the output stream
+@param[in] page_id the page_id_t object to be printed
+@return the output stream */
+std::ostream&
+operator<<(
+ std::ostream& out,
+ const page_id_t& page_id);
+
#ifndef UNIV_HOTBACKUP
/********************************************************************//**
Acquire mutex on all buffer pool instances */
@@ -221,8 +355,7 @@ buf_pool_mutex_exit_all(void);
/********************************************************************//**
Creates the buffer pool.
-@return DB_SUCCESS if success, DB_ERROR if not enough memory or error */
-UNIV_INTERN
+@return DB_SUCCESS if success, DB_ERROR if not enough memory or error */
dberr_t
buf_pool_init(
/*=========*/
@@ -231,42 +364,62 @@ buf_pool_init(
/********************************************************************//**
Frees the buffer pool at shutdown. This must not be invoked before
freeing all mutexes. */
-UNIV_INTERN
void
buf_pool_free(
/*==========*/
ulint n_instances); /*!< in: numbere of instances to free */
+/** Determines if a block is intended to be withdrawn.
+@param[in] buf_pool buffer pool instance
+@param[in] block pointer to control block
+@retval true if will be withdrawn */
+bool
+buf_block_will_withdrawn(
+ buf_pool_t* buf_pool,
+ const buf_block_t* block);
+
+/** Determines if a frame is intended to be withdrawn.
+@param[in] buf_pool buffer pool instance
+@param[in] ptr pointer to a frame
+@retval true if will be withdrawn */
+bool
+buf_frame_will_withdrawn(
+ buf_pool_t* buf_pool,
+ const byte* ptr);
+
+/** Resize the buffer pool based on srv_buf_pool_size from
+srv_buf_pool_old_size. */
+void
+buf_pool_resize();
+
+/** This is the thread for resizing buffer pool. It waits for an event and
+when waked up either performs a resizing and sleeps again.
+@param[in] arg a dummy parameter required by os_thread_create.
+@return this function does not return, calls os_thread_exit()
+*/
+extern "C"
+os_thread_ret_t
+DECLARE_THREAD(buf_resize_thread)(
+/*==============================*/
+ void* arg); /*!< in: a dummy parameter
+ required by os_thread_create */
+
/********************************************************************//**
Clears the adaptive hash index on all pages in the buffer pool. */
-UNIV_INTERN
void
buf_pool_clear_hash_index(void);
/*===========================*/
-/********************************************************************//**
-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. */
-UNIV_INTERN
-void
-buf_relocate(
-/*=========*/
- buf_page_t* bpage, /*!< in/out: control block being relocated;
- buf_page_get_state(bpage) must be
- BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */
- buf_page_t* dpage) /*!< in/out: destination control block */
- MY_ATTRIBUTE((nonnull));
/*********************************************************************//**
Gets the current size of buffer buf_pool in bytes.
-@return size in bytes */
+@return size in bytes */
UNIV_INLINE
ulint
buf_pool_get_curr_size(void);
/*========================*/
/*********************************************************************//**
Gets the current size of buffer buf_pool in frames.
-@return size in pages */
+@return size in pages */
UNIV_INLINE
ulint
buf_pool_get_n_pages(void);
@@ -274,8 +427,7 @@ buf_pool_get_n_pages(void);
/********************************************************************//**
Gets the smallest oldest_modification lsn for any page in the pool. Returns
zero if all modified pages have been flushed to disk.
-@return oldest modification in pool, zero if none */
-UNIV_INTERN
+@return oldest modification in pool, zero if none */
lsn_t
buf_pool_get_oldest_modification(void);
/*==================================*/
@@ -299,8 +451,7 @@ buf_page_free_descriptor(
/********************************************************************//**
Allocates a buffer block.
-@return own: the allocated block, in state BUF_BLOCK_MEMORY */
-UNIV_INTERN
+@return own: the allocated block, in state BUF_BLOCK_MEMORY */
buf_block_t*
buf_block_alloc(
/*============*/
@@ -317,7 +468,7 @@ buf_block_free(
#endif /* !UNIV_HOTBACKUP */
/*********************************************************************//**
Copies contents of a buffer frame to a given buffer.
-@return buf */
+@return buf */
UNIV_INLINE
byte*
buf_frame_copy(
@@ -329,23 +480,21 @@ buf_frame_copy(
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(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
- SP, ZS, OF, LA, NULL,\
- BUF_GET, __FILE__, __LINE__, MTR)
+#define buf_page_get(ID, SIZE, LA, MTR) \
+ buf_page_get_gen(ID, SIZE, LA, NULL, BUF_GET, __FILE__, __LINE__, MTR, NULL)
/**************************************************************//**
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_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
- SP, ZS, OF, RW_NO_LATCH, NULL,\
- BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
+#define buf_page_get_with_no_latch(ID, SIZE, MTR) \
+ buf_page_get_gen(ID, SIZE, RW_NO_LATCH, NULL, BUF_GET_NO_LATCH, \
+ __FILE__, __LINE__, MTR, NULL)
/********************************************************************//**
This is the general function used to get optimistic access to a database
page.
-@return TRUE if success */
-UNIV_INTERN
+@return TRUE if success */
ibool
buf_page_optimistic_get(
/*====================*/
@@ -358,8 +507,7 @@ buf_page_optimistic_get(
/********************************************************************//**
This is used to get access to a known database page, when no waiting can be
done.
-@return TRUE if success */
-UNIV_INTERN
+@return TRUE if success */
ibool
buf_page_get_known_nowait(
/*======================*/
@@ -370,96 +518,98 @@ buf_page_get_known_nowait(
ulint line, /*!< in: line where called */
mtr_t* mtr); /*!< in: mini-transaction */
-/*******************************************************************//**
-Given a tablespace id and page number tries to get that page. If the
+/** 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. */
-UNIV_INTERN
+Suitable for using when holding the lock_sys_t::mutex.
+@param[in] page_id page id
+@param[in] file file name
+@param[in] line line where called
+@param[in] mtr mini-transaction
+@return pointer to a page or NULL */
buf_block_t*
buf_page_try_get_func(
-/*==================*/
- ulint space_id,/*!< in: tablespace id */
- ulint page_no,/*!< in: page number */
- ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH */
- bool possibly_freed, /*!< in: don't mind if page is freed */
- const char* file, /*!< in: file name */
- ulint line, /*!< in: line where called */
- mtr_t* mtr); /*!< in: mini-transaction */
-
-/** 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.
-@param space_id in: tablespace id
-@param page_no in: page number
-@param mtr in: mini-transaction
-@return the page if in buffer pool, NULL if not */
-#define buf_page_try_get(space_id, page_no, mtr) \
- buf_page_try_get_func(space_id, page_no, RW_S_LATCH, false, \
- __FILE__, __LINE__, mtr);
-
-/********************************************************************//**
-Get read access to a compressed page (usually of type
+ const page_id_t& page_id,
+ const char* file,
+ ulint line,
+ mtr_t* 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.
+@param[in] page_id page identifier
+@param[in] mtr mini-transaction
+@return the page if in buffer pool, NULL if not */
+#define buf_page_try_get(page_id, mtr) \
+ buf_page_try_get_func((page_id), __FILE__, __LINE__, mtr);
+
+/** 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.
-@return pointer to the block, or NULL if not compressed */
-UNIV_INTERN
+@param[in] page_id page id
+@param[in] page_size page size
+@return pointer to the block */
buf_page_t*
buf_page_get_zip(
-/*=============*/
- ulint space, /*!< in: space id */
- ulint zip_size,/*!< in: compressed page size */
- ulint offset);/*!< in: page number */
-/********************************************************************//**
-This is the general function used to get access to a database page.
-@return pointer to the block or NULL */
-UNIV_INTERN
+ const page_id_t& page_id,
+ const page_size_t& page_size);
+
+/** This is the general function used to get access to a database page.
+@param[in] page_id page id
+@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH
+@param[in] guess guessed block or NULL
+@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL,
+BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH
+@param[in] file file name
+@param[in] line line where called
+@param[in] mtr mini-transaction
+@param[out] err DB_SUCCESS or error code
+@param[in] dirty_with_no_latch
+ mark page as dirty even if page
+ is being pinned without any latch
+@return pointer to the block or NULL */
buf_block_t*
buf_page_get_gen(
-/*=============*/
- ulint space, /*!< in: space id */
- ulint zip_size,/*!< in: compressed page size in bytes
- or 0 for uncompressed pages */
- ulint offset, /*!< in: page number */
- ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
- buf_block_t* guess, /*!< in: guessed block or NULL */
- ulint mode, /*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
- BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH or
- BUF_GET_IF_IN_POOL_OR_WATCH */
- const char* file, /*!< in: file name */
- ulint line, /*!< in: line where called */
- mtr_t* mtr, /*!< in: mini-transaction */
- dberr_t* err = NULL); /*!< out: error code */
-/********************************************************************//**
-Initializes a page to the buffer buf_pool. The page is usually not read
+ const page_id_t& page_id,
+ const page_size_t& page_size,
+ ulint rw_latch,
+ buf_block_t* guess,
+ ulint mode,
+ const char* file,
+ ulint line,
+ mtr_t* mtr,
+ dberr_t* err,
+ bool dirty_with_no_latch = false);
+
+/** 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).
-@return pointer to the block, page bufferfixed */
-UNIV_INTERN
+@param[in] page_id page id
+@param[in] page_size page size
+@param[in] mtr mini-transaction
+@return pointer to the block, page bufferfixed */
buf_block_t*
buf_page_create(
-/*============*/
- ulint space, /*!< in: space id */
- ulint offset, /*!< in: offset of the page within space in units of
- a page */
- ulint zip_size,/*!< in: compressed page size, or 0 */
- mtr_t* mtr); /*!< in: mini-transaction handle */
+ const page_id_t& page_id,
+ const page_size_t& page_size,
+ mtr_t* mtr);
+
#else /* !UNIV_HOTBACKUP */
-/********************************************************************//**
-Inits a page to the buffer buf_pool, for use in mysqlbackup --restore. */
-UNIV_INTERN
+
+/** Inits a page to the buffer buf_pool, for use in mysqlbackup --restore.
+@param[in] page_id page id
+@param[in] page_size page size
+@param[in,out] block block to init */
void
buf_page_init_for_backup_restore(
-/*=============================*/
- ulint space, /*!< in: space id */
- ulint offset, /*!< in: offset of the page within space
- in units of a page */
- ulint zip_size,/*!< in: compressed page size in bytes
- or 0 for uncompressed pages */
- buf_block_t* block); /*!< in: block to init */
+ const page_id_t& page_id,
+ const page_size_t& page_size,
+ buf_block_t* block);
+
#endif /* !UNIV_HOTBACKUP */
#ifndef UNIV_HOTBACKUP
@@ -471,12 +621,11 @@ buf_page_release_zip(
/*=================*/
buf_page_t* bpage); /*!< in: buffer block */
/********************************************************************//**
-Decrements the bufferfix count of a buffer control block and releases
-a latch, if specified. */
+Releases a latch, if specified. */
UNIV_INLINE
void
-buf_page_release(
-/*=============*/
+buf_page_release_latch(
+/*=====================*/
buf_block_t* block, /*!< in: buffer block */
ulint rw_latch); /*!< in: RW_S_LATCH, RW_X_LATCH,
RW_NO_LATCH */
@@ -484,53 +633,47 @@ buf_page_release(
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. */
-UNIV_INTERN
void
buf_page_make_young(
/*================*/
buf_page_t* bpage); /*!< in: buffer block of a file page */
-/********************************************************************//**
-Returns TRUE if the page can be found in the buffer pool hash table.
+/** 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.
-
-@return TRUE if found in the page hash table */
+@param[in] page_id page id
+@return TRUE if found in the page hash table */
UNIV_INLINE
ibool
buf_page_peek(
-/*==========*/
- ulint space, /*!< in: space id */
- ulint offset);/*!< in: page number */
-#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
-/********************************************************************//**
-Sets file_page_was_freed TRUE if the page is found in the buffer pool.
+ const page_id_t& page_id);
+
+#ifdef UNIV_DEBUG
+
+/** 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.
-@return control block if found in page hash table, otherwise NULL */
-UNIV_INTERN
+@param[in] page_id page id
+@return control block if found in page hash table, otherwise NULL */
buf_page_t*
buf_page_set_file_page_was_freed(
-/*=============================*/
- ulint space, /*!< in: space id */
- ulint offset);/*!< in: page number */
-/********************************************************************//**
-Sets file_page_was_freed FALSE if the page is found in the buffer pool.
+ const page_id_t& page_id);
+
+/** 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.
-@return control block if found in page hash table, otherwise NULL */
-UNIV_INTERN
+@param[in] page_id page id
+@return control block if found in page hash table, otherwise NULL */
buf_page_t*
buf_page_reset_file_page_was_freed(
-/*===============================*/
- ulint space, /*!< in: space id */
- ulint offset); /*!< in: page number */
-#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
+ const page_id_t& page_id);
+
+#endif /* UNIV_DEBUG */
/********************************************************************//**
Reads the freed_page_clock of a buffer block.
-@return freed_page_clock */
+@return freed_page_clock */
UNIV_INLINE
ulint
buf_page_get_freed_page_clock(
@@ -539,7 +682,7 @@ buf_page_get_freed_page_clock(
MY_ATTRIBUTE((pure));
/********************************************************************//**
Reads the freed_page_clock of a buffer block.
-@return freed_page_clock */
+@return freed_page_clock */
UNIV_INLINE
ulint
buf_block_get_freed_page_clock(
@@ -553,7 +696,7 @@ 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.
-@return TRUE if block is close to MRU end of LRU */
+@return TRUE if block is close to MRU end of LRU */
UNIV_INLINE
ibool
buf_page_peek_if_young(
@@ -563,7 +706,7 @@ buf_page_peek_if_young(
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.
-@return TRUE if should be made younger */
+@return TRUE if should be made younger */
UNIV_INLINE
ibool
buf_page_peek_if_too_old(
@@ -572,7 +715,7 @@ buf_page_peek_if_too_old(
/********************************************************************//**
Gets the youngest modification log sequence number for a frame.
Returns zero if not file page or no modification occurred yet.
-@return newest modification to page */
+@return newest modification to page */
UNIV_INLINE
lsn_t
buf_page_get_newest_modification(
@@ -591,7 +734,7 @@ buf_block_modify_clock_inc(
/********************************************************************//**
Returns the value of the modify clock. The caller must have an s-lock
or x-lock on the block.
-@return value */
+@return value */
UNIV_INLINE
ib_uint64_t
buf_block_get_modify_clock(
@@ -603,67 +746,97 @@ UNIV_INLINE
void
buf_block_buf_fix_inc_func(
/*=======================*/
-# ifdef UNIV_SYNC_DEBUG
+# ifdef UNIV_DEBUG
const char* file, /*!< in: file name */
ulint line, /*!< in: line */
-# endif /* UNIV_SYNC_DEBUG */
+# endif /* UNIV_DEBUG */
buf_block_t* block) /*!< in/out: block to bufferfix */
MY_ATTRIBUTE((nonnull));
-/*******************************************************************//**
-Increments the bufferfix count. */
+/** Increments the bufferfix count.
+@param[in,out] bpage block to bufferfix
+@return the count */
UNIV_INLINE
-void
+ulint
buf_block_fix(
-/*===========*/
- buf_block_t* block); /*!< in/out: block to bufferfix */
+ buf_page_t* bpage);
-/*******************************************************************//**
-Increments the bufferfix count. */
+/** Increments the bufferfix count.
+@param[in,out] block block to bufferfix
+@return the count */
UNIV_INLINE
-void
+ulint
+buf_block_fix(
+ buf_block_t* block);
+
+/** Decrements the bufferfix count.
+@param[in,out] bpage block to bufferunfix
+@return the remaining buffer-fix count */
+UNIV_INLINE
+ulint
buf_block_unfix(
-/*===========*/
- buf_block_t* block); /*!< in/out: block to bufferfix */
+ buf_page_t* bpage);
+/** Decrements the bufferfix count.
+@param[in,out] block block to bufferunfix
+@return the remaining buffer-fix count */
+UNIV_INLINE
+ulint
+buf_block_unfix(
+ buf_block_t* block);
-# ifdef UNIV_SYNC_DEBUG
+# ifdef UNIV_DEBUG
/** Increments the bufferfix count.
-@param b in/out: block to bufferfix
-@param f in: file name where requested
-@param l in: line number where requested */
+@param[in,out] b block to bufferfix
+@param[in] f file name where requested
+@param[in] l line number where requested */
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(f,l,b)
-# else /* UNIV_SYNC_DEBUG */
+# else /* UNIV_DEBUG */
/** Increments the bufferfix count.
-@param b in/out: block to bufferfix
-@param f in: file name where requested
-@param l in: line number where requested */
+@param[in,out] b block to bufferfix
+@param[in] f file name where requested
+@param[in] l line number where requested */
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(b)
-# endif /* UNIV_SYNC_DEBUG */
+# endif /* UNIV_DEBUG */
#else /* !UNIV_HOTBACKUP */
# define buf_block_modify_clock_inc(block) ((void) 0)
#endif /* !UNIV_HOTBACKUP */
-/********************************************************************//**
-Checks if a page is corrupt.
-@return TRUE if corrupted */
-UNIV_INTERN
-ibool
-buf_page_is_corrupted(
-/*==================*/
- bool check_lsn, /*!< in: true if we need to check the
- and complain about the LSN */
- const byte* read_buf, /*!< in: a database page */
- ulint zip_size) /*!< in: size of compressed page;
- 0 for uncompressed pages */
- MY_ATTRIBUTE((nonnull, warn_unused_result));
-/********************************************************************//**
-Checks if a page is all zeroes.
-@return TRUE if the page is all zeroes */
+#endif /* !UNIV_INNOCHECKSUM */
+
+/** Checks if a page contains only zeroes.
+@param[in] read_buf database page
+@param[in] page_size page size
+@return true if page is filled with zeroes */
bool
buf_page_is_zeroes(
-/*===============*/
- const byte* read_buf, /*!< in: a database page */
- const ulint zip_size); /*!< in: size of compressed page;
- 0 for uncompressed pages */
+ const byte* read_buf,
+ const page_size_t& page_size);
+
+/** Checks if a page is corrupt.
+@param[in] check_lsn true if we need to check and complain about
+the LSN
+@param[in] read_buf database page
+@param[in] page_size page size
+@param[in] skip_checksum if true, skip checksum
+@param[in] page_no page number of given read_buf
+@param[in] strict_check true if strict-check option is enabled
+@param[in] is_log_enabled true if log option is enabled
+@param[in] log_file file pointer to log_file
+@return TRUE if corrupted */
+ibool
+buf_page_is_corrupted(
+ bool check_lsn,
+ const byte* read_buf,
+ const page_size_t& page_size,
+ bool skip_checksum
+#ifdef UNIV_INNOCHECKSUM
+ ,uintmax_t page_no,
+ bool strict_check,
+ bool is_log_enabled,
+ FILE* log_file
+#endif /* UNIV_INNOCHECKSUM */
+) __attribute__((warn_unused_result));
+
+#ifndef UNIV_INNOCHECKSUM
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Gets the space id, page offset, and byte offset within page of a
@@ -678,7 +851,7 @@ buf_ptr_get_fsp_addr(
/**********************************************************************//**
Gets the hash value of a block. This can be used in searches in the
lock hash table.
-@return lock hash value */
+@return lock hash value */
UNIV_INLINE
ulint
buf_block_get_lock_hash_val(
@@ -689,8 +862,7 @@ buf_block_get_lock_hash_val(
/*********************************************************************//**
Finds a block in the buffer pool that points to a
given compressed page.
-@return buffer block pointing to the compressed page, or NULL */
-UNIV_INTERN
+@return buffer block pointing to the compressed page, or NULL */
buf_block_t*
buf_pool_contains_zip(
/*==================*/
@@ -711,8 +883,7 @@ buf_frame_align(
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/*********************************************************************//**
Validates the buffer pool data structure.
-@return TRUE */
-UNIV_INTERN
+@return TRUE */
ibool
buf_validate(void);
/*==============*/
@@ -720,7 +891,6 @@ buf_validate(void);
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/*********************************************************************//**
Prints info of the buffer pool data structure. */
-UNIV_INTERN
void
buf_print(void);
/*============*/
@@ -733,23 +903,20 @@ enum buf_page_print_flags {
BUF_PAGE_PRINT_NO_FULL = 2
};
-/********************************************************************//**
-Prints a page to stderr. */
-UNIV_INTERN
+/** Prints a page to stderr.
+@param[in] read_buf a database page
+@param[in] page_size page size
+@param[in] flags 0 or BUF_PAGE_PRINT_NO_CRASH or
+BUF_PAGE_PRINT_NO_FULL */
void
buf_page_print(
-/*===========*/
- const byte* read_buf, /*!< in: a database page */
- ulint zip_size, /*!< in: compressed page size, or
- 0 for uncompressed pages */
- ulint flags) /*!< in: 0 or
- BUF_PAGE_PRINT_NO_CRASH or
- BUF_PAGE_PRINT_NO_FULL */
- UNIV_COLD MY_ATTRIBUTE((nonnull));
+ const byte* read_buf,
+ const page_size_t& page_size,
+ ulint flags);
+
/********************************************************************//**
Decompress a block.
-@return TRUE if successful */
-UNIV_INTERN
+@return TRUE if successful */
ibool
buf_zip_decompress(
/*===============*/
@@ -759,22 +926,19 @@ buf_zip_decompress(
#ifdef UNIV_DEBUG
/*********************************************************************//**
Returns the number of latched pages in the buffer pool.
-@return number of latched pages */
-UNIV_INTERN
+@return number of latched pages */
ulint
buf_get_latched_pages_number(void);
/*==============================*/
#endif /* UNIV_DEBUG */
/*********************************************************************//**
Returns the number of pending buf pool read ios.
-@return number of pending read I/O operations */
-UNIV_INTERN
+@return number of pending read I/O operations */
ulint
buf_get_n_pending_read_ios(void);
/*============================*/
/*********************************************************************//**
Prints info of the buffer i/o. */
-UNIV_INTERN
void
buf_print_io(
/*=========*/
@@ -783,7 +947,6 @@ buf_print_io(
Collect buffer pool stats information for a buffer pool. Also
record aggregated stats if there are more than one buffer pool
in the server */
-UNIV_INTERN
void
buf_stats_get_pool_info(
/*====================*/
@@ -794,36 +957,31 @@ buf_stats_get_pool_info(
/*********************************************************************//**
Returns the ratio in percents of modified pages in the buffer pool /
database pages in the buffer pool.
-@return modified page percentage ratio */
-UNIV_INTERN
+@return modified page percentage ratio */
double
buf_get_modified_ratio_pct(void);
/*============================*/
/**********************************************************************//**
Refreshes the statistics used to print per-second averages. */
-UNIV_INTERN
void
buf_refresh_io_stats(
/*=================*/
buf_pool_t* buf_pool); /*!< buffer pool instance */
/**********************************************************************//**
Refreshes the statistics used to print per-second averages. */
-UNIV_INTERN
void
buf_refresh_io_stats_all(void);
/*=================*/
/*********************************************************************//**
Asserts that all file pages in the buffer are in a replaceable state.
-@return TRUE */
-UNIV_INTERN
+@return TRUE */
ibool
buf_all_freed(void);
/*===============*/
/*********************************************************************//**
Checks that there currently are no pending i/o-operations for the buffer
pool.
-@return number of pending i/o operations */
-UNIV_INTERN
+@return number of pending i/o operations */
ulint
buf_pool_check_no_pending_io(void);
/*==============================*/
@@ -831,7 +989,6 @@ buf_pool_check_no_pending_io(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_INTERN
void
buf_pool_invalidate(void);
/*=====================*/
@@ -841,7 +998,7 @@ buf_pool_invalidate(void);
--------------------------- LOWER LEVEL ROUTINES -------------------------
=========================================================================*/
-#ifdef UNIV_SYNC_DEBUG
+#ifdef UNIV_DEBUG
/*********************************************************************//**
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
@@ -852,13 +1009,13 @@ buf_block_dbg_add_level(
/*====================*/
buf_block_t* block, /*!< in: buffer page
where we have acquired latch */
- ulint level); /*!< in: latching order level */
-#else /* UNIV_SYNC_DEBUG */
+ latch_level_t level); /*!< in: latching order level */
+#else /* UNIV_DEBUG */
# define buf_block_dbg_add_level(block, level) /* nothing */
-#endif /* UNIV_SYNC_DEBUG */
+#endif /* UNIV_DEBUG */
/*********************************************************************//**
Gets the state of a block.
-@return state */
+@return state */
UNIV_INLINE
enum buf_page_state
buf_page_get_state(
@@ -876,7 +1033,7 @@ buf_get_state_name(
block */
/*********************************************************************//**
Gets the state of a block.
-@return state */
+@return state */
UNIV_INLINE
enum buf_page_state
buf_block_get_state(
@@ -901,7 +1058,7 @@ buf_block_set_state(
enum buf_page_state state); /*!< in: state */
/*********************************************************************//**
Determines if a block is mapped to a tablespace.
-@return TRUE if mapped */
+@return TRUE if mapped */
UNIV_INLINE
ibool
buf_page_in_file(
@@ -911,7 +1068,7 @@ buf_page_in_file(
#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
Determines if a block should be on unzip_LRU list.
-@return TRUE if block belongs to unzip_LRU */
+@return TRUE if block belongs to unzip_LRU */
UNIV_INLINE
ibool
buf_page_belongs_to_unzip_LRU(
@@ -921,9 +1078,9 @@ buf_page_belongs_to_unzip_LRU(
/*********************************************************************//**
Gets the mutex of a block.
-@return pointer to mutex protecting bpage */
+@return pointer to mutex protecting bpage */
UNIV_INLINE
-ib_mutex_t*
+BPageMutex*
buf_page_get_mutex(
/*===============*/
const buf_page_t* bpage) /*!< in: pointer to control block */
@@ -931,7 +1088,7 @@ buf_page_get_mutex(
/*********************************************************************//**
Get the flush type of a page.
-@return flush type */
+@return flush type */
UNIV_INLINE
buf_flush_t
buf_page_get_flush_type(
@@ -946,18 +1103,19 @@ buf_page_set_flush_type(
/*====================*/
buf_page_t* bpage, /*!< in: buffer page */
buf_flush_t flush_type); /*!< in: flush type */
-/*********************************************************************//**
-Map a block to a file page. */
+
+/** Map a block to a file page.
+@param[in,out] block pointer to control block
+@param[in] page_id page id */
UNIV_INLINE
void
buf_block_set_file_page(
-/*====================*/
- buf_block_t* block, /*!< in/out: pointer to control block */
- ulint space, /*!< in: tablespace id */
- ulint page_no);/*!< in: page number */
+ buf_block_t* block,
+ const page_id_t& page_id);
+
/*********************************************************************//**
Gets the io_fix state of a block.
-@return io_fix state */
+@return io_fix state */
UNIV_INLINE
enum buf_io_fix
buf_page_get_io_fix(
@@ -966,7 +1124,7 @@ buf_page_get_io_fix(
MY_ATTRIBUTE((pure));
/*********************************************************************//**
Gets the io_fix state of a block.
-@return io_fix state */
+@return io_fix state */
UNIV_INLINE
enum buf_io_fix
buf_block_get_io_fix(
@@ -1022,7 +1180,7 @@ buf_page_can_relocate(
/*********************************************************************//**
Determine if a block has been flagged old.
-@return TRUE if old */
+@return TRUE if old */
UNIV_INLINE
ibool
buf_page_is_old(
@@ -1039,7 +1197,7 @@ buf_page_set_old(
ibool old); /*!< in: old */
/*********************************************************************//**
Determine the time of first access of a block in the buffer pool.
-@return ut_time_ms() at the time of first access, 0 if not accessed */
+@return ut_time_ms() at the time of first access, 0 if not accessed */
UNIV_INLINE
unsigned
buf_page_is_accessed(
@@ -1057,8 +1215,8 @@ buf_page_set_accessed(
/*********************************************************************//**
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.
-@return control block, or NULL */
+const we don't update its value.
+@return control block, or NULL */
UNIV_INLINE
buf_block_t*
buf_page_get_block(
@@ -1069,70 +1227,17 @@ buf_page_get_block(
#ifdef UNIV_DEBUG
/*********************************************************************//**
Gets a pointer to the memory frame of a block.
-@return pointer to the frame */
+@return pointer to the frame */
UNIV_INLINE
buf_frame_t*
buf_block_get_frame(
/*================*/
const buf_block_t* block) /*!< in: pointer to the control block */
- MY_ATTRIBUTE((pure));
+ __attribute__((warn_unused_result));
#else /* UNIV_DEBUG */
# define buf_block_get_frame(block) (block)->frame
#endif /* UNIV_DEBUG */
-/*********************************************************************//**
-Gets the space id of a block.
-@return space id */
-UNIV_INLINE
-ulint
-buf_page_get_space(
-/*===============*/
- const buf_page_t* bpage) /*!< in: pointer to the control block */
- MY_ATTRIBUTE((pure));
-/*********************************************************************//**
-Gets the space id of a block.
-@return space id */
-UNIV_INLINE
-ulint
-buf_block_get_space(
-/*================*/
- const buf_block_t* block) /*!< in: pointer to the control block */
- MY_ATTRIBUTE((pure));
-/*********************************************************************//**
-Gets the page number of a block.
-@return page number */
-UNIV_INLINE
-ulint
-buf_page_get_page_no(
-/*=================*/
- const buf_page_t* bpage) /*!< in: pointer to the control block */
- MY_ATTRIBUTE((pure));
-/*********************************************************************//**
-Gets the page number of a block.
-@return page number */
-UNIV_INLINE
-ulint
-buf_block_get_page_no(
-/*==================*/
- const buf_block_t* block) /*!< in: pointer to the control block */
- MY_ATTRIBUTE((pure));
-/*********************************************************************//**
-Gets the compressed page size of a block.
-@return compressed page size, or 0 */
-UNIV_INLINE
-ulint
-buf_page_get_zip_size(
-/*==================*/
- const buf_page_t* bpage) /*!< in: pointer to the control block */
- MY_ATTRIBUTE((pure));
-/*********************************************************************//**
-Gets the compressed page size of a block.
-@return compressed page size, or 0 */
-UNIV_INLINE
-ulint
-buf_block_get_zip_size(
-/*===================*/
- const buf_block_t* block) /*!< in: pointer to the control block */
- MY_ATTRIBUTE((pure));
+
/*********************************************************************//**
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
@@ -1141,8 +1246,7 @@ if applicable. */
#ifndef UNIV_HOTBACKUP
/*******************************************************************//**
Gets the block to whose frame the pointer is pointing to.
-@return pointer to block, never NULL */
-UNIV_INTERN
+@return pointer to block, never NULL */
buf_block_t*
buf_block_align(
/*============*/
@@ -1150,21 +1254,20 @@ buf_block_align(
/********************************************************************//**
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
-@return TRUE if ptr belongs to a buf_block_t struct */
-UNIV_INTERN
+@return TRUE if ptr belongs to a buf_block_t struct */
ibool
buf_pointer_is_block_field(
/*=======================*/
const void* ptr); /*!< in: pointer not
dereferenced */
/** Find out if a pointer corresponds to a buf_block_t::mutex.
-@param m in: mutex candidate
-@return TRUE if m is a buf_block_t::mutex */
+@param m in: mutex candidate
+@return TRUE if m is a buf_block_t::mutex */
#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::lock.
-@param l in: rw-lock candidate
-@return TRUE if l is a buf_block_t::lock */
+@param l in: rw-lock candidate
+@return TRUE if l is a buf_block_t::lock */
#define buf_pool_is_block_lock(l) \
buf_pointer_is_block_field((const void*)(l))
@@ -1172,15 +1275,15 @@ buf_pointer_is_block_field(
/*********************************************************************//**
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable.
-@return compressed page descriptor, or NULL */
+@return compressed page descriptor, or NULL */
UNIV_INLINE
const page_zip_des_t*
buf_frame_get_page_zip(
/*===================*/
const byte* ptr); /*!< in: pointer to the page */
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
-/********************************************************************//**
-Function which inits a page for read to the buffer buf_pool. If the page is
+
+/** 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,
@@ -1188,25 +1291,23 @@ 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.
-@return pointer to the block or NULL */
-UNIV_INTERN
+@param[out] err DB_SUCCESS or DB_TABLESPACE_DELETED
+@param[in] mode BUF_READ_IBUF_PAGES_ONLY, ...
+@param[in] page_id page id
+@param[in] unzip TRUE=request uncompressed page
+@return pointer to the block or NULL */
buf_page_t*
buf_page_init_for_read(
-/*===================*/
- dberr_t* err, /*!< out: DB_SUCCESS or DB_TABLESPACE_DELETED */
- ulint mode, /*!< in: BUF_READ_IBUF_PAGES_ONLY, ... */
- ulint space, /*!< in: space id */
- ulint zip_size,/*!< in: compressed page size, or 0 */
- ibool unzip, /*!< in: TRUE=request uncompressed page */
- ib_int64_t tablespace_version,/*!< in: prevents reading from a wrong
- version of the tablespace in case we have done
- DISCARD + IMPORT */
- ulint offset);/*!< in: page number */
+ dberr_t* err,
+ ulint mode,
+ const page_id_t& page_id,
+ const page_size_t& page_size,
+ ibool unzip);
+
/********************************************************************//**
Completes an asynchronous read or write request of a file page to or from
the buffer pool.
@return true if successful */
-UNIV_INTERN
bool
buf_page_io_complete(
/*=================*/
@@ -1214,19 +1315,8 @@ buf_page_io_complete(
bool evict = false);/*!< in: whether or not to evict
the page from LRU list. */
/********************************************************************//**
-Calculates a folded value of a file page address to use in the page hash
-table.
-@return the folded value */
-UNIV_INLINE
-ulint
-buf_page_address_fold(
-/*==================*/
- ulint space, /*!< in: space id */
- ulint offset) /*!< in: offset of the page within space */
- MY_ATTRIBUTE((const));
-/********************************************************************//**
Calculates the index of a buffer pool to the buf_pool[] array.
-@return the position of the buffer pool in buf_pool[] */
+@return the position of the buffer pool in buf_pool[] */
UNIV_INLINE
ulint
buf_pool_index(
@@ -1249,15 +1339,15 @@ buf_pool_t*
buf_pool_from_block(
/*================*/
const buf_block_t* block); /*!< in: block */
-/******************************************************************//**
-Returns the buffer pool instance given space and offset of page
+
+/** Returns the buffer pool instance given a page id.
+@param[in] page_id page id
@return buffer pool */
UNIV_INLINE
buf_pool_t*
buf_pool_get(
-/*==========*/
- ulint space, /*!< in: space id */
- ulint offset);/*!< in: offset of the page within space */
+ const page_id_t& page_id);
+
/******************************************************************//**
Returns the buffer pool instance given its array index
@return buffer pool */
@@ -1267,71 +1357,64 @@ buf_pool_from_array(
/*================*/
ulint index); /*!< in: array index to get
buffer pool instance from */
-/******************************************************************//**
-Returns the control block of a file page, NULL if not found.
-@return block, NULL if not found */
+
+/** Returns the control block of a file page, NULL if not found.
+@param[in] buf_pool buffer pool instance
+@param[in] page_id page id
+@return block, NULL if not found */
UNIV_INLINE
buf_page_t*
buf_page_hash_get_low(
-/*==================*/
- buf_pool_t* buf_pool,/*!< buffer pool instance */
- ulint space, /*!< in: space id */
- ulint offset, /*!< in: offset of the page within space */
- ulint fold); /*!< in: buf_page_address_fold(space, offset) */
-/******************************************************************//**
-Returns the control block of a file page, NULL if not found.
+ buf_pool_t* buf_pool,
+ const page_id_t& page_id);
+
+/** 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.
-@return block, NULL if not found, or watch sentinel (if watch is true) */
+@param[in] buf_pool buffer pool instance
+@param[in] page_id page id
+@param[in,out] lock 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.
+@param[in] lock_mode RW_LOCK_X or RW_LOCK_S. Ignored if
+lock == NULL
+@param[in] watch if true, return watch sentinel also.
+@return pointer to the bpage or NULL; if NULL, lock is also NULL or
+a watch sentinel. */
UNIV_INLINE
buf_page_t*
buf_page_hash_get_locked(
-/*=====================*/
- /*!< out: pointer to the bpage,
- or NULL; if NULL, hash_lock
- is also NULL. */
- buf_pool_t* buf_pool, /*!< buffer pool instance */
- ulint space, /*!< in: space id */
- ulint offset, /*!< in: page number */
- rw_lock_t** lock, /*!< in/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 */
- ulint lock_mode, /*!< in: RW_LOCK_EX or
- RW_LOCK_SHARED. Ignored if
- lock == NULL */
- bool watch = false); /*!< in: if true, return watch
- sentinel also. */
-/******************************************************************//**
-Returns the control block of a file page, NULL if not found.
+ buf_pool_t* buf_pool,
+ const page_id_t& page_id,
+ rw_lock_t** lock,
+ ulint lock_mode,
+ bool watch = false);
+
+/** 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.
-@return block, NULL if not found */
+@param[in] buf_pool buffer pool instance
+@param[in] page_id page id
+@param[in,out] lock 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.
+@param[in] lock_mode RW_LOCK_X or RW_LOCK_S. Ignored if
+lock == NULL
+@return pointer to the block or NULL; if NULL, lock is also NULL. */
UNIV_INLINE
buf_block_t*
buf_block_hash_get_locked(
-/*=====================*/
- /*!< out: pointer to the bpage,
- or NULL; if NULL, hash_lock
- is also NULL. */
- buf_pool_t* buf_pool, /*!< buffer pool instance */
- ulint space, /*!< in: space id */
- ulint offset, /*!< in: page number */
- rw_lock_t** lock, /*!< in/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 */
- ulint lock_mode); /*!< in: RW_LOCK_EX or
- RW_LOCK_SHARED. Ignored if
- lock == NULL */
+ buf_pool_t* buf_pool,
+ const page_id_t& page_id,
+ rw_lock_t** lock,
+ ulint lock_mode);
+
/* There are four different ways we can try to get a bpage or block
from the page hash:
1) Caller already holds the appropriate page hash lock: in the case call
@@ -1339,75 +1422,70 @@ buf_page_hash_get_low() function.
2) Caller wants to hold page hash lock in x-mode
3) Caller wants to hold page hash lock in s-mode
4) Caller doesn't want to hold page hash lock */
-#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_hash_get_s_locked(b, page_id, l) \
+ buf_page_hash_get_locked(b, page_id, l, RW_LOCK_S)
+#define buf_page_hash_get_x_locked(b, page_id, l) \
+ buf_page_hash_get_locked(b, page_id, l, RW_LOCK_X)
+#define buf_page_hash_get(b, page_id) \
+ buf_page_hash_get_locked(b, page_id, NULL, 0)
+#define buf_page_get_also_watch(b, page_id) \
+ buf_page_hash_get_locked(b, page_id, NULL, 0, true)
+
+#define buf_block_hash_get_s_locked(b, page_id, l) \
+ buf_block_hash_get_locked(b, page_id, l, RW_LOCK_S)
+#define buf_block_hash_get_x_locked(b, page_id, l) \
+ buf_block_hash_get_locked(b, page_id, l, RW_LOCK_X)
+#define buf_block_hash_get(b, page_id) \
+ buf_block_hash_get_locked(b, page_id, NULL, 0)
/*********************************************************************//**
Gets the current length of the free list of buffer blocks.
-@return length of the free list */
-UNIV_INTERN
+@return length of the free list */
ulint
buf_get_free_list_len(void);
/*=======================*/
/********************************************************************//**
Determine if a block is a sentinel for a buffer pool watch.
-@return TRUE if a sentinel for a buffer pool watch, FALSE if not */
-UNIV_INTERN
+@return TRUE if a sentinel for a buffer pool watch, FALSE if not */
ibool
buf_pool_watch_is_sentinel(
/*=======================*/
- buf_pool_t* buf_pool, /*!< buffer pool instance */
+ const buf_pool_t* buf_pool, /*!< buffer pool instance */
const buf_page_t* bpage) /*!< in: block */
MY_ATTRIBUTE((nonnull, warn_unused_result));
-/****************************************************************//**
-Add watch for the given page to be read in. Caller must have the buffer pool
+
+/** 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.
+@param[in] page_id page id
+@param[in,out] hash_lock hash_lock currently latched
@return NULL if watch set, block if the page is in the buffer pool */
-UNIV_INTERN
buf_page_t*
buf_pool_watch_set(
-/*===============*/
- ulint space, /*!< in: space id */
- ulint offset, /*!< in: page number */
- ulint fold) /*!< in: buf_page_address_fold(space, offset) */
+ const page_id_t& page_id,
+ rw_lock_t** hash_lock)
MY_ATTRIBUTE((warn_unused_result));
-/****************************************************************//**
-Stop watching if the page has been read in.
-buf_pool_watch_set(space,offset) must have returned NULL before. */
-UNIV_INTERN
+
+/** Stop watching if the page has been read in.
+buf_pool_watch_set(space,offset) must have returned NULL before.
+@param[in] page_id page id */
void
buf_pool_watch_unset(
-/*=================*/
- ulint space, /*!< in: space id */
- ulint offset);/*!< in: page number */
-/****************************************************************//**
-Check if the page has been read in.
+ const page_id_t& page_id);
+
+/** 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).
-@return FALSE if the given page was not read in, TRUE if it was */
-UNIV_INTERN
+@param[in] page_id page id
+@return FALSE if the given page was not read in, TRUE if it was */
ibool
buf_pool_watch_occurred(
-/*====================*/
- ulint space, /*!< in: space id */
- ulint offset) /*!< in: page number */
+ const page_id_t& page_id)
MY_ATTRIBUTE((warn_unused_result));
+
/********************************************************************//**
Get total buffer pool statistics. */
-UNIV_INTERN
void
buf_get_total_list_len(
/*===================*/
@@ -1416,7 +1494,6 @@ buf_get_total_list_len(
ulint* flush_list_len);/*!< out: length of all flush lists */
/********************************************************************//**
Get total list size in bytes from all buffer pools. */
-UNIV_INTERN
void
buf_get_total_list_size_in_bytes(
/*=============================*/
@@ -1424,7 +1501,6 @@ buf_get_total_list_size_in_bytes(
in all buffer pools */
/********************************************************************//**
Get total buffer pool statistics. */
-UNIV_INTERN
void
buf_get_total_stat(
/*===============*/
@@ -1440,15 +1516,33 @@ buf_get_nth_chunk_block(
ulint n, /*!< in: nth chunk in the buffer pool */
ulint* chunk_size); /*!< in: chunk size */
-/********************************************************************//**
-Calculate the checksum of a page from compressed table and update the page. */
-UNIV_INTERN
+/** Verify the possibility that a stored page is not in buffer pool.
+@param[in] withdraw_clock withdraw clock when stored the page
+@retval true if the page might be relocated */
+UNIV_INLINE
+bool
+buf_pool_is_obsolete(
+ ulint withdraw_clock);
+
+/** Calculate aligned buffer pool size based on srv_buf_pool_chunk_unit,
+if needed.
+@param[in] size size in bytes
+@return aligned size */
+UNIV_INLINE
+ulint
+buf_pool_size_align(
+ ulint size);
+
+/** Calculate the checksum of a page from compressed table and update the
+page.
+@param[in,out] page page to update
+@param[in] size compressed page size
+@param[in] lsn LSN to stamp on the page */
void
buf_flush_update_zip_checksum(
-/*==========================*/
- buf_frame_t* page, /*!< in/out: Page to update */
- ulint zip_size, /*!< in: Compressed page size */
- lsn_t lsn); /*!< in: Lsn to stamp on the page */
+ buf_frame_t* page,
+ ulint size,
+ lsn_t lsn);
#endif /* !UNIV_HOTBACKUP */
@@ -1528,7 +1622,8 @@ for compressed and uncompressed frames */
/** Number of bits used for buffer page states. */
#define BUF_PAGE_STATE_BITS 3
-struct buf_page_t{
+class buf_page_t {
+public:
/** @name General fields
None of these bit-fields must be modified without holding
buf_page_get_mutex() [buf_block_t::mutex or
@@ -1537,36 +1632,21 @@ struct buf_page_t{
by buf_pool->mutex. */
/* @{ */
- ib_uint32_t space; /*!< tablespace id; also protected
- by buf_pool->mutex. */
- ib_uint32_t offset; /*!< page number; also protected
- by buf_pool->mutex. */
- /** count of how manyfold this block is currently bufferfixed */
-#ifdef PAGE_ATOMIC_REF_COUNT
- ib_uint32_t buf_fix_count;
+ /** Page id. Protected by buf_pool mutex. */
+ page_id_t id;
- /** type of pending I/O operation; also protected by
- buf_pool->mutex for writes only @see enum buf_io_fix */
- byte io_fix;
+ /** Page size. Protected by buf_pool mutex. */
+ page_size_t size;
- byte state;
-#else
- unsigned buf_fix_count:19;
+ /** Count of how manyfold this block is currently bufferfixed. */
+ ib_uint32_t buf_fix_count;
/** type of pending I/O operation; also protected by
- buf_pool->mutex for writes only @see enum buf_io_fix */
- unsigned io_fix:2;
+ buf_pool->mutex for writes only */
+ buf_io_fix io_fix;
- /*!< state of the control block; also protected by buf_pool->mutex.
- State transitions from BUF_BLOCK_READY_FOR_USE to BUF_BLOCK_MEMORY
- need not be protected by buf_page_get_mutex(). @see enum buf_page_state.
- State changes that are relevant to page_hash are additionally protected
- by the appropriate page_hash mutex i.e.: if a page is in page_hash or
- is being added to/removed from page_hash then the corresponding changes
- must also be protected by page_hash mutex. */
- unsigned state:BUF_PAGE_STATE_BITS;
-
-#endif /* PAGE_ATOMIC_REF_COUNT */
+ /** Block state. @see buf_page_in_file */
+ buf_page_state state;
#ifndef UNIV_HOTBACKUP
unsigned flush_type:2; /*!< if this block is currently being
@@ -1592,6 +1672,7 @@ struct buf_page_t{
if written again we check is TRIM
operation needed. */
+ ulint space; /*!< space id */
unsigned key_version; /*!< key version for this block */
bool page_encrypted; /*!< page is page encrypted */
bool page_compressed;/*!< page is page compressed */
@@ -1631,7 +1712,7 @@ struct buf_page_t{
in one of the following lists in
buf_pool:
- - BUF_BLOCK_NOT_USED: free
+ - BUF_BLOCK_NOT_USED: free, withdraw
- BUF_BLOCK_FILE_PAGE: flush_list
- BUF_BLOCK_ZIP_DIRTY: flush_list
- BUF_BLOCK_ZIP_PAGE: zip_clean
@@ -1667,6 +1748,9 @@ struct buf_page_t{
should hold: in_free_list
== (state == BUF_BLOCK_NOT_USED) */
#endif /* UNIV_DEBUG */
+
+ FlushObserver* flush_observer; /*!< flush observer */
+
lsn_t newest_modification;
/*!< log sequence number of
the youngest modification to
@@ -1714,13 +1798,13 @@ struct buf_page_t{
0 if the block was never accessed
in the buffer pool. Protected by
block mutex */
-# if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
+# ifdef UNIV_DEBUG
ibool file_page_was_freed;
/*!< this is set to TRUE when
fsp frees a page in buffer pool;
protected by buf_pool->zip_mutex
or buf_block_t::mutex. */
-# endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
+# endif /* UNIV_DEBUG */
#endif /* !UNIV_HOTBACKUP */
};
@@ -1740,6 +1824,8 @@ struct buf_block_t{
aligned to an address divisible by
UNIV_PAGE_SIZE */
#ifndef UNIV_HOTBACKUP
+ BPageLock lock; /*!< read-write lock of the buffer
+ frame */
UT_LIST_NODE_T(buf_block_t) unzip_LRU;
/*!< node of the decompressed LRU list;
a block is in the unzip_LRU list
@@ -1749,15 +1835,8 @@ struct buf_block_t{
ibool in_unzip_LRU_list;/*!< TRUE if the page is in the
decompressed LRU list;
used in debugging */
+ ibool in_withdraw_list;
#endif /* UNIV_DEBUG */
- ib_mutex_t mutex; /*!< mutex protecting this block:
- state (also protected by the buffer
- pool mutex), io_fix, buf_fix_count,
- and accessed; we introduce this new
- mutex in InnoDB-5.1 to relieve
- contention on the buffer pool mutex */
- rw_lock_t lock; /*!< read-write lock of the buffer
- frame */
unsigned lock_hash_val:32;/*!< hashed value of the page address
in the record lock hash table;
protected by buf_block_t::lock
@@ -1765,15 +1844,6 @@ struct buf_block_t{
in buf_page_get_gen(),
buf_page_init_for_read()
and buf_page_create()) */
- ibool check_index_page_at_flush;
- /*!< TRUE if we know that this is
- an index page, and want the database
- to check its consistency before flush;
- note that there may be pages in the
- buffer pool which are index pages,
- but this flag is not set because
- we do not keep track of all pages;
- NOT protected by any mutex */
/* @} */
/** @name Optimistic search field */
/* @{ */
@@ -1796,11 +1866,12 @@ struct buf_block_t{
ulint n_hash_helps; /*!< counter which controls building
of a new hash index for the page */
- ulint n_fields; /*!< recommended prefix length for hash
+ volatile ulint n_bytes; /*!< recommended prefix length for hash
+ search: number of bytes in
+ an incomplete last field */
+ volatile ulint n_fields; /*!< recommended prefix length for hash
search: number of full fields */
- ulint n_bytes; /*!< recommended prefix: number of bytes
- in an incomplete field */
- ibool left_side; /*!< TRUE or FALSE, depending on
+ volatile bool left_side; /*!< true or false, depending on
whether the leftmost record of several
records with the same prefix should be
indexed in the hash index */
@@ -1808,7 +1879,7 @@ struct buf_block_t{
/** @name Hash search fields
These 5 fields may only be modified when we have
- an x-latch on btr_search_latch AND
+ an x-latch on search system AND
- we are holding an s-latch or x-latch on buf_block_t::lock or
- we know that buf_block_t::buf_fix_count == 0.
@@ -1816,7 +1887,7 @@ struct buf_block_t{
in the buffer pool in buf0buf.cc.
Another exception is that assigning block->index = NULL
- is allowed whenever holding an x-latch on btr_search_latch. */
+ is allowed whenever holding an x-latch on search system. */
/* @{ */
@@ -1839,8 +1910,17 @@ struct buf_block_t{
complete, though: there may
have been hash collisions,
record deletions, etc. */
+ bool made_dirty_with_no_latch;
+ /*!< true if block has been made dirty
+ without acquiring X/SX latch as the
+ block belongs to temporary tablespace
+ and block is always accessed by a
+ single thread. */
+ bool skip_flush_check;
+ /*!< Skip check in buf_dblwr_check_block
+ during bulk load, protected by lock.*/
/* @} */
-# ifdef UNIV_SYNC_DEBUG
+# ifdef UNIV_DEBUG
/** @name Debug fields */
/* @{ */
rw_lock_t debug_latch; /*!< in the debug version, each thread
@@ -1849,16 +1929,23 @@ struct buf_block_t{
debug utilities in sync0rw */
/* @} */
# endif
+ BPageMutex mutex; /*!< mutex protecting this block:
+ state (also protected by the buffer
+ pool mutex), io_fix, buf_fix_count,
+ and accessed; we introduce this new
+ mutex in InnoDB-5.1 to relieve
+ contention on the buffer pool mutex */
#endif /* !UNIV_HOTBACKUP */
};
/** Check if a buf_block_t object is in a valid state
-@param block buffer block
-@return TRUE if valid */
+@param block buffer block
+@return TRUE if valid */
#define buf_block_state_valid(block) \
(buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
&& (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
+
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Compute the hash fold value for blocks in buf_pool->zip_hash. */
@@ -1890,7 +1977,7 @@ public:
virtual ~HazardPointer() {}
/** Get current value */
- buf_page_t* get()
+ buf_page_t* get() const
{
ut_ad(mutex_own(m_mutex));
return(m_hp);
@@ -1920,7 +2007,7 @@ protected:
/** Buffer pool instance */
const buf_pool_t* m_buf_pool;
-#if UNIV_DEBUG
+#ifdef UNIV_DEBUG
/** mutex that protects access to the m_hp. */
const ib_mutex_t* m_mutex;
#endif /* UNIV_DEBUG */
@@ -2074,15 +2161,14 @@ struct buf_pool_t{
/** @name General fields */
/* @{ */
- ib_mutex_t mutex; /*!< Buffer pool mutex of this
+ BufPoolMutex mutex; /*!< Buffer pool mutex of this
instance */
- ib_mutex_t zip_mutex; /*!< Zip mutex of this buffer
+ BufPoolZipMutex zip_mutex; /*!< Zip mutex of this buffer
pool instance, protects compressed
only pages (of type buf_page_t, not
buf_block_t */
ulint instance_no; /*!< Array index of this buffer
pool instance */
- ulint old_pool_size; /*!< Old pool size in bytes */
ulint curr_pool_size; /*!< Current pool size in bytes */
ulint LRU_old_ratio; /*!< Reserve this much of the buffer
pool for "old" blocks */
@@ -2093,9 +2179,19 @@ struct buf_pool_t{
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ulint mutex_exit_forbidden; /*!< Forbid release mutex */
#endif
- ulint n_chunks; /*!< number of buffer pool chunks */
+ ut_allocator<unsigned char> allocator; /*!< Allocator used for
+ allocating memory for the the "chunks"
+ member. */
+ volatile ulint n_chunks; /*!< number of buffer pool chunks */
+ volatile ulint n_chunks_new; /*!< new number of buffer pool chunks */
buf_chunk_t* chunks; /*!< buffer pool chunks */
+ buf_chunk_t* chunks_old; /*!< old buffer pool chunks to be freed
+ after resizing buffer pool */
ulint curr_size; /*!< current pool size in pages */
+ ulint old_size; /*!< previous pool size in pages */
+ ulint read_ahead_area;/*!< size in pages of the area which
+ the read-ahead algorithms read if
+ invoked */
hash_table_t* page_hash; /*!< hash table of buf_page_t or
buf_block_t file pages,
buf_page_in_file() == TRUE,
@@ -2107,6 +2203,8 @@ struct buf_pool_t{
page_hash mutex. Lookups can happen
while holding the buf_pool->mutex or
the relevant page_hash mutex. */
+ hash_table_t* page_hash_old; /*!< old pointer to page_hash to be
+ freed after resizing buffer pool */
hash_table_t* zip_hash; /*!< hash table of buf_block_t blocks
whose frames are allocated to the
zip buddy system,
@@ -2130,7 +2228,7 @@ struct buf_pool_t{
/* @{ */
- ib_mutex_t flush_list_mutex;/*!< mutex protecting the
+ FlushListMutex flush_list_mutex;/*!< mutex protecting the
flush list access. This mutex
protects flush_list, flush_rbt
and bpage::list pointers when
@@ -2197,6 +2295,15 @@ struct buf_pool_t{
/*!< base node of the free
block list */
+ UT_LIST_BASE_NODE_T(buf_page_t) withdraw;
+ /*!< base node of the withdraw
+ block list. It is only used during
+ shrinking buffer pool size, not to
+ reuse the blocks will be removed */
+
+ ulint withdraw_target;/*!< target length of withdraw
+ block list, when withdrawing */
+
/** "hazard pointer" used during scan of LRU while doing
LRU list batch. Protected by buf_pool::mutex */
LRUHp lru_hp;
@@ -2211,6 +2318,7 @@ struct buf_pool_t{
UT_LIST_BASE_NODE_T(buf_page_t) LRU;
/*!< base node of the LRU list */
+
buf_page_t* LRU_old; /*!< pointer to the about
LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV
oldest blocks in the LRU list;
@@ -2258,6 +2366,15 @@ struct buf_pool_t{
/* @} */
};
+/** Print the given buf_pool_t object.
+@param[in,out] out the output stream
+@param[in] buf_pool the buf_pool_t object to be printed
+@return the output stream */
+std::ostream&
+operator<<(
+ std::ostream& out,
+ const buf_pool_t& buf_pool);
+
/** @name Accessors for buf_pool->mutex.
Use these instead of accessing buf_pool->mutex directly. */
/* @{ */
@@ -2265,77 +2382,79 @@ Use these instead of accessing buf_pool->mutex directly. */
/** Test if a buffer pool mutex is owned. */
#define buf_pool_mutex_own(b) mutex_own(&b->mutex)
/** Acquire a buffer pool mutex. */
-#define buf_pool_mutex_enter(b) do { \
- ut_ad(!mutex_own(&b->zip_mutex)); \
- mutex_enter(&b->mutex); \
+#define buf_pool_mutex_enter(b) do { \
+ ut_ad(!(b)->zip_mutex.is_owned()); \
+ mutex_enter(&(b)->mutex); \
} while (0)
/** Test if flush list mutex is owned. */
-#define buf_flush_list_mutex_own(b) mutex_own(&b->flush_list_mutex)
+#define buf_flush_list_mutex_own(b) mutex_own(&(b)->flush_list_mutex)
/** Acquire the flush list mutex. */
-#define buf_flush_list_mutex_enter(b) do { \
- mutex_enter(&b->flush_list_mutex); \
+#define buf_flush_list_mutex_enter(b) do { \
+ mutex_enter(&(b)->flush_list_mutex); \
} while (0)
/** Release the flush list mutex. */
-# define buf_flush_list_mutex_exit(b) do { \
- mutex_exit(&b->flush_list_mutex); \
+# define buf_flush_list_mutex_exit(b) do { \
+ mutex_exit(&(b)->flush_list_mutex); \
} while (0)
+
/** Test if block->mutex is owned. */
-#define buf_block_mutex_own(b) mutex_own(&(b)->mutex)
+#define buf_page_mutex_own(b) (b)->mutex.is_owned()
/** Acquire the block->mutex. */
-#define buf_block_mutex_enter(b) do { \
+#define buf_page_mutex_enter(b) do { \
mutex_enter(&(b)->mutex); \
} while (0)
/** Release the trx->mutex. */
-#define buf_block_mutex_exit(b) do { \
- mutex_exit(&(b)->mutex); \
+#define buf_page_mutex_exit(b) do { \
+ (b)->mutex.exit(); \
} while (0)
/** Get appropriate page_hash_lock. */
-# define buf_page_hash_lock_get(b, f) \
- hash_get_lock(b->page_hash, f)
+# define buf_page_hash_lock_get(buf_pool, page_id) \
+ hash_get_lock((buf_pool)->page_hash, (page_id).fold())
+
+/** If not appropriate page_hash_lock, relock until appropriate. */
+# define buf_page_hash_lock_s_confirm(hash_lock, buf_pool, page_id)\
+ hash_lock_s_confirm(hash_lock, (buf_pool)->page_hash, (page_id).fold())
-#ifdef UNIV_SYNC_DEBUG
+# define buf_page_hash_lock_x_confirm(hash_lock, buf_pool, page_id)\
+ hash_lock_x_confirm(hash_lock, (buf_pool)->page_hash, (page_id).fold())
+
+#ifdef UNIV_DEBUG
/** Test if page_hash lock is held in s-mode. */
-# define buf_page_hash_lock_held_s(b, p) \
- rw_lock_own(buf_page_hash_lock_get(b, \
- buf_page_address_fold(p->space, \
- p->offset)), \
- RW_LOCK_SHARED)
+# define buf_page_hash_lock_held_s(buf_pool, bpage) \
+ rw_lock_own(buf_page_hash_lock_get((buf_pool), (bpage)->id), RW_LOCK_S)
/** Test if page_hash lock is held in x-mode. */
-# define buf_page_hash_lock_held_x(b, p) \
- rw_lock_own(buf_page_hash_lock_get(b, \
- buf_page_address_fold(p->space, \
- p->offset)), \
- RW_LOCK_EX)
+# define buf_page_hash_lock_held_x(buf_pool, bpage) \
+ rw_lock_own(buf_page_hash_lock_get((buf_pool), (bpage)->id), RW_LOCK_X)
/** Test if page_hash lock is held in x or s-mode. */
-# define buf_page_hash_lock_held_s_or_x(b, p) \
- (buf_page_hash_lock_held_s(b, p) \
- || buf_page_hash_lock_held_x(b, p))
+# define buf_page_hash_lock_held_s_or_x(buf_pool, bpage)\
+ (buf_page_hash_lock_held_s((buf_pool), (bpage)) \
+ || buf_page_hash_lock_held_x((buf_pool), (bpage)))
-# define buf_block_hash_lock_held_s(b, p) \
- buf_page_hash_lock_held_s(b, &(p->page))
+# define buf_block_hash_lock_held_s(buf_pool, block) \
+ buf_page_hash_lock_held_s((buf_pool), &(block)->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_x(buf_pool, block) \
+ buf_page_hash_lock_held_x((buf_pool), &(block)->page)
-# define buf_block_hash_lock_held_s_or_x(b, p) \
- buf_page_hash_lock_held_s_or_x(b, &(p->page))
-#else /* UNIV_SYNC_DEBUG */
+# define buf_block_hash_lock_held_s_or_x(buf_pool, block) \
+ buf_page_hash_lock_held_s_or_x((buf_pool), &(block)->page)
+#else /* UNIV_DEBUG */
# define buf_page_hash_lock_held_s(b, p) (TRUE)
# define buf_page_hash_lock_held_x(b, p) (TRUE)
# define buf_page_hash_lock_held_s_or_x(b, p) (TRUE)
# define buf_block_hash_lock_held_s(b, p) (TRUE)
# define buf_block_hash_lock_held_x(b, p) (TRUE)
# define buf_block_hash_lock_held_s_or_x(b, p) (TRUE)
-#endif /* UNIV_SYNC_DEBUG */
+#endif /* UNIV_DEBUG */
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/** Forbid the release of the buffer pool mutex. */
@@ -2416,6 +2535,12 @@ struct CheckInLRUList {
{
ut_a(elem->in_LRU_list);
}
+
+ static void validate(const buf_pool_t* buf_pool)
+ {
+ CheckInLRUList check;
+ ut_list_validate(buf_pool->LRU, check);
+ }
};
/** Functor to validate the LRU list. */
@@ -2424,6 +2549,12 @@ struct CheckInFreeList {
{
ut_a(elem->in_free_list);
}
+
+ static void validate(const buf_pool_t* buf_pool)
+ {
+ CheckInFreeList check;
+ ut_list_validate(buf_pool->free, check);
+ }
};
struct CheckUnzipLRUAndLRUList {
@@ -2432,11 +2563,18 @@ struct CheckUnzipLRUAndLRUList {
ut_a(elem->page.in_LRU_list);
ut_a(elem->in_unzip_LRU_list);
}
+
+ static void validate(const buf_pool_t* buf_pool)
+ {
+ CheckUnzipLRUAndLRUList check;
+ ut_list_validate(buf_pool->unzip_LRU, check);
+ }
};
#endif /* UNIV_DEBUG || defined UNIV_BUF_DEBUG */
#ifndef UNIV_NONINL
#include "buf0buf.ic"
#endif
+#endif /* !UNIV_INNOCHECKSUM */
#endif