| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 1995, 2015, Oracle and/or its affiliates. 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., |
| 15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 16 | |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /**************************************************//** |
| 20 | @file include/buf0types.h |
| 21 | The database buffer pool global types for the directory |
| 22 | |
| 23 | Created 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) */ |
| 33 | class buf_page_t; |
| 34 | /** Buffer block for which an uncompressed page exists */ |
| 35 | struct buf_block_t; |
| 36 | /** Buffer pool chunk comprising buf_block_t */ |
| 37 | struct buf_chunk_t; |
| 38 | /** Buffer pool comprising buf_chunk_t */ |
| 39 | struct buf_pool_t; |
| 40 | /** Buffer pool statistics struct */ |
| 41 | struct buf_pool_stat_t; |
| 42 | /** Buffer pool buddy statistics struct */ |
| 43 | struct buf_buddy_stat_t; |
| 44 | /** Doublewrite memory struct */ |
| 45 | struct buf_dblwr_t; |
| 46 | /** Flush observer for bulk create index */ |
| 47 | class FlushObserver; |
| 48 | |
| 49 | /** A buffer frame. @see page_t */ |
| 50 | typedef byte buf_frame_t; |
| 51 | |
| 52 | /** Flags for flush types */ |
| 53 | enum 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 */ |
| 63 | enum 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 |
| 73 | setting innodb_checksum_algorithm */ |
| 74 | enum 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 | |
| 89 | inline |
| 90 | bool |
| 91 | is_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 | |
| 98 | inline |
| 99 | bool |
| 100 | is_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; |
| 123 | the underlying memory is aligned by this amount: |
| 124 | this 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 | |
| 133 | typedef ib_bpmutex_t BPageMutex; |
| 134 | typedef ib_mutex_t BufPoolMutex; |
| 135 | typedef ib_mutex_t FlushListMutex; |
| 136 | typedef BPageMutex BufPoolZipMutex; |
| 137 | typedef rw_lock_t BPageLock; |
| 138 | #endif /* !UNIV_INNOCHECKSUM */ |
| 139 | |
| 140 | #endif /* buf0types.h */ |
| 141 | |