drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
buf0buf.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
25
26#pragma once
27#ifndef buf0buf_h
28#define buf0buf_h
29
30#include "univ.i"
31#include "fil0fil.h"
32#include "mtr0types.h"
33#include "buf0types.h"
34#include "hash0hash.h"
35#include "ut0byte.h"
36#include "page0types.h"
37#ifndef UNIV_HOTBACKUP
38#include "ut0rbt.h"
39#include "os0proc.h"
40
42/* @{ */
43#define BUF_GET 10
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/* @} */
59/* @{ */
60#define BUF_MAKE_YOUNG 51
65#define BUF_KEEP_OLD 52
67/* @} */
68
69#define MAX_BUFFER_POOLS 64
71
72#define BUF_POOL_WATCH_SIZE 1
74
75extern buf_pool_t* buf_pool_ptr;
77#ifdef UNIV_DEBUG
78extern ibool buf_debug_prints;
81#endif /* UNIV_DEBUG */
82#else /* !UNIV_HOTBACKUP */
83extern buf_block_t* back_block1;
84extern buf_block_t* back_block2;
85#endif /* !UNIV_HOTBACKUP */
86
88#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
89
117
118
122 /* General buffer pool info */
124 ulint pool_size;
125 ulint lru_len;
151
152 /* Buffer pool access stats */
166
167 /* Statistics about read ahead algorithm. */
172
173 /* Stats about LRU eviction */
176 /* Counters for LRU policy */
177 ulint io_sum;
178 ulint io_cur;
180 ulint unzip_sum;
181 ulint unzip_cur;
184};
185
186typedef struct buf_pool_info_struct buf_pool_info_t;
187
188#ifndef UNIV_HOTBACKUP
189/********************************************************************/
191UNIV_INLINE
192void
194/*===========================*/
195
196/********************************************************************/
198UNIV_INLINE
199void
201/*==========================*/
202
203/********************************************************************/
206UNIV_INTERN
207ulint
209/*=========*/
210 ulint size,
211 ulint n_instances);
212/********************************************************************/
215UNIV_INTERN
216void
218/*==========*/
219 ulint n_instances);
220
221/********************************************************************/
225UNIV_INTERN
226void
228/*==========================*/
229
230/********************************************************************/
234UNIV_INTERN
235void
237/*=========*/
238 buf_page_t* bpage,
241 buf_page_t* dpage)
242 __attribute__((nonnull));
243/********************************************************************/
245UNIV_INTERN
246void
247buf_pool_resize(void);
248/*=================*/
249/*********************************************************************/
252UNIV_INLINE
253ulint
255/*========================*/
256/*********************************************************************/
259UNIV_INLINE
260ulint
262/*=======================*/
263/********************************************************************/
267UNIV_INTERN
268ib_uint64_t
270/*==================================*/
271/********************************************************************/
274UNIV_INTERN
277/*============*/
278 buf_pool_t* buf_pool);
281/********************************************************************/
283UNIV_INLINE
284void
286/*===========*/
287 buf_block_t* block);
288#endif /* !UNIV_HOTBACKUP */
289/*********************************************************************/
292UNIV_INLINE
293byte*
295/*===========*/
296 byte* buf,
297 const buf_frame_t* frame);
298#ifndef UNIV_HOTBACKUP
299/**************************************************************/
303#define buf_page_get(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
304 SP, ZS, OF, LA, NULL,\
305 BUF_GET, __FILE__, __LINE__, MTR)
306/**************************************************************/
312#define buf_page_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
313 SP, ZS, OF, RW_NO_LATCH, NULL,\
314 BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
315/********************************************************************/
319UNIV_INTERN
320ibool
322/*====================*/
323 ulint rw_latch,
324 buf_block_t* block,
325 ib_uint64_t modify_clock,
327 const char* file,
328 ulint line,
329 mtr_t* mtr);
330/********************************************************************/
334UNIV_INTERN
335ibool
337/*======================*/
338 ulint rw_latch,
339 buf_block_t* block,
340 ulint mode,
341 const char* file,
342 ulint line,
343 mtr_t* mtr);
344
345/*******************************************************************/
349UNIV_INTERN
350const buf_block_t*
352/*==================*/
353 ulint space_id,
354 ulint page_no,
355 const char* file,
356 ulint line,
357 mtr_t* mtr);
358
365#define buf_page_try_get(space_id, page_no, mtr) \
366 buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
367
368/********************************************************************/
377UNIV_INTERN
380/*=============*/
381 ulint space,
382 ulint zip_size,
383 ulint offset);
384/********************************************************************/
387UNIV_INTERN
390/*=============*/
391 ulint space,
392 ulint zip_size,
394 ulint offset,
395 ulint rw_latch,
396 buf_block_t* guess,
397 ulint mode,
400 const char* file,
401 ulint line,
402 mtr_t* mtr);
403/********************************************************************/
409UNIV_INTERN
412/*============*/
413 ulint space,
414 ulint offset,
416 ulint zip_size,
417 mtr_t* mtr);
418#else /* !UNIV_HOTBACKUP */
419/********************************************************************/
421UNIV_INTERN
422void
423buf_page_init_for_backup_restore(
424/*=============================*/
425 ulint space,
426 ulint offset,
428 ulint zip_size,
430 buf_block_t* block);
431#endif /* !UNIV_HOTBACKUP */
432
433#ifndef UNIV_HOTBACKUP
434/********************************************************************/
436UNIV_INLINE
437void
439/*=================*/
440 buf_page_t* bpage);
441/********************************************************************/
444UNIV_INLINE
445void
447/*=============*/
448 buf_block_t* block,
449 ulint rw_latch);
451/********************************************************************/
455UNIV_INTERN
456void
458/*================*/
459 buf_page_t* bpage);
460/********************************************************************/
467UNIV_INLINE
468ibool
470/*==========*/
471 ulint space,
472 ulint offset);
473/********************************************************************/
476UNIV_INTERN
477void
479/*================================*/
480 ulint space,
481 ulint offset);
482#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
483/********************************************************************/
489UNIV_INTERN
491buf_page_set_file_page_was_freed(
492/*=============================*/
493 ulint space,
494 ulint offset);
495/********************************************************************/
501UNIV_INTERN
503buf_page_reset_file_page_was_freed(
504/*===============================*/
505 ulint space,
506 ulint offset);
507#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
508/********************************************************************/
511UNIV_INLINE
512ulint
514/*==========================*/
515 const buf_page_t* bpage)
516 __attribute__((pure));
517/********************************************************************/
520UNIV_INLINE
521ulint
523/*===========================*/
524 const buf_block_t* block)
525 __attribute__((pure));
526
527/********************************************************************/
532UNIV_INLINE
533ibool
535/*=====================*/
536 const buf_page_t* bpage);
537/********************************************************************/
542UNIV_INTERN
543ibool
545/*===========================*/
546 ulint space,
547 ulint offset);
548/********************************************************************/
552UNIV_INLINE
553ib_uint64_t
555/*=============================*/
556 const buf_page_t* bpage);
558/********************************************************************/
562UNIV_INLINE
563void
565/*=======================*/
566 buf_block_t* block);
567/********************************************************************/
571UNIV_INLINE
572ib_uint64_t
574/*=======================*/
575 buf_block_t* block);
576#else /* !UNIV_HOTBACKUP */
577# define buf_block_modify_clock_inc(block) ((void) 0)
578#endif /* !UNIV_HOTBACKUP */
579/********************************************************************/
584UNIV_INTERN
585ulint
587/*=======================*/
588 const byte* page);
589/********************************************************************/
597UNIV_INTERN
598ulint
600/*=======================*/
601 const byte* page);
602/********************************************************************/
605UNIV_INTERN
606ibool
608/*==================*/
609 const byte* read_buf,
610 ulint zip_size);
612#ifndef UNIV_HOTBACKUP
613/**********************************************************************/
616UNIV_INLINE
617void
619/*=================*/
620 const void* ptr,
621 ulint* space,
622 fil_addr_t* addr);
623/**********************************************************************/
627UNIV_INLINE
628ulint
630/*========================*/
631 const buf_block_t* block)
632 __attribute__((pure));
633#ifdef UNIV_DEBUG
634/*********************************************************************/
638UNIV_INTERN
640buf_pool_contains_zip(
641/*==================*/
642 buf_pool_t* buf_pool,
643 const void* data);
644#endif /* UNIV_DEBUG */
645#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
646/*********************************************************************/
649UNIV_INTERN
650ibool
651buf_validate(void);
652/*==============*/
653#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
654#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
655/*********************************************************************/
657UNIV_INTERN
658void
659buf_print(void);
660/*============*/
661#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
662#endif /* !UNIV_HOTBACKUP */
663/********************************************************************/
665UNIV_INTERN
666void
668/*===========*/
669 const byte* read_buf,
670 ulint zip_size);
672/********************************************************************/
675UNIV_INTERN
676ibool
678/*===============*/
679 buf_block_t* block,
680 ibool check);
681#ifndef UNIV_HOTBACKUP
682#ifdef UNIV_DEBUG
683/*********************************************************************/
686UNIV_INTERN
687ulint
688buf_get_latched_pages_number(void);
689/*==============================*/
690#endif /* UNIV_DEBUG */
691/*********************************************************************/
694UNIV_INTERN
695ulint
697/*=======================*/
698/*********************************************************************/
700UNIV_INTERN
701void
703/*=========*/
704 FILE* file);
705/*********************************************************************/
709UNIV_INTERN
710ulint
712/*============================*/
713/**********************************************************************/
715UNIV_INTERN
716void
718/*=================*/
719 buf_pool_t* buf_pool);
720/**********************************************************************/
722UNIV_INTERN
723void
725/*=================*/
726/*********************************************************************/
729UNIV_INTERN
730ibool
731buf_all_freed(void);
732/*===============*/
733/*********************************************************************/
737UNIV_INTERN
738ibool
740/*==============================*/
741/*********************************************************************/
745UNIV_INTERN
746void
748/*=====================*/
749#endif /* !UNIV_HOTBACKUP */
750
751/*========================================================================
752--------------------------- LOWER LEVEL ROUTINES -------------------------
753=========================================================================*/
754
755#ifdef UNIV_SYNC_DEBUG
756/*********************************************************************/
760UNIV_INLINE
761void
762buf_block_dbg_add_level(
763/*====================*/
764 buf_block_t* block,
766 ulint level);
767#else /* UNIV_SYNC_DEBUG */
768# define buf_block_dbg_add_level(block, level) /* nothing */
769#endif /* UNIV_SYNC_DEBUG */
770/*********************************************************************/
773UNIV_INLINE
776/*===============*/
777 const buf_page_t* bpage);
778/*********************************************************************/
781UNIV_INLINE
784/*================*/
785 const buf_block_t* block)
786 __attribute__((pure));
787/*********************************************************************/
789UNIV_INLINE
790void
792/*===============*/
793 buf_page_t* bpage,
794 enum buf_page_state state);
795/*********************************************************************/
797UNIV_INLINE
798void
800/*================*/
801 buf_block_t* block,
802 enum buf_page_state state);
803/*********************************************************************/
806UNIV_INLINE
807ibool
809/*=============*/
810 const buf_page_t* bpage)
811 __attribute__((pure));
812#ifndef UNIV_HOTBACKUP
813/*********************************************************************/
816UNIV_INLINE
817ibool
819/*==========================*/
820 const buf_page_t* bpage)
821 __attribute__((pure));
822
823/*********************************************************************/
826UNIV_INLINE
827mutex_t*
829/*===============*/
830 const buf_page_t* bpage)
831 __attribute__((pure));
832
833/*********************************************************************/
836UNIV_INLINE
837enum buf_flush
839/*====================*/
840 const buf_page_t* bpage)
841 __attribute__((pure));
842/*********************************************************************/
844UNIV_INLINE
845void
847/*====================*/
848 buf_page_t* bpage,
849 enum buf_flush flush_type);
850/*********************************************************************/
852UNIV_INLINE
853void
855/*====================*/
856 buf_block_t* block,
857 ulint space,
858 ulint page_no);
859/*********************************************************************/
862UNIV_INLINE
863enum buf_io_fix
865/*================*/
866 const buf_page_t* bpage)
867 __attribute__((pure));
868/*********************************************************************/
871UNIV_INLINE
872enum buf_io_fix
874/*================*/
875 const buf_block_t* block)
876 __attribute__((pure));
877/*********************************************************************/
879UNIV_INLINE
880void
882/*================*/
883 buf_page_t* bpage,
884 enum buf_io_fix io_fix);
885/*********************************************************************/
887UNIV_INLINE
888void
890/*=================*/
891 buf_block_t* block,
892 enum buf_io_fix io_fix);
893
894/********************************************************************/
897UNIV_INLINE
898ibool
900/*==================*/
901 const buf_page_t* bpage)
902 __attribute__((pure));
903
904/*********************************************************************/
907UNIV_INLINE
908ibool
910/*============*/
911 const buf_page_t* bpage)
912 __attribute__((pure));
913/*********************************************************************/
915UNIV_INLINE
916void
918/*=============*/
919 buf_page_t* bpage,
920 ibool old);
921/*********************************************************************/
924UNIV_INLINE
925unsigned
927/*=================*/
928 const buf_page_t* bpage)
929 __attribute__((nonnull, pure));
930/*********************************************************************/
932UNIV_INLINE
933void
935/*==================*/
936 buf_page_t* bpage,
937 ulint time_ms)
938 __attribute__((nonnull));
939/*********************************************************************/
944UNIV_INLINE
947/*===============*/
948 buf_page_t* bpage)
949 __attribute__((pure));
950#endif /* !UNIV_HOTBACKUP */
951#ifdef UNIV_DEBUG
952/*********************************************************************/
955UNIV_INLINE
957buf_block_get_frame(
958/*================*/
959 const buf_block_t* block)
960 __attribute__((pure));
961#else /* UNIV_DEBUG */
962# define buf_block_get_frame(block) (block)->frame
963#endif /* UNIV_DEBUG */
964/*********************************************************************/
967UNIV_INLINE
968ulint
970/*===============*/
971 const buf_page_t* bpage)
972 __attribute__((pure));
973/*********************************************************************/
976UNIV_INLINE
977ulint
979/*================*/
980 const buf_block_t* block)
981 __attribute__((pure));
982/*********************************************************************/
985UNIV_INLINE
986ulint
988/*=================*/
989 const buf_page_t* bpage)
990 __attribute__((pure));
991/*********************************************************************/
994UNIV_INLINE
995ulint
997/*==================*/
998 const buf_block_t* block)
999 __attribute__((pure));
1000/*********************************************************************/
1003UNIV_INLINE
1004ulint
1006/*==================*/
1007 const buf_page_t* bpage)
1008 __attribute__((pure));
1009/*********************************************************************/
1012UNIV_INLINE
1013ulint
1015/*===================*/
1016 const buf_block_t* block)
1017 __attribute__((pure));
1018/*********************************************************************/
1021#define buf_block_get_page_zip(block) \
1022 (UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL)
1023#ifndef UNIV_HOTBACKUP
1024/*******************************************************************/
1027UNIV_INTERN
1030/*============*/
1031 const byte* ptr);
1032/********************************************************************/
1036UNIV_INTERN
1037ibool
1039/*=======================*/
1040 const void* ptr);
1045#define buf_pool_is_block_mutex(m) \
1046 buf_pointer_is_block_field((const void*)(m))
1047
1050#define buf_pool_is_block_lock(l) \
1051 buf_pointer_is_block_field((const void*)(l))
1052
1053#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
1054/*********************************************************************/
1058UNIV_INLINE
1059const page_zip_des_t*
1060buf_frame_get_page_zip(
1061/*===================*/
1062 const byte* ptr);
1063#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
1064/********************************************************************/
1074UNIV_INTERN
1077/*===================*/
1078 ulint* err,
1079 ulint mode,
1080 ulint space,
1081 ulint zip_size,
1082 ibool unzip,
1083 ib_int64_t tablespace_version,
1086 ulint offset);
1087/********************************************************************/
1090UNIV_INTERN
1091void
1093/*=================*/
1094 buf_page_t* bpage);
1095/********************************************************************/
1099UNIV_INLINE
1100ulint
1102/*==================*/
1103 ulint space,
1104 ulint offset)
1105 __attribute__((const));
1106/********************************************************************/
1109UNIV_INLINE
1110ulint
1112/*===========*/
1113 const buf_pool_t* buf_pool)
1114 __attribute__((nonnull, const));
1115/******************************************************************/
1118UNIV_INLINE
1121/*================*/
1122 const buf_page_t* bpage);
1123/******************************************************************/
1126UNIV_INLINE
1129/*================*/
1130 const buf_block_t* block);
1131/******************************************************************/
1134UNIV_INLINE
1137/*==========*/
1138 ulint space,
1139 ulint offset);
1140/******************************************************************/
1143UNIV_INLINE
1146/*================*/
1147 ulint index);
1149/******************************************************************/
1152UNIV_INLINE
1155/*==================*/
1156 buf_pool_t* buf_pool,
1157 ulint space,
1158 ulint offset,
1160 ulint fold);
1162/******************************************************************/
1165UNIV_INLINE
1168/*==============*/
1169 buf_pool_t* buf_pool,
1170 ulint space,
1171 ulint offset);
1173/******************************************************************/
1177UNIV_INLINE
1180/*===============*/
1181 buf_pool_t* buf_pool,
1182 ulint space,
1183 ulint offset);
1185/*********************************************************************/
1188UNIV_INTERN
1189ulint
1191/*=======================*/
1192
1193/********************************************************************
1194Determine if a block is a sentinel for a buffer pool watch.
1195@return TRUE if a sentinel for a buffer pool watch, FALSE if not */
1196UNIV_INTERN
1197ibool
1199/*=======================*/
1200 buf_pool_t* buf_pool,
1201 const buf_page_t* bpage)
1202 UNIV_WARN_UNUSED_RESULT;
1203/****************************************************************/
1206UNIV_INTERN
1209/*===============*/
1210 ulint space,
1211 ulint offset,
1212 ulint fold)
1213 UNIV_WARN_UNUSED_RESULT;
1214/****************************************************************/
1217UNIV_INTERN
1218void
1220/*=================*/
1221 ulint space,
1222 ulint offset);
1223/****************************************************************/
1228UNIV_INTERN
1229ibool
1231/*====================*/
1232 ulint space,
1233 ulint offset)
1234 UNIV_WARN_UNUSED_RESULT;
1235/********************************************************************/
1237UNIV_INTERN
1238void
1240/*===================*/
1241 ulint* LRU_len,
1242 ulint* free_len,
1243 ulint* flush_list_len);
1244/********************************************************************/
1246UNIV_INTERN
1247void
1249/*===============*/
1250 buf_pool_stat_t*tot_stat);
1251
1252#endif /* !UNIV_HOTBACKUP */
1253
1256
1264 /* @{ */
1265
1266 unsigned space:32;
1268 unsigned offset:32;
1270
1271 unsigned state:3;
1278#ifndef UNIV_HOTBACKUP
1279 unsigned flush_type:2;
1283 unsigned io_fix:2;
1286 unsigned buf_fix_count:19;
1288 unsigned buf_pool_index:6;
1290# if MAX_BUFFER_POOLS > 64
1291# error "MAX_BUFFER_POOLS > 64; redefine buf_pool_index:6"
1292# endif
1293 /* @} */
1294#endif /* !UNIV_HOTBACKUP */
1301#ifndef UNIV_HOTBACKUP
1305#ifdef UNIV_DEBUG
1306 ibool in_page_hash;
1307 ibool in_zip_hash;
1308#endif /* UNIV_DEBUG */
1309
1312 /* @{ */
1313
1341
1342#ifdef UNIV_DEBUG
1343 ibool in_flush_list;
1354 ibool in_free_list;
1358#endif /* UNIV_DEBUG */
1378 /* @} */
1382 /* @{ */
1383
1386#ifdef UNIV_DEBUG
1387 ibool in_LRU_list;
1390#endif /* UNIV_DEBUG */
1391 unsigned old:1;
1393 unsigned freed_page_clock:31;
1401 unsigned access_time:32;
1404 /* @} */
1405# if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
1406 ibool file_page_was_freed;
1409# endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
1410#endif /* !UNIV_HOTBACKUP */
1411};
1412
1414
1416
1418 /* @{ */
1419
1424 byte* frame;
1428#ifndef UNIV_HOTBACKUP
1434#ifdef UNIV_DEBUG
1435 ibool in_unzip_LRU_list;
1438#endif /* UNIV_DEBUG */
1445 rw_lock_t lock;
1447 unsigned lock_hash_val:32;
1463 /* @} */
1465 /* @{ */
1466
1467 ib_uint64_t modify_clock;
1478 /* @} */
1481 /* @{ */
1482
1485 ulint n_fields;
1487 ulint n_bytes;
1493 /* @} */
1494
1503
1504 /* @{ */
1505
1506#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1507 ulint n_pointers;
1510#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
1511 unsigned is_hashed:1;
1518 unsigned curr_n_fields:10;
1520 unsigned curr_n_bytes:15;
1522 unsigned curr_left_side:1;
1523 dict_index_t* index;
1525 /* @} */
1526# ifdef UNIV_SYNC_DEBUG
1528 /* @{ */
1529 rw_lock_t debug_latch;
1533 /* @} */
1534# endif
1535#endif /* !UNIV_HOTBACKUP */
1536};
1537
1541#define buf_block_state_valid(block) \
1542(buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
1543 && (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
1544
1545#ifndef UNIV_HOTBACKUP
1546/**********************************************************************/
1548/* @{ */
1549#define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE)
1550#define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
1551#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
1552/* @} */
1553
1578
1582 ulint used;
1584 ib_uint64_t relocated;
1586 ib_uint64_t relocated_usec;
1587};
1588
1593
1595
1597 /* @{ */
1610#ifdef UNIV_DEBUG
1611 ulint buddy_n_frames;
1613#endif
1614#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1615 ulint mutex_exit_forbidden;
1616#endif
1617 ulint n_chunks;
1620 hash_table_t* page_hash;
1624 hash_table_t* zip_hash;
1631
1635 buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES_MAX + 1];
1640
1641 /* @} */
1642
1644
1645 /* @{ */
1646
1667 ib_rbt_t* flush_rbt;
1694 /* @} */
1695
1697 /* @{ */
1698
1718
1722
1723 /* @} */
1728 /* @{ */
1731 UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES_MAX];
1733
1738
1739#if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
1740# error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
1741#endif
1742 /* @} */
1743};
1744
1747/* @{ */
1748
1750#define buf_pool_mutex_own(b) mutex_own(&b->mutex)
1752#define buf_pool_mutex_enter(b) do { \
1753 ut_ad(!mutex_own(&b->zip_mutex)); \
1754 mutex_enter(&b->mutex); \
1755} while (0)
1756
1758#define buf_flush_list_mutex_own(b) mutex_own(&b->flush_list_mutex)
1759
1761#define buf_flush_list_mutex_enter(b) do { \
1762 mutex_enter(&b->flush_list_mutex); \
1763} while (0)
1764
1765# define buf_flush_list_mutex_exit(b) do { \
1766 mutex_exit(&b->flush_list_mutex); \
1767} while (0)
1768
1769
1770
1771#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1773# define buf_pool_mutex_exit_forbid(b) do { \
1774 ut_ad(buf_pool_mutex_own(b)); \
1775 b->mutex_exit_forbidden++; \
1776} while (0)
1778# define buf_pool_mutex_exit_allow(b) do { \
1779 ut_ad(buf_pool_mutex_own(b)); \
1780 ut_a(b->mutex_exit_forbidden); \
1781 b->mutex_exit_forbidden--; \
1782} while (0)
1784# define buf_pool_mutex_exit(b) do { \
1785 ut_a(!b->mutex_exit_forbidden); \
1786 mutex_exit(&b->mutex); \
1787} while (0)
1788#else
1790# define buf_pool_mutex_exit_forbid(b) ((void) 0)
1792# define buf_pool_mutex_exit_allow(b) ((void) 0)
1794# define buf_pool_mutex_exit(b) mutex_exit(&b->mutex)
1795#endif
1796#endif /* !UNIV_HOTBACKUP */
1797/* @} */
1798
1799/**********************************************************************
1800Let us list the consistency conditions for different control block states.
1801
1802NOT_USED: is in free list, not in LRU list, not in flush list, nor
1803 page hash table
1804READY_FOR_USE: is not in free list, LRU list, or flush list, nor page
1805 hash table
1806MEMORY: is not in free list, LRU list, or flush list, nor page
1807 hash table
1808FILE_PAGE: space and offset are defined, is in page hash table
1809 if io_fix == BUF_IO_WRITE,
1810 pool: no_flush[flush_type] is in reset state,
1811 pool: n_flush[flush_type] > 0
1812
1813 (1) if buf_fix_count == 0, then
1814 is in LRU list, not in free list
1815 is in flush list,
1816 if and only if oldest_modification > 0
1817 is x-locked,
1818 if and only if io_fix == BUF_IO_READ
1819 is s-locked,
1820 if and only if io_fix == BUF_IO_WRITE
1821
1822 (2) if buf_fix_count > 0, then
1823 is not in LRU list, not in free list
1824 is in flush list,
1825 if and only if oldest_modification > 0
1826 if io_fix == BUF_IO_READ,
1827 is x-locked
1828 if io_fix == BUF_IO_WRITE,
1829 is s-locked
1830
1831State transitions:
1832
1833NOT_USED => READY_FOR_USE
1834READY_FOR_USE => MEMORY
1835READY_FOR_USE => FILE_PAGE
1836MEMORY => NOT_USED
1837FILE_PAGE => NOT_USED NOTE: This transition is allowed if and only if
1838 (1) buf_fix_count == 0,
1839 (2) oldest_modification == 0, and
1840 (3) io_fix == 0.
1841*/
1842
1843#ifndef UNIV_NONINL
1844#include "buf0buf.ic"
1845#endif
1846
1847#endif
UNIV_INLINE buf_pool_t * buf_pool_from_bpage(const buf_page_t *bpage)
UNIV_INLINE ib_uint64_t buf_page_get_newest_modification(const buf_page_t *bpage)
UNIV_INTERN ibool buf_pool_check_no_pending_io(void)
Definition buf0buf.cc:5197
UNIV_INLINE unsigned buf_page_is_accessed(const buf_page_t *bpage) __attribute__((nonnull
UNIV_INLINE ulint buf_pool_index(const buf_pool_t *buf_pool) __attribute__((nonnull
UNIV_INLINE buf_pool_t * buf_pool_from_block(const buf_block_t *block)
UNIV_INTERN void buf_pool_free(ulint n_instances)
Definition buf0buf.cc:1331
UNIV_INTERN ibool buf_pointer_is_block_field(const void *ptr)
Definition buf0buf.cc:2667
UNIV_INLINE ibool buf_page_peek(ulint space, ulint offset)
UNIV_INLINE ulint buf_block_get_freed_page_clock(const buf_block_t *block) __attribute__((pure))
UNIV_INTERN void buf_get_total_stat(buf_pool_stat_t *tot_stat)
Definition buf0buf.cc:387
UNIV_INTERN const buf_block_t * buf_page_try_get_func(ulint space_id, ulint page_no, const char *file, ulint line, mtr_t *mtr)
Definition buf0buf.cc:3371
UNIV_INLINE enum buf_flush buf_page_get_flush_type(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE ulint buf_pool_get_curr_size(void)
UNIV_INTERN ulint buf_calc_page_old_checksum(const byte *page)
Definition buf0buf.cc:485
UNIV_INLINE ulint buf_block_get_zip_size(const buf_block_t *block) __attribute__((pure))
UNIV_INTERN buf_page_t * buf_pool_watch_set(ulint space, ulint offset, ulint fold) UNIV_WARN_UNUSED_RESULT
Definition buf0buf.cc:1844
UNIV_INTERN ib_uint64_t buf_pool_get_oldest_modification(void)
Definition buf0buf.cc:315
UNIV_INLINE buf_pool_t * buf_pool_get(ulint space, ulint offset)
UNIV_INLINE ulint buf_page_address_fold(ulint space, ulint offset) __attribute__((const))
UNIV_INTERN void buf_page_make_young(buf_page_t *bpage)
Definition buf0buf.cc:2127
UNIV_INLINE void buf_ptr_get_fsp_addr(const void *ptr, ulint *space, fil_addr_t *addr)
UNIV_INLINE enum buf_page_state buf_block_get_state(const buf_block_t *block) __attribute__((pure))
UNIV_INLINE ulint buf_page_get_space(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE void buf_page_set_state(buf_page_t *bpage, enum buf_page_state state)
UNIV_INLINE ulint buf_block_get_lock_hash_val(const buf_block_t *block) __attribute__((pure))
UNIV_INTERN ibool buf_page_is_corrupted(const byte *read_buf, ulint zip_size)
Definition buf0buf.cc:503
UNIV_INLINE void buf_block_set_io_fix(buf_block_t *block, enum buf_io_fix io_fix)
#define BUF_POOL_WATCH_SIZE
Definition buf0buf.h:72
UNIV_INLINE buf_block_t * buf_page_get_block(buf_page_t *bpage) __attribute__((pure))
UNIV_INTERN void buf_reset_check_index_page_at_flush(ulint space, ulint offset)
Definition buf0buf.cc:2179
UNIV_INLINE enum buf_page_state buf_page_get_state(const buf_page_t *bpage)
UNIV_INTERN ibool buf_page_optimistic_get(ulint rw_latch, buf_block_t *block, ib_uint64_t modify_clock, const char *file, ulint line, mtr_t *mtr)
Definition buf0buf.cc:3149
UNIV_INLINE ib_uint64_t buf_block_get_modify_clock(buf_block_t *block)
UNIV_INTERN buf_block_t * buf_page_create(ulint space, ulint offset, ulint zip_size, mtr_t *mtr)
Definition buf0buf.cc:3794
UNIV_INLINE void buf_block_set_state(buf_block_t *block, enum buf_page_state state)
UNIV_INTERN void buf_pool_resize(void)
Definition buf0buf.cc:1985
UNIV_INLINE enum buf_io_fix buf_page_get_io_fix(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE void buf_block_free(buf_block_t *block)
UNIV_INTERN void buf_pool_drop_hash_index(void)
Definition buf0buf.cc:1423
UNIV_INLINE void buf_pool_mutex_exit_all(void)
UNIV_INLINE void buf_page_release(buf_block_t *block, ulint rw_latch)
UNIV_INTERN void buf_pool_invalidate(void)
Definition buf0buf.cc:4251
UNIV_INTERN void buf_refresh_io_stats_all(void)
Definition buf0buf.cc:5154
UNIV_INLINE ibool buf_page_can_relocate(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE void buf_page_release_zip(buf_page_t *bpage)
UNIV_INLINE ulint buf_block_get_space(const buf_block_t *block) __attribute__((pure))
UNIV_INTERN ibool buf_all_freed(void)
Definition buf0buf.cc:5173
UNIV_INTERN buf_page_t * buf_page_init_for_read(ulint *err, ulint mode, ulint space, ulint zip_size, ibool unzip, ib_int64_t tablespace_version, ulint offset)
Definition buf0buf.cc:3558
UNIV_INLINE buf_pool_t * buf_pool_from_array(ulint index)
UNIV_INLINE ulint buf_page_get_page_no(const buf_page_t *bpage) __attribute__((pure))
UNIV_INTERN buf_block_t * buf_block_align(const byte *ptr)
Definition buf0buf.cc:2610
UNIV_INTERN buf_block_t * buf_page_get_gen(ulint space, ulint zip_size, ulint offset, ulint rw_latch, buf_block_t *guess, ulint mode, const char *file, ulint line, mtr_t *mtr)
Definition buf0buf.cc:2712
UNIV_INLINE byte * buf_frame_copy(byte *buf, const buf_frame_t *frame)
UNIV_INTERN ulint buf_get_free_list_len(void)
UNIV_INLINE enum buf_io_fix buf_block_get_io_fix(const buf_block_t *block) __attribute__((pure))
UNIV_INTERN ulint buf_pool_init(ulint size, ulint n_instances)
Definition buf0buf.cc:1288
UNIV_INTERN ibool buf_pool_watch_occurred(ulint space, ulint offset) UNIV_WARN_UNUSED_RESULT
Definition buf0buf.cc:2099
UNIV_INTERN ibool buf_page_get_known_nowait(ulint rw_latch, buf_block_t *block, ulint mode, const char *file, ulint line, mtr_t *mtr)
Definition buf0buf.cc:3267
UNIV_INLINE ibool buf_page_belongs_to_unzip_LRU(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE void buf_block_set_file_page(buf_block_t *block, ulint space, ulint page_no)
UNIV_INLINE buf_block_t * buf_block_hash_get(buf_pool_t *buf_pool, ulint space, ulint offset)
UNIV_INLINE void buf_block_modify_clock_inc(buf_block_t *block)
UNIV_INTERN buf_page_t * buf_page_get_zip(ulint space, ulint zip_size, ulint offset)
Definition buf0buf.cc:2306
UNIV_INLINE ibool buf_page_is_old(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE void buf_page_set_io_fix(buf_page_t *bpage, enum buf_io_fix io_fix)
UNIV_INTERN void buf_print_io(FILE *file)
Definition buf0buf.cc:5080
UNIV_INTERN void buf_page_io_complete(buf_page_t *bpage)
Definition buf0buf.cc:3942
UNIV_INLINE void buf_page_set_flush_type(buf_page_t *bpage, enum buf_flush flush_type)
UNIV_INTERN ulint buf_get_modified_ratio_pct(void)
Definition buf0buf.cc:4796
buf_page_state
States of a control block.
Definition buf0buf.h:94
@ BUF_BLOCK_NOT_USED
Definition buf0buf.h:105
@ BUF_BLOCK_ZIP_PAGE
Definition buf0buf.h:99
@ BUF_BLOCK_REMOVE_HASH
Definition buf0buf.h:114
@ BUF_BLOCK_MEMORY
Definition buf0buf.h:112
@ BUF_BLOCK_ZIP_DIRTY
Definition buf0buf.h:101
@ BUF_BLOCK_POOL_WATCH
Definition buf0buf.h:97
@ BUF_BLOCK_ZIP_FREE
Definition buf0buf.h:95
@ BUF_BLOCK_READY_FOR_USE
Definition buf0buf.h:109
@ BUF_BLOCK_FILE_PAGE
Definition buf0buf.h:111
UNIV_INTERN buf_block_t * buf_block_alloc(buf_pool_t *buf_pool)
Definition buf0buf.cc:420
UNIV_INTERN ibool buf_pool_watch_is_sentinel(buf_pool_t *buf_pool, const buf_page_t *bpage) UNIV_WARN_UNUSED_RESULT
Definition buf0buf.cc:1814
UNIV_INLINE buf_page_t * buf_page_hash_get_low(buf_pool_t *buf_pool, ulint space, ulint offset, ulint fold)
UNIV_INLINE void buf_pool_mutex_enter_all(void)
UNIV_INLINE ibool buf_page_peek_if_too_old(const buf_page_t *bpage)
UNIV_INLINE void buf_page_set_old(buf_page_t *bpage, ibool old)
UNIV_INLINE ulint buf_block_get_page_no(const buf_block_t *block) __attribute__((pure))
UNIV_INLINE ulint buf_pool_get_n_pages(void)
UNIV_INTERN void buf_pool_watch_unset(ulint space, ulint offset)
Definition buf0buf.cc:2059
UNIV_INLINE ulint buf_page_get_freed_page_clock(const buf_page_t *bpage) __attribute__((pure))
UNIV_INTERN ibool buf_page_peek_if_search_hashed(ulint space, ulint offset)
Definition buf0buf.cc:2206
UNIV_INLINE mutex_t * buf_page_get_mutex(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE void buf_page_set_accessed(buf_page_t *bpage, ulint time_ms) __attribute__((nonnull))
UNIV_INLINE ibool buf_page_in_file(const buf_page_t *bpage) __attribute__((pure))
UNIV_INTERN void buf_refresh_io_stats(buf_pool_t *buf_pool)
Definition buf0buf.cc:5142
UNIV_INTERN ulint buf_calc_page_new_checksum(const byte *page)
Definition buf0buf.cc:451
UNIV_INTERN ulint buf_get_n_pending_ios(void)
Definition buf0buf.cc:4769
UNIV_INTERN ibool buf_zip_decompress(buf_block_t *block, ibool check)
Definition buf0buf.cc:2452
UNIV_INTERN void buf_get_total_list_len(ulint *LRU_len, ulint *free_len, ulint *flush_list_len)
Definition buf0buf.cc:361
UNIV_INTERN void buf_relocate(buf_page_t *bpage, buf_page_t *dpage) __attribute__((nonnull))
Definition buf0buf.cc:1456
UNIV_INLINE ulint buf_page_get_zip_size(const buf_page_t *bpage) __attribute__((pure))
UNIV_INLINE buf_page_t * buf_page_hash_get(buf_pool_t *buf_pool, ulint space, ulint offset)
UNIV_INTERN void buf_page_print(const byte *read_buf, ulint zip_size)
Definition buf0buf.cc:601
byte buf_frame_t
Definition buf0types.h:44
struct buf_pool_stat_struct buf_pool_stat_t
Definition buf0types.h:39
struct buf_chunk_struct buf_chunk_t
Definition buf0types.h:35
struct buf_pool_struct buf_pool_t
Definition buf0types.h:37
buf_flush
Definition buf0types.h:47
@ BUF_FLUSH_N_TYPES
Definition buf0types.h:52
struct buf_page_struct buf_page_t
Definition buf0types.h:31
struct buf_buddy_stat_struct buf_buddy_stat_t
Definition buf0types.h:41
buf_io_fix
Definition buf0types.h:56
struct buf_block_struct buf_block_t
Definition buf0types.h:33
struct fil_addr_struct fil_addr_t
Definition fil0fil.h:64
os_event_struct_t * os_event_t
Definition os0sync.h:58
struct page_zip_des_struct page_zip_des_t
Definition page0types.h:44
ibool check_index_page_at_flush
Definition buf0buf.h:1454
rw_lock_t lock
Definition buf0buf.h:1445
unsigned is_hashed
Definition buf0buf.h:1511
unsigned curr_left_side
Definition buf0buf.h:1522
ib_uint64_t modify_clock
Definition buf0buf.h:1467
UT_LIST_NODE_T(buf_block_t) unzip_LRU
buf_page_t page
Definition buf0buf.h:1420
unsigned lock_hash_val
Definition buf0buf.h:1447
unsigned curr_n_fields
Definition buf0buf.h:1518
dict_index_t * index
Definition buf0buf.h:1523
unsigned curr_n_bytes
Definition buf0buf.h:1520
ib_uint64_t relocated
Definition buf0buf.h:1584
ib_uint64_t relocated_usec
Definition buf0buf.h:1586
UT_LIST_NODE_T(buf_page_t) list
ib_uint64_t oldest_modification
Definition buf0buf.h:1365
unsigned state
Definition buf0buf.h:1271
unsigned offset
Definition buf0buf.h:1268
ib_uint64_t newest_modification
Definition buf0buf.h:1359
unsigned flush_type
Definition buf0buf.h:1279
unsigned access_time
Definition buf0buf.h:1401
buf_page_t * hash
Definition buf0buf.h:1302
unsigned freed_page_clock
Definition buf0buf.h:1393
unsigned buf_fix_count
Definition buf0buf.h:1286
unsigned space
Definition buf0buf.h:1266
unsigned io_fix
Definition buf0buf.h:1283
page_zip_des_t zip
Definition buf0buf.h:1295
unsigned old
Definition buf0buf.h:1391
unsigned buf_pool_index
Definition buf0buf.h:1288
UT_LIST_NODE_T(buf_page_t) LRU
double page_not_made_young_rate
Definition buf0buf.h:155
ulint n_pages_not_made_young
Definition buf0buf.h:139
double page_made_young_rate
Definition buf0buf.h:153
double pages_evicted_rate
Definition buf0buf.h:170
double pages_created_rate
Definition buf0buf.h:158
ulint n_pending_flush_single_page
Definition buf0buf.h:136
ulint n_pending_flush_list
Definition buf0buf.h:134
ulint n_pending_flush_lru
Definition buf0buf.h:133
double pages_written_rate
Definition buf0buf.h:159
double pages_readahead_rate
Definition buf0buf.h:168
ulint not_young_making_delta
Definition buf0buf.h:164
The buffer pool statistics structure.
Definition buf0buf.h:1555
ulint n_pages_not_made_young
Definition buf0buf.h:1573
The buffer pool structure.
Definition buf0buf.h:1594
ulint n_pend_unzip
Definition buf0buf.h:1630
ulint instance_no
Definition buf0buf.h:1604
ulint LRU_old_len
Definition buf0buf.h:1711
ibool init_flush[BUF_FLUSH_N_TYPES]
Definition buf0buf.h:1657
buf_chunk_t * chunks
Definition buf0buf.h:1618
buf_pool_stat_t stat
Definition buf0buf.h:1638
UT_LIST_BASE_NODE_T(buf_page_t) zip_clean
buf_page_t watch[BUF_POOL_WATCH_SIZE]
Definition buf0buf.h:1734
mutex_t mutex
Definition buf0buf.h:1598
UT_LIST_BASE_NODE_T(buf_page_t) free
hash_table_t * zip_hash
Definition buf0buf.h:1624
hash_table_t * page_hash
Definition buf0buf.h:1620
UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES_MAX]
ulint curr_pool_size
Definition buf0buf.h:1607
ulint LRU_old_ratio
Definition buf0buf.h:1608
ulint freed_page_clock
Definition buf0buf.h:1681
buf_page_t * LRU_old
Definition buf0buf.h:1704
ulint LRU_flush_ended
Definition buf0buf.h:1690
ulint n_flush[BUF_FLUSH_N_TYPES]
Definition buf0buf.h:1660
time_t last_printout_time
Definition buf0buf.h:1632
mutex_t zip_mutex
Definition buf0buf.h:1600
UT_LIST_BASE_NODE_T(buf_block_t) unzip_LRU
os_event_t no_flush[BUF_FLUSH_N_TYPES]
Definition buf0buf.h:1663
ulint old_pool_size
Definition buf0buf.h:1606
buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES_MAX+1]
Definition buf0buf.h:1635
buf_pool_stat_t old_stat
Definition buf0buf.h:1639
UT_LIST_BASE_NODE_T(buf_page_t) LRU
ulint n_pend_reads
Definition buf0buf.h:1628
UT_LIST_BASE_NODE_T(buf_page_t) flush_list
ib_rbt_t * flush_rbt
Definition buf0buf.h:1667
mutex_t flush_list_mutex
Definition buf0buf.h:1647
#define mutex_t
Definition sync0types.h:31