Drizzled Public API Documentation

buf0buf.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
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_GET_NO_LATCH 14
51 #define BUF_GET_IF_IN_POOL_OR_WATCH 15
52 
55 /* @} */
57 /* @{ */
58 #define BUF_MAKE_YOUNG 51
63 #define BUF_KEEP_OLD 52
65 /* @} */
66 
67 #define MAX_BUFFER_POOLS 64
70 #define BUF_POOL_WATCH_SIZE 1
73 extern buf_pool_t* buf_pool_ptr;
75 #ifdef UNIV_DEBUG
76 extern ibool buf_debug_prints;
79 #endif /* UNIV_DEBUG */
80 #else /* !UNIV_HOTBACKUP */
81 extern buf_block_t* back_block1;
82 extern buf_block_t* back_block2;
83 #endif /* !UNIV_HOTBACKUP */
84 
86 #define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
87 
92 enum buf_page_state {
93  BUF_BLOCK_ZIP_FREE = 0,
114 };
116 #ifndef UNIV_HOTBACKUP
117 /********************************************************************/
119 UNIV_INLINE
120 void
122 /*===========================*/
123 
124 /********************************************************************/
126 UNIV_INLINE
127 void
129 /*==========================*/
130 
131 /********************************************************************/
134 UNIV_INTERN
135 ulint
136 buf_pool_init(
137 /*=========*/
138  ulint size,
139  ulint n_instances);
140 /********************************************************************/
143 UNIV_INTERN
144 void
145 buf_pool_free(
146 /*==========*/
147  ulint n_instances);
149 /********************************************************************/
153 UNIV_INTERN
154 void
155 buf_pool_drop_hash_index(void);
156 /*==========================*/
157 
158 /********************************************************************/
162 UNIV_INTERN
163 void
164 buf_relocate(
165 /*=========*/
166  buf_page_t* bpage,
169  buf_page_t* dpage)
170  __attribute__((nonnull));
171 /********************************************************************/
173 UNIV_INTERN
174 void
175 buf_pool_resize(void);
176 /*=================*/
177 /*********************************************************************/
180 UNIV_INLINE
181 ulint
183 /*========================*/
184 /*********************************************************************/
187 UNIV_INLINE
188 ulint
190 /*=======================*/
191 /********************************************************************/
195 UNIV_INTERN
196 ib_uint64_t
197 buf_pool_get_oldest_modification(void);
198 /*==================================*/
199 /********************************************************************/
202 UNIV_INTERN
204 buf_block_alloc(
205 /*============*/
206  buf_pool_t* buf_pool,
207  ulint zip_size);
209 /********************************************************************/
211 UNIV_INLINE
212 void
214 /*===========*/
215  buf_block_t* block);
216 #endif /* !UNIV_HOTBACKUP */
217 /*********************************************************************/
220 UNIV_INLINE
221 byte*
223 /*===========*/
224  byte* buf,
225  const buf_frame_t* frame);
226 #ifndef UNIV_HOTBACKUP
227 /**************************************************************/
231 #define buf_page_get(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
232  SP, ZS, OF, LA, NULL,\
233  BUF_GET, __FILE__, __LINE__, MTR)
234 /**************************************************************/
240 #define buf_page_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
241  SP, ZS, OF, RW_NO_LATCH, NULL,\
242  BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
243 /********************************************************************/
247 UNIV_INTERN
248 ibool
249 buf_page_optimistic_get(
250 /*====================*/
251  ulint rw_latch,
252  buf_block_t* block,
253  ib_uint64_t modify_clock,
255  const char* file,
256  ulint line,
257  mtr_t* mtr);
258 /********************************************************************/
262 UNIV_INTERN
263 ibool
264 buf_page_get_known_nowait(
265 /*======================*/
266  ulint rw_latch,
267  buf_block_t* block,
268  ulint mode,
269  const char* file,
270  ulint line,
271  mtr_t* mtr);
273 /*******************************************************************/
277 UNIV_INTERN
278 const buf_block_t*
279 buf_page_try_get_func(
280 /*==================*/
281  ulint space_id,
282  ulint page_no,
283  const char* file,
284  ulint line,
285  mtr_t* mtr);
293 #define buf_page_try_get(space_id, page_no, mtr) \
294  buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
295 
296 /********************************************************************/
305 UNIV_INTERN
306 buf_page_t*
307 buf_page_get_zip(
308 /*=============*/
309  ulint space,
310  ulint zip_size,
311  ulint offset);
312 /********************************************************************/
315 UNIV_INTERN
317 buf_page_get_gen(
318 /*=============*/
319  ulint space,
320  ulint zip_size,
322  ulint offset,
323  ulint rw_latch,
324  buf_block_t* guess,
325  ulint mode,
328  const char* file,
329  ulint line,
330  mtr_t* mtr);
331 /********************************************************************/
337 UNIV_INTERN
339 buf_page_create(
340 /*============*/
341  ulint space,
342  ulint offset,
344  ulint zip_size,
345  mtr_t* mtr);
346 #else /* !UNIV_HOTBACKUP */
347 /********************************************************************/
349 UNIV_INTERN
350 void
351 buf_page_init_for_backup_restore(
352 /*=============================*/
353  ulint space,
354  ulint offset,
356  ulint zip_size,
358  buf_block_t* block);
359 #endif /* !UNIV_HOTBACKUP */
360 
361 #ifndef UNIV_HOTBACKUP
362 /********************************************************************/
364 UNIV_INLINE
365 void
367 /*=================*/
368  buf_page_t* bpage);
369 /********************************************************************/
372 UNIV_INLINE
373 void
375 /*=============*/
376  buf_block_t* block,
377  ulint rw_latch);
379 /********************************************************************/
383 UNIV_INTERN
384 void
385 buf_page_make_young(
386 /*================*/
387  buf_page_t* bpage);
388 /********************************************************************/
395 UNIV_INLINE
396 ibool
398 /*==========*/
399  ulint space,
400  ulint offset);
401 /********************************************************************/
404 UNIV_INTERN
405 void
406 buf_reset_check_index_page_at_flush(
407 /*================================*/
408  ulint space,
409  ulint offset);
410 #ifdef UNIV_DEBUG_FILE_ACCESSES
411 /********************************************************************/
417 UNIV_INTERN
418 buf_page_t*
419 buf_page_set_file_page_was_freed(
420 /*=============================*/
421  ulint space,
422  ulint offset);
423 /********************************************************************/
429 UNIV_INTERN
430 buf_page_t*
431 buf_page_reset_file_page_was_freed(
432 /*===============================*/
433  ulint space,
434  ulint offset);
435 #endif /* UNIV_DEBUG_FILE_ACCESSES */
436 /********************************************************************/
439 UNIV_INLINE
440 ulint
442 /*==========================*/
443  const buf_page_t* bpage)
444  __attribute__((pure));
445 /********************************************************************/
448 UNIV_INLINE
449 ulint
451 /*===========================*/
452  const buf_block_t* block)
453  __attribute__((pure));
454 
455 /********************************************************************/
460 UNIV_INLINE
461 ibool
463 /*=====================*/
464  const buf_page_t* bpage);
465 /********************************************************************/
470 UNIV_INTERN
471 ibool
472 buf_page_peek_if_search_hashed(
473 /*===========================*/
474  ulint space,
475  ulint offset);
476 /********************************************************************/
480 UNIV_INLINE
481 ib_uint64_t
483 /*=============================*/
484  const buf_page_t* bpage);
486 /********************************************************************/
490 UNIV_INLINE
491 void
493 /*=======================*/
494  buf_block_t* block);
495 /********************************************************************/
499 UNIV_INLINE
500 ib_uint64_t
502 /*=======================*/
503  buf_block_t* block);
504 #else /* !UNIV_HOTBACKUP */
505 # define buf_block_modify_clock_inc(block) ((void) 0)
506 #endif /* !UNIV_HOTBACKUP */
507 /********************************************************************/
512 UNIV_INTERN
513 ulint
514 buf_calc_page_new_checksum(
515 /*=======================*/
516  const byte* page);
517 /********************************************************************/
525 UNIV_INTERN
526 ulint
527 buf_calc_page_old_checksum(
528 /*=======================*/
529  const byte* page);
530 /********************************************************************/
533 UNIV_INTERN
534 ibool
535 buf_page_is_corrupted(
536 /*==================*/
537  const byte* read_buf,
538  ulint zip_size);
540 #ifndef UNIV_HOTBACKUP
541 /**********************************************************************/
544 UNIV_INLINE
545 void
547 /*=================*/
548  const void* ptr,
549  ulint* space,
550  fil_addr_t* addr);
551 /**********************************************************************/
555 UNIV_INLINE
556 ulint
558 /*========================*/
559  const buf_block_t* block)
560  __attribute__((pure));
561 #ifdef UNIV_DEBUG
562 /*********************************************************************/
566 UNIV_INTERN
568 buf_pool_contains_zip(
569 /*==================*/
570  buf_pool_t* buf_pool,
571  const void* data);
572 #endif /* UNIV_DEBUG */
573 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
574 /*********************************************************************/
577 UNIV_INTERN
578 ibool
579 buf_validate(void);
580 /*==============*/
581 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
582 #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
583 /*********************************************************************/
585 UNIV_INTERN
586 void
587 buf_print(void);
588 /*============*/
589 #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
590 #endif /* !UNIV_HOTBACKUP */
591 /********************************************************************/
593 UNIV_INTERN
594 void
595 buf_page_print(
596 /*===========*/
597  const byte* read_buf,
598  ulint zip_size);
600 /********************************************************************/
603 UNIV_INTERN
604 ibool
605 buf_zip_decompress(
606 /*===============*/
607  buf_block_t* block,
608  ibool check);
609 #ifndef UNIV_HOTBACKUP
610 #ifdef UNIV_DEBUG
611 /*********************************************************************/
614 UNIV_INTERN
615 ulint
616 buf_get_latched_pages_number(void);
617 /*==============================*/
618 #endif /* UNIV_DEBUG */
619 /*********************************************************************/
622 UNIV_INTERN
623 ulint
624 buf_get_n_pending_ios(void);
625 /*=======================*/
626 /*********************************************************************/
628 UNIV_INTERN
629 void
630 buf_print_io(
631 /*=========*/
632  FILE* file);
633 /*********************************************************************/
637 UNIV_INTERN
638 ulint
639 buf_get_modified_ratio_pct(void);
640 /*============================*/
641 /**********************************************************************/
643 UNIV_INTERN
644 void
645 buf_refresh_io_stats(
646 /*=================*/
647  buf_pool_t* buf_pool);
648 /**********************************************************************/
650 UNIV_INTERN
651 void
652 buf_refresh_io_stats_all(void);
653 /*=================*/
654 /*********************************************************************/
657 UNIV_INTERN
658 ibool
659 buf_all_freed(void);
660 /*===============*/
661 /*********************************************************************/
665 UNIV_INTERN
666 ibool
667 buf_pool_check_no_pending_io(void);
668 /*==============================*/
669 /*********************************************************************/
673 UNIV_INTERN
674 void
675 buf_pool_invalidate(void);
676 /*=====================*/
677 #endif /* !UNIV_HOTBACKUP */
678 
679 /*========================================================================
680 --------------------------- LOWER LEVEL ROUTINES -------------------------
681 =========================================================================*/
682 
683 #ifdef UNIV_SYNC_DEBUG
684 /*********************************************************************/
688 UNIV_INLINE
689 void
690 buf_block_dbg_add_level(
691 /*====================*/
692  buf_block_t* block,
694  ulint level);
695 #else /* UNIV_SYNC_DEBUG */
696 # define buf_block_dbg_add_level(block, level) /* nothing */
697 #endif /* UNIV_SYNC_DEBUG */
698 /*********************************************************************/
701 UNIV_INLINE
702 enum buf_page_state
704 /*===============*/
705  const buf_page_t* bpage);
706 /*********************************************************************/
709 UNIV_INLINE
710 enum buf_page_state
712 /*================*/
713  const buf_block_t* block)
714  __attribute__((pure));
715 /*********************************************************************/
717 UNIV_INLINE
718 void
720 /*===============*/
721  buf_page_t* bpage,
722  enum buf_page_state state);
723 /*********************************************************************/
725 UNIV_INLINE
726 void
728 /*================*/
729  buf_block_t* block,
730  enum buf_page_state state);
731 /*********************************************************************/
734 UNIV_INLINE
735 ibool
737 /*=============*/
738  const buf_page_t* bpage)
739  __attribute__((pure));
740 #ifndef UNIV_HOTBACKUP
741 /*********************************************************************/
744 UNIV_INLINE
745 ibool
747 /*==========================*/
748  const buf_page_t* bpage)
749  __attribute__((pure));
750 
751 /*********************************************************************/
754 UNIV_INLINE
755 mutex_t*
757 /*===============*/
758  const buf_page_t* bpage)
759  __attribute__((pure));
760 
761 /*********************************************************************/
764 UNIV_INLINE
765 enum buf_flush
767 /*====================*/
768  const buf_page_t* bpage)
769  __attribute__((pure));
770 /*********************************************************************/
772 UNIV_INLINE
773 void
775 /*====================*/
776  buf_page_t* bpage,
777  enum buf_flush flush_type);
778 /*********************************************************************/
780 UNIV_INLINE
781 void
783 /*====================*/
784  buf_block_t* block,
785  ulint space,
786  ulint page_no);
787 /*********************************************************************/
790 UNIV_INLINE
791 enum buf_io_fix
793 /*================*/
794  const buf_page_t* bpage)
795  __attribute__((pure));
796 /*********************************************************************/
799 UNIV_INLINE
800 enum buf_io_fix
802 /*================*/
803  const buf_block_t* block)
804  __attribute__((pure));
805 /*********************************************************************/
807 UNIV_INLINE
808 void
810 /*================*/
811  buf_page_t* bpage,
812  enum buf_io_fix io_fix);
813 /*********************************************************************/
815 UNIV_INLINE
816 void
818 /*=================*/
819  buf_block_t* block,
820  enum buf_io_fix io_fix);
822 /********************************************************************/
825 UNIV_INLINE
826 ibool
828 /*==================*/
829  const buf_page_t* bpage)
830  __attribute__((pure));
831 
832 /*********************************************************************/
835 UNIV_INLINE
836 ibool
838 /*============*/
839  const buf_page_t* bpage)
840  __attribute__((pure));
841 /*********************************************************************/
843 UNIV_INLINE
844 void
846 /*=============*/
847  buf_page_t* bpage,
848  ibool old);
849 /*********************************************************************/
852 UNIV_INLINE
853 unsigned
855 /*=================*/
856  const buf_page_t* bpage)
857  __attribute__((nonnull, pure));
858 /*********************************************************************/
860 UNIV_INLINE
861 void
863 /*==================*/
864  buf_page_t* bpage,
865  ulint time_ms)
866  __attribute__((nonnull));
867 /*********************************************************************/
872 UNIV_INLINE
875 /*===============*/
876  buf_page_t* bpage)
877  __attribute__((pure));
878 #endif /* !UNIV_HOTBACKUP */
879 #ifdef UNIV_DEBUG
880 /*********************************************************************/
883 UNIV_INLINE
885 buf_block_get_frame(
886 /*================*/
887  const buf_block_t* block)
888  __attribute__((pure));
889 #else /* UNIV_DEBUG */
890 # define buf_block_get_frame(block) (block)->frame
891 #endif /* UNIV_DEBUG */
892 /*********************************************************************/
895 UNIV_INLINE
896 ulint
898 /*===============*/
899  const buf_page_t* bpage)
900  __attribute__((pure));
901 /*********************************************************************/
904 UNIV_INLINE
905 ulint
907 /*================*/
908  const buf_block_t* block)
909  __attribute__((pure));
910 /*********************************************************************/
913 UNIV_INLINE
914 ulint
916 /*=================*/
917  const buf_page_t* bpage)
918  __attribute__((pure));
919 /*********************************************************************/
922 UNIV_INLINE
923 ulint
925 /*==================*/
926  const buf_block_t* block)
927  __attribute__((pure));
928 /*********************************************************************/
931 UNIV_INLINE
932 ulint
934 /*==================*/
935  const buf_page_t* bpage)
936  __attribute__((pure));
937 /*********************************************************************/
940 UNIV_INLINE
941 ulint
943 /*===================*/
944  const buf_block_t* block)
945  __attribute__((pure));
946 /*********************************************************************/
949 #define buf_block_get_page_zip(block) \
950  (UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL)
951 #ifndef UNIV_HOTBACKUP
952 /*******************************************************************/
955 UNIV_INTERN
957 buf_block_align(
958 /*============*/
959  const byte* ptr);
960 /********************************************************************/
964 UNIV_INTERN
965 ibool
966 buf_pointer_is_block_field(
967 /*=======================*/
968  const void* ptr);
973 #define buf_pool_is_block_mutex(m) \
974  buf_pointer_is_block_field((const void*)(m))
975 
978 #define buf_pool_is_block_lock(l) \
979  buf_pointer_is_block_field((const void*)(l))
980 
981 #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
982 /*********************************************************************/
986 UNIV_INLINE
987 const page_zip_des_t*
988 buf_frame_get_page_zip(
989 /*===================*/
990  const byte* ptr);
991 #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
992 /********************************************************************/
1002 UNIV_INTERN
1003 buf_page_t*
1004 buf_page_init_for_read(
1005 /*===================*/
1006  ulint* err,
1007  ulint mode,
1008  ulint space,
1009  ulint zip_size,
1010  ibool unzip,
1011  ib_int64_t tablespace_version,
1014  ulint offset);
1015 /********************************************************************/
1018 UNIV_INTERN
1019 void
1020 buf_page_io_complete(
1021 /*=================*/
1022  buf_page_t* bpage);
1023 /********************************************************************/
1027 UNIV_INLINE
1028 ulint
1030 /*==================*/
1031  ulint space,
1032  ulint offset)
1033  __attribute__((const));
1034 /********************************************************************/
1037 UNIV_INLINE
1038 ulint
1040 /*===========*/
1041  const buf_pool_t* buf_pool)
1042  __attribute__((nonnull, const));
1043 /******************************************************************/
1046 UNIV_INLINE
1047 buf_pool_t*
1049 /*================*/
1050  const buf_page_t* bpage);
1051 /******************************************************************/
1054 UNIV_INLINE
1055 buf_pool_t*
1057 /*================*/
1058  const buf_block_t* block);
1059 /******************************************************************/
1062 UNIV_INLINE
1063 buf_pool_t*
1064 buf_pool_get(
1065 /*==========*/
1066  ulint space,
1067  ulint offset);
1068 /******************************************************************/
1071 UNIV_INLINE
1072 buf_pool_t*
1074 /*================*/
1075  ulint index);
1077 /******************************************************************/
1080 UNIV_INLINE
1081 buf_page_t*
1083 /*==================*/
1084  buf_pool_t* buf_pool,
1085  ulint space,
1086  ulint offset,
1088  ulint fold);
1090 /******************************************************************/
1093 UNIV_INLINE
1094 buf_page_t*
1096 /*==============*/
1097  buf_pool_t* buf_pool,
1098  ulint space,
1099  ulint offset);
1101 /******************************************************************/
1105 UNIV_INLINE
1106 buf_block_t*
1108 /*===============*/
1109  buf_pool_t* buf_pool,
1110  ulint space,
1111  ulint offset);
1113 /*********************************************************************/
1116 UNIV_INTERN
1117 ulint
1118 buf_get_free_list_len(void);
1119 /*=======================*/
1120 
1121 /********************************************************************
1122 Determine if a block is a sentinel for a buffer pool watch.
1123 @return TRUE if a sentinel for a buffer pool watch, FALSE if not */
1124 UNIV_INTERN
1125 ibool
1126 buf_pool_watch_is_sentinel(
1127 /*=======================*/
1128  buf_pool_t* buf_pool,
1129  const buf_page_t* bpage)
1130  UNIV_WARN_UNUSED_RESULT;
1131 /****************************************************************/
1134 UNIV_INTERN
1135 buf_page_t*
1136 buf_pool_watch_set(
1137 /*===============*/
1138  ulint space,
1139  ulint offset,
1140  ulint fold)
1141  UNIV_WARN_UNUSED_RESULT;
1142 /****************************************************************/
1145 UNIV_INTERN
1146 void
1147 buf_pool_watch_unset(
1148 /*=================*/
1149  ulint space,
1150  ulint offset);
1151 /****************************************************************/
1156 UNIV_INTERN
1157 ibool
1158 buf_pool_watch_occurred(
1159 /*====================*/
1160  ulint space,
1161  ulint offset)
1162  UNIV_WARN_UNUSED_RESULT;
1163 /********************************************************************/
1165 UNIV_INTERN
1166 void
1167 buf_get_total_list_len(
1168 /*===================*/
1169  ulint* LRU_len,
1170  ulint* free_len,
1171  ulint* flush_list_len);
1172 /********************************************************************/
1174 UNIV_INTERN
1175 void
1176 buf_get_total_stat(
1177 /*===============*/
1178  buf_pool_stat_t*tot_stat);
1180 #endif /* !UNIV_HOTBACKUP */
1181 
1185 struct buf_page_struct{
1192  /* @{ */
1193 
1194  unsigned space:32;
1196  unsigned offset:32;
1199  unsigned state:3;
1206 #ifndef UNIV_HOTBACKUP
1207  unsigned flush_type:2;
1211  unsigned io_fix:2;
1214  unsigned buf_fix_count:19;
1216  unsigned buf_pool_index:6;
1218 # if MAX_BUFFER_POOLS > 64
1219 # error "MAX_BUFFER_POOLS > 64; redefine buf_pool_index:6"
1220 # endif
1221  /* @} */
1222 #endif /* !UNIV_HOTBACKUP */
1229 #ifndef UNIV_HOTBACKUP
1230  buf_page_t* hash;
1233 #ifdef UNIV_DEBUG
1234  ibool in_page_hash;
1235  ibool in_zip_hash;
1236 #endif /* UNIV_DEBUG */
1237 
1240  /* @{ */
1241 
1270 #ifdef UNIV_DEBUG
1271  ibool in_flush_list;
1282  ibool in_free_list;
1286 #endif /* UNIV_DEBUG */
1287  ib_uint64_t newest_modification;
1293  ib_uint64_t oldest_modification;
1306  /* @} */
1310  /* @{ */
1311 
1314 #ifdef UNIV_DEBUG
1315  ibool in_LRU_list;
1318 #endif /* UNIV_DEBUG */
1319  unsigned old:1;
1321  unsigned freed_page_clock:31;
1329  unsigned access_time:32;
1332  /* @} */
1333 # ifdef UNIV_DEBUG_FILE_ACCESSES
1334  ibool file_page_was_freed;
1337 # endif /* UNIV_DEBUG_FILE_ACCESSES */
1338 #endif /* !UNIV_HOTBACKUP */
1339 };
1340 
1343 struct buf_block_struct{
1344 
1346  /* @{ */
1347 
1348  buf_page_t page;
1352  byte* frame;
1356 #ifndef UNIV_HOTBACKUP
1357  UT_LIST_NODE_T(buf_block_t) unzip_LRU;
1362 #ifdef UNIV_DEBUG
1363  ibool in_unzip_LRU_list;
1366 #endif /* UNIV_DEBUG */
1367  mutex_t mutex;
1373  rw_lock_t lock;
1375  unsigned lock_hash_val:32;
1391  /* @} */
1393  /* @{ */
1395  ib_uint64_t modify_clock;
1406  /* @} */
1409  /* @{ */
1410 
1411  ulint n_hash_helps;
1413  ulint n_fields;
1415  ulint n_bytes;
1417  ibool left_side;
1421  /* @} */
1422 
1432  /* @{ */
1433 
1434 #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1435  ulint n_pointers;
1438 #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
1439  unsigned is_hashed:1;
1446  unsigned curr_n_fields:10;
1448  unsigned curr_n_bytes:15;
1450  unsigned curr_left_side:1;
1453  /* @} */
1454 # ifdef UNIV_SYNC_DEBUG
1455 
1456  /* @{ */
1457  rw_lock_t debug_latch;
1461  /* @} */
1462 # endif
1463 #endif /* !UNIV_HOTBACKUP */
1464 };
1465 
1469 #define buf_block_state_valid(block) \
1470 (buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
1471  && (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
1472 
1473 #ifndef UNIV_HOTBACKUP
1474 /**********************************************************************/
1476 /* @{ */
1477 #define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE)
1478 #define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
1479 #define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
1480 /* @} */
1483 struct buf_pool_stat_struct{
1484  ulint n_page_gets;
1490  ulint n_pages_read;
1491  ulint n_pages_written;
1492  ulint n_pages_created;
1494  ulint n_ra_pages_read;
1499  ulint n_pages_made_young;
1501  ulint n_pages_not_made_young;
1505 };
1510  ulint used;
1512  ib_uint64_t relocated;
1514  ib_uint64_t relocated_usec;
1515 };
1516 
1523 
1525  /* @{ */
1528  mutex_t zip_mutex;
1532  ulint instance_no;
1535  ulint curr_pool_size;
1536  ulint LRU_old_ratio;
1538 #ifdef UNIV_DEBUG
1539  ulint buddy_n_frames;
1541 #endif
1542 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1543  ulint mutex_exit_forbidden;
1544 #endif
1545  ulint n_chunks;
1547  ulint curr_size;
1556  ulint n_pend_reads;
1563  buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES_MAX + 1];
1569  /* @} */
1573  /* @{ */
1574 
1582  UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
1588  ulint n_flush[BUF_FLUSH_N_TYPES];
1591  os_event_t no_flush[BUF_FLUSH_N_TYPES];
1595  ib_rbt_t* flush_rbt;
1609  ulint freed_page_clock;
1618  ulint LRU_flush_ended;
1622  /* @} */
1623 
1625  /* @{ */
1626 
1632  buf_page_t* LRU_old;
1639  ulint LRU_old_len;
1647  UT_LIST_BASE_NODE_T(buf_block_t) unzip_LRU;
1651  /* @} */
1656  /* @{ */
1657  UT_LIST_BASE_NODE_T(buf_page_t) zip_clean;
1659  UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES_MAX];
1667 #if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
1668 # error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
1669 #endif
1670  /* @} */
1671 };
1672 
1675 /* @{ */
1676 
1678 #define buf_pool_mutex_own(b) mutex_own(&b->mutex)
1679 
1680 #define buf_pool_mutex_enter(b) do { \
1681  ut_ad(!mutex_own(&b->zip_mutex)); \
1682  mutex_enter(&b->mutex); \
1683 } while (0)
1684 
1686 #define buf_flush_list_mutex_own(b) mutex_own(&b->flush_list_mutex)
1687 
1689 #define buf_flush_list_mutex_enter(b) do { \
1690  mutex_enter(&b->flush_list_mutex); \
1691 } while (0)
1693 # define buf_flush_list_mutex_exit(b) do { \
1694  mutex_exit(&b->flush_list_mutex); \
1695 } while (0)
1696 
1697 
1699 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1700 
1701 # define buf_pool_mutex_exit_forbid(b) do { \
1702  ut_ad(buf_pool_mutex_own(b)); \
1703  b->mutex_exit_forbidden++; \
1704 } while (0)
1706 # define buf_pool_mutex_exit_allow(b) do { \
1707  ut_ad(buf_pool_mutex_own(b)); \
1708  ut_a(b->mutex_exit_forbidden); \
1709  b->mutex_exit_forbidden--; \
1710 } while (0)
1711 
1712 # define buf_pool_mutex_exit(b) do { \
1713  ut_a(!b->mutex_exit_forbidden); \
1714  mutex_exit(&b->mutex); \
1715 } while (0)
1716 #else
1717 
1718 # define buf_pool_mutex_exit_forbid(b) ((void) 0)
1719 
1720 # define buf_pool_mutex_exit_allow(b) ((void) 0)
1721 
1722 # define buf_pool_mutex_exit(b) mutex_exit(&b->mutex)
1723 #endif
1724 #endif /* !UNIV_HOTBACKUP */
1725 /* @} */
1726 
1727 /**********************************************************************
1728 Let us list the consistency conditions for different control block states.
1729 
1730 NOT_USED: is in free list, not in LRU list, not in flush list, nor
1731  page hash table
1732 READY_FOR_USE: is not in free list, LRU list, or flush list, nor page
1733  hash table
1734 MEMORY: is not in free list, LRU list, or flush list, nor page
1735  hash table
1736 FILE_PAGE: space and offset are defined, is in page hash table
1737  if io_fix == BUF_IO_WRITE,
1738  pool: no_flush[flush_type] is in reset state,
1739  pool: n_flush[flush_type] > 0
1740 
1741  (1) if buf_fix_count == 0, then
1742  is in LRU list, not in free list
1743  is in flush list,
1744  if and only if oldest_modification > 0
1745  is x-locked,
1746  if and only if io_fix == BUF_IO_READ
1747  is s-locked,
1748  if and only if io_fix == BUF_IO_WRITE
1749 
1750  (2) if buf_fix_count > 0, then
1751  is not in LRU list, not in free list
1752  is in flush list,
1753  if and only if oldest_modification > 0
1754  if io_fix == BUF_IO_READ,
1755  is x-locked
1756  if io_fix == BUF_IO_WRITE,
1757  is s-locked
1758 
1759 State transitions:
1760 
1761 NOT_USED => READY_FOR_USE
1762 READY_FOR_USE => MEMORY
1763 READY_FOR_USE => FILE_PAGE
1764 MEMORY => NOT_USED
1765 FILE_PAGE => NOT_USED NOTE: This transition is allowed if and only if
1766  (1) buf_fix_count == 0,
1767  (2) oldest_modification == 0, and
1768  (3) io_fix == 0.
1769 */
1770 
1771 #ifndef UNIV_NONINL
1772 #include "buf0buf.ic"
1773 #endif
1774 
1775 #endif