1/*****************************************************************************
2
3Copyright (c) 1995, 2015, Oracle and/or its affiliates. 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.,
1551 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17*****************************************************************************/
18
19/**************************************************//**
20@file include/buf0types.h
21The database buffer pool global types for the directory
22
23Created 11/17/1995 Heikki Tuuri
24*******************************************************/
25
26#ifndef buf0types_h
27#define buf0types_h
28
29#include "os0event.h"
30#include "ut0ut.h"
31
32/** Buffer page (uncompressed or compressed) */
33class buf_page_t;
34/** Buffer block for which an uncompressed page exists */
35struct buf_block_t;
36/** Buffer pool chunk comprising buf_block_t */
37struct buf_chunk_t;
38/** Buffer pool comprising buf_chunk_t */
39struct buf_pool_t;
40/** Buffer pool statistics struct */
41struct buf_pool_stat_t;
42/** Buffer pool buddy statistics struct */
43struct buf_buddy_stat_t;
44/** Doublewrite memory struct */
45struct buf_dblwr_t;
46/** Flush observer for bulk create index */
47class FlushObserver;
48
49/** A buffer frame. @see page_t */
50typedef byte buf_frame_t;
51
52/** Flags for flush types */
53enum buf_flush_t {
54 BUF_FLUSH_LRU = 0, /*!< flush via the LRU list */
55 BUF_FLUSH_LIST, /*!< flush via the flush list
56 of dirty blocks */
57 BUF_FLUSH_SINGLE_PAGE, /*!< flush via the LRU list
58 but only a single page */
59 BUF_FLUSH_N_TYPES /*!< index of last element + 1 */
60};
61
62/** Flags for io_fix types */
63enum buf_io_fix {
64 BUF_IO_NONE = 0, /**< no pending I/O */
65 BUF_IO_READ, /**< read pending */
66 BUF_IO_WRITE, /**< write pending */
67 BUF_IO_PIN /**< disallow relocation of
68 block and its removal of from
69 the flush_list */
70};
71
72/** Alternatives for srv_checksum_algorithm, which can be changed by
73setting innodb_checksum_algorithm */
74enum srv_checksum_algorithm_t {
75 SRV_CHECKSUM_ALGORITHM_CRC32, /*!< Write crc32, allow crc32,
76 innodb or none when reading */
77 SRV_CHECKSUM_ALGORITHM_STRICT_CRC32, /*!< Write crc32, allow crc32
78 when reading */
79 SRV_CHECKSUM_ALGORITHM_INNODB, /*!< Write innodb, allow crc32,
80 innodb or none when reading */
81 SRV_CHECKSUM_ALGORITHM_STRICT_INNODB, /*!< Write innodb, allow
82 innodb when reading */
83 SRV_CHECKSUM_ALGORITHM_NONE, /*!< Write none, allow crc32,
84 innodb or none when reading */
85 SRV_CHECKSUM_ALGORITHM_STRICT_NONE /*!< Write none, allow none
86 when reading */
87};
88
89inline
90bool
91is_checksum_strict(srv_checksum_algorithm_t algo)
92{
93 return(algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32
94 || algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB
95 || algo == SRV_CHECKSUM_ALGORITHM_STRICT_NONE);
96}
97
98inline
99bool
100is_checksum_strict(ulint algo)
101{
102 return(algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32
103 || algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB
104 || algo == SRV_CHECKSUM_ALGORITHM_STRICT_NONE);
105}
106
107/** Parameters of binary buddy system for compressed pages (buf0buddy.h) */
108/* @{ */
109/** Zip shift value for the smallest page size */
110#define BUF_BUDDY_LOW_SHIFT UNIV_ZIP_SIZE_SHIFT_MIN
111
112/** Smallest buddy page size */
113#define BUF_BUDDY_LOW (1U << BUF_BUDDY_LOW_SHIFT)
114
115/** Actual number of buddy sizes based on current page size */
116#define BUF_BUDDY_SIZES (srv_page_size_shift - BUF_BUDDY_LOW_SHIFT)
117
118/** Maximum number of buddy sizes based on the max page size */
119#define BUF_BUDDY_SIZES_MAX (UNIV_PAGE_SIZE_SHIFT_MAX \
120 - BUF_BUDDY_LOW_SHIFT)
121
122/** twice the maximum block size of the buddy system;
123the underlying memory is aligned by this amount:
124this must be equal to srv_page_size */
125#define BUF_BUDDY_HIGH (BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
126/* @} */
127
128#ifndef UNIV_INNOCHECKSUM
129
130#include "ut0mutex.h"
131#include "sync0rw.h"
132
133typedef ib_bpmutex_t BPageMutex;
134typedef ib_mutex_t BufPoolMutex;
135typedef ib_mutex_t FlushListMutex;
136typedef BPageMutex BufPoolZipMutex;
137typedef rw_lock_t BPageLock;
138#endif /* !UNIV_INNOCHECKSUM */
139
140#endif /* buf0types.h */
141