1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8 
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation.  The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License, version 2.0, for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
24 
25 *****************************************************************************/
26 
27 /**************************************************//**
28 @file include/buf0types.h
29 The database buffer pool global types for the directory
30 
31 Created 11/17/1995 Heikki Tuuri
32 *******************************************************/
33 
34 #ifndef buf0types_h
35 #define buf0types_h
36 
37 #if defined(INNODB_PAGE_ATOMIC_REF_COUNT) && defined(HAVE_ATOMIC_BUILTINS)
38 #define PAGE_ATOMIC_REF_COUNT
39 #endif /* INNODB_PAGE_ATOMIC_REF_COUNT && HAVE_ATOMIC_BUILTINS */
40 
41 /** Buffer page (uncompressed or compressed) */
42 struct buf_page_t;
43 /** Buffer block for which an uncompressed page exists */
44 struct buf_block_t;
45 /** Buffer pool chunk comprising buf_block_t */
46 struct buf_chunk_t;
47 /** Buffer pool comprising buf_chunk_t */
48 struct buf_pool_t;
49 /** Buffer pool statistics struct */
50 struct buf_pool_stat_t;
51 /** Buffer pool buddy statistics struct */
52 struct buf_buddy_stat_t;
53 /** Doublewrite memory struct */
54 struct buf_dblwr_t;
55 
56 /** A buffer frame. @see page_t */
57 typedef	byte	buf_frame_t;
58 
59 /** Flags for flush types */
60 enum buf_flush_t {
61 	BUF_FLUSH_LRU = 0,		/*!< flush via the LRU list */
62 	BUF_FLUSH_LIST,			/*!< flush via the flush list
63 					of dirty blocks */
64 	BUF_FLUSH_SINGLE_PAGE,		/*!< flush via the LRU list
65 					but only a single page */
66 	BUF_FLUSH_N_TYPES		/*!< index of last element + 1  */
67 };
68 
69 /** Algorithm to remove the pages for a tablespace from the buffer pool.
70 See buf_LRU_flush_or_remove_pages(). */
71 enum buf_remove_t {
72 	BUF_REMOVE_ALL_NO_WRITE,	/*!< Remove all pages from the buffer
73 					pool, don't write or sync to disk */
74 	BUF_REMOVE_FLUSH_NO_WRITE,	/*!< Remove only, from the flush list,
75 					don't write or sync to disk */
76 	BUF_REMOVE_FLUSH_WRITE		/*!< Flush dirty pages to disk only
77 					don't remove from the buffer pool */
78 };
79 
80 /** Flags for io_fix types */
81 enum buf_io_fix {
82 	BUF_IO_NONE = 0,		/**< no pending I/O */
83 	BUF_IO_READ,			/**< read pending */
84 	BUF_IO_WRITE,			/**< write pending */
85 	BUF_IO_PIN			/**< disallow relocation of
86 					block and its removal of from
87 					the flush_list */
88 };
89 
90 /** Alternatives for srv_checksum_algorithm, which can be changed by
91 setting innodb_checksum_algorithm */
92 enum srv_checksum_algorithm_t {
93 	SRV_CHECKSUM_ALGORITHM_CRC32,		/*!< Write crc32, allow crc32,
94 						innodb or none when reading */
95 	SRV_CHECKSUM_ALGORITHM_STRICT_CRC32,	/*!< Write crc32, allow crc32
96 						when reading */
97 	SRV_CHECKSUM_ALGORITHM_INNODB,		/*!< Write innodb, allow crc32,
98 						innodb or none when reading */
99 	SRV_CHECKSUM_ALGORITHM_STRICT_INNODB,	/*!< Write innodb, allow
100 						innodb when reading */
101 	SRV_CHECKSUM_ALGORITHM_NONE,		/*!< Write none, allow crc32,
102 						innodb or none when reading */
103 	SRV_CHECKSUM_ALGORITHM_STRICT_NONE	/*!< Write none, allow none
104 						when reading */
105 };
106 
107 /** Alternatives for srv_cleaner_lsn_age_factor, set through
108 innodb_cleaner_lsn_age_factor variable  */
109 enum srv_cleaner_lsn_age_factor_t {
110 	SRV_CLEANER_LSN_AGE_FACTOR_LEGACY,	/*!< Original Oracle MySQL 5.6
111 						formula */
112 	SRV_CLEANER_LSN_AGE_FACTOR_HIGH_CHECKPOINT
113 						/*!< Percona Server 5.6 formula
114 						that returns lower values than
115 					        legacy option for low
116 					        checkpoint ages, and higher
117 					        values for high ages.  This has
118 					        the effect of stabilizing the
119 						checkpoint age higher.  */
120 };
121 
122 /** Alternatives for srv_foreground_preflush, set through
123 innodb_foreground_preflush variable  */
124 enum srv_foreground_preflush_t {
125 	SRV_FOREGROUND_PREFLUSH_SYNC_PREFLUSH,	/*!< Original Oracle MySQL 5.6
126 						behavior of performing a sync
127 						flush list flush  */
128 	SRV_FOREGROUND_PREFLUSH_EXP_BACKOFF	/*!< Exponential backoff wait
129 						for the page cleaner to flush
130 						for us  */
131 };
132 
133 /** Alternatives for srv_empty_free_list_algorithm, set through
134 innodb_empty_free_list_algorithm variable  */
135 enum srv_empty_free_list_t {
136 	SRV_EMPTY_FREE_LIST_LEGACY,	/*!< Original Oracle MySQL 5.6
137 				        algorithm */
138 	SRV_EMPTY_FREE_LIST_BACKOFF	/*!< Percona Server 5.6 algorithm that
139 					loops in a progressive backoff until a
140 					free page is produced by the cleaner
141 					thread */
142 };
143 
144 /** Parameters of binary buddy system for compressed pages (buf0buddy.h) */
145 /* @{ */
146 /** Zip shift value for the smallest page size */
147 #define BUF_BUDDY_LOW_SHIFT	UNIV_ZIP_SIZE_SHIFT_MIN
148 
149 /** Smallest buddy page size */
150 #define BUF_BUDDY_LOW		(1U << BUF_BUDDY_LOW_SHIFT)
151 
152 /** Actual number of buddy sizes based on current page size */
153 #define BUF_BUDDY_SIZES		(UNIV_PAGE_SIZE_SHIFT - BUF_BUDDY_LOW_SHIFT)
154 
155 /** Maximum number of buddy sizes based on the max page size */
156 #define BUF_BUDDY_SIZES_MAX	(UNIV_PAGE_SIZE_SHIFT_MAX	\
157 				- BUF_BUDDY_LOW_SHIFT)
158 
159 /** twice the maximum block size of the buddy system;
160 the underlying memory is aligned by this amount:
161 this must be equal to UNIV_PAGE_SIZE */
162 #define BUF_BUDDY_HIGH	(BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
163 /* @} */
164 
165 #endif /* buf0types.h */
166