36 #ifndef UNIV_HOTBACKUP
44 #define BUF_GET_IF_IN_POOL 11
45 #define BUF_PEEK_IF_IN_POOL 12
47 #define BUF_GET_NO_LATCH 14
53 #define BUF_GET_IF_IN_POOL_OR_WATCH 15
57 #define BUF_GET_POSSIBLY_FREED 16
63 #define BUF_MAKE_YOUNG 51
68 #define BUF_KEEP_OLD 52
72 #define MAX_BUFFER_POOLS_BITS 6
75 #define MAX_BUFFER_POOLS (1 << MAX_BUFFER_POOLS_BITS)
79 #define BUF_POOL_WATCH_SIZE (srv_n_purge_threads + 1)
82 #define MAX_PAGE_HASH_LOCKS 1024
85 extern buf_pool_t* buf_pool_ptr;
92 extern ulint srv_buf_pool_instances;
93 extern ulint srv_buf_pool_curr_size;
100 #define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
209 #ifndef UNIV_HOTBACKUP
261 __attribute__((nonnull));
292 __attribute__((malloc));
300 __attribute__((nonnull));
329 #ifndef UNIV_HOTBACKUP
334 #define buf_page_get(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
335 SP, ZS, OF, LA, NULL,\
336 BUF_GET, __FILE__, __LINE__, MTR)
343 #define buf_page_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
344 SP, ZS, OF, RW_NO_LATCH, NULL,\
345 BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
356 ib_uint64_t modify_clock,
395 #define buf_page_try_get(space_id, page_no, mtr) \
396 buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
453 buf_page_init_for_backup_restore(
463 #ifndef UNIV_HOTBACKUP
503 #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
537 __attribute__((pure));
546 __attribute__((pure));
604 # ifdef UNIV_SYNC_DEBUG
609 __attribute__((nonnull));
627 # ifdef UNIV_SYNC_DEBUG
632 # define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(f,l,b)
638 # define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(b)
641 # define buf_block_modify_clock_inc(block) ((void) 0)
652 const byte* read_buf,
655 __attribute__((nonnull, warn_unused_result));
662 const byte* read_buf,
663 const ulint zip_size);
665 #ifndef UNIV_HOTBACKUP
685 __attribute__((pure));
709 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
718 #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
740 const byte* read_buf,
746 UNIV_COLD __attribute__((nonnull));
756 #ifndef UNIV_HOTBACKUP
842 #ifdef UNIV_SYNC_DEBUG
855 # define buf_block_dbg_add_level(block, level)
873 __attribute__((pure));
898 __attribute__((pure));
899 #ifndef UNIV_HOTBACKUP
908 __attribute__((pure));
918 __attribute__((pure));
928 __attribute__((pure));
954 __attribute__((pure));
963 __attribute__((pure));
1009 __attribute__((pure));
1019 __attribute__((pure));
1036 __attribute__((nonnull, pure));
1044 __attribute__((nonnull));
1055 __attribute__((pure));
1066 __attribute__((pure));
1068 # define buf_block_get_frame(block) (block)->frame
1078 __attribute__((pure));
1087 __attribute__((pure));
1096 __attribute__((pure));
1105 __attribute__((pure));
1114 __attribute__((pure));
1123 __attribute__((pure));
1127 #define buf_block_get_page_zip(block) \
1128 ((block)->page.zip.data ? &(block)->page.zip : NULL)
1129 #ifndef UNIV_HOTBACKUP
1151 #define buf_pool_is_block_mutex(m) \
1152 buf_pointer_is_block_field((const void*)(m))
1156 #define buf_pool_is_block_lock(l) \
1157 buf_pointer_is_block_field((const void*)(l))
1159 #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
1189 ib_int64_t tablespace_version,
1212 __attribute__((
const));
1221 __attribute__((nonnull,
const));
1293 bool watch =
false);
1328 #define buf_page_hash_get_s_locked(b, s, o, l) \
1329 buf_page_hash_get_locked(b, s, o, l, RW_LOCK_SHARED)
1330 #define buf_page_hash_get_x_locked(b, s, o, l) \
1331 buf_page_hash_get_locked(b, s, o, l, RW_LOCK_EX)
1332 #define buf_page_hash_get(b, s, o) \
1333 buf_page_hash_get_locked(b, s, o, NULL, 0)
1334 #define buf_page_get_also_watch(b, s, o) \
1335 buf_page_hash_get_locked(b, s, o, NULL, 0, true)
1337 #define buf_block_hash_get_s_locked(b, s, o, l) \
1338 buf_block_hash_get_locked(b, s, o, l, RW_LOCK_SHARED)
1339 #define buf_block_hash_get_x_locked(b, s, o, l) \
1340 buf_block_hash_get_locked(b, s, o, l, RW_LOCK_EX)
1341 #define buf_block_hash_get(b, s, o) \
1342 buf_block_hash_get_locked(b, s, o, NULL, 0)
1361 __attribute__((nonnull, warn_unused_result));
1372 __attribute__((warn_unused_result));
1393 __attribute__((warn_unused_result));
1402 ulint* flush_list_len);
1445 #define BUF_PAGE_STATE_BITS 3
1461 #ifdef PAGE_ATOMIC_REF_COUNT
1487 #ifndef UNIV_HOTBACKUP
1494 # if MAX_BUFFER_POOLS > 64
1495 # error "MAX_BUFFER_POOLS > 64; redefine buf_pool_index:6"
1505 #ifndef UNIV_HOTBACKUP
1609 # if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
1634 #ifndef UNIV_HOTBACKUP
1715 #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1735 # ifdef UNIV_SYNC_DEBUG
1750 #define buf_block_state_valid(block) \
1751 (buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
1752 && (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
1754 #ifndef UNIV_HOTBACKUP
1758 #define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE)
1759 #define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
1760 #define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
1793 ulint n_pages_created;
1795 ulint n_ra_pages_read_rnd;
1797 ulint n_ra_pages_read;
1799 ulint n_ra_pages_evicted;
1802 ulint n_pages_made_young;
1804 ulint n_pages_not_made_young;
1841 ulint LRU_old_ratio;
1844 ulint buddy_n_frames;
1847 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1872 time_t last_printout_time;
1905 ulint n_flush[BUF_FLUSH_N_TYPES];
1926 ulint freed_page_clock;
1980 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1992 #if BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN
1993 # error "BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN"
2003 #define buf_pool_mutex_own(b) mutex_own(&b->mutex)
2005 #define buf_pool_mutex_enter(b) do { \
2006 ut_ad(!mutex_own(&b->zip_mutex)); \
2007 mutex_enter(&b->mutex); \
2011 #define buf_flush_list_mutex_own(b) mutex_own(&b->flush_list_mutex)
2014 #define buf_flush_list_mutex_enter(b) do { \
2015 mutex_enter(&b->flush_list_mutex); \
2018 # define buf_flush_list_mutex_exit(b) do { \
2019 mutex_exit(&b->flush_list_mutex); \
2023 #define buf_block_mutex_own(b) mutex_own(&(b)->mutex)
2026 #define buf_block_mutex_enter(b) do { \
2027 mutex_enter(&(b)->mutex); \
2031 #define buf_block_mutex_exit(b) do { \
2032 mutex_exit(&(b)->mutex); \
2037 # define buf_page_hash_lock_get(b, f) \
2038 hash_get_lock(b->page_hash, f)
2040 #ifdef UNIV_SYNC_DEBUG
2042 # define buf_page_hash_lock_held_s(b, p) \
2043 rw_lock_own(buf_page_hash_lock_get(b, \
2044 buf_page_address_fold(p->space, \
2049 # define buf_page_hash_lock_held_x(b, p) \
2050 rw_lock_own(buf_page_hash_lock_get(b, \
2051 buf_page_address_fold(p->space, \
2056 # define buf_page_hash_lock_held_s_or_x(b, p) \
2057 (buf_page_hash_lock_held_s(b, p) \
2058 || buf_page_hash_lock_held_x(b, p))
2060 # define buf_block_hash_lock_held_s(b, p) \
2061 buf_page_hash_lock_held_s(b, &(p->page))
2063 # define buf_block_hash_lock_held_x(b, p) \
2064 buf_page_hash_lock_held_x(b, &(p->page))
2066 # define buf_block_hash_lock_held_s_or_x(b, p) \
2067 buf_page_hash_lock_held_s_or_x(b, &(p->page))
2069 # define buf_page_hash_lock_held_s(b, p) (TRUE)
2070 # define buf_page_hash_lock_held_x(b, p) (TRUE)
2071 # define buf_page_hash_lock_held_s_or_x(b, p) (TRUE)
2072 # define buf_block_hash_lock_held_s(b, p) (TRUE)
2073 # define buf_block_hash_lock_held_x(b, p) (TRUE)
2074 # define buf_block_hash_lock_held_s_or_x(b, p) (TRUE)
2077 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
2079 # define buf_pool_mutex_exit_forbid(b) do { \
2080 ut_ad(buf_pool_mutex_own(b)); \
2081 b->mutex_exit_forbidden++; \
2084 # define buf_pool_mutex_exit_allow(b) do { \
2085 ut_ad(buf_pool_mutex_own(b)); \
2086 ut_a(b->mutex_exit_forbidden); \
2087 b->mutex_exit_forbidden--; \
2090 # define buf_pool_mutex_exit(b) do { \
2091 ut_a(!b->mutex_exit_forbidden); \
2092 mutex_exit(&b->mutex); \
2096 # define buf_pool_mutex_exit_forbid(b) ((void) 0)
2098 # define buf_pool_mutex_exit_allow(b) ((void) 0)
2100 # define buf_pool_mutex_exit(b) mutex_exit(&b->mutex)
2149 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
2152 void operator()(
const buf_page_t* elem)
const
2160 void operator()(
const buf_page_t* elem)
const