~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/buf0buf.h

Merge initial InnoDB+ import.

This was applied by generating a patch between MySQL 5.1.50 InnoDB plugin and
the just-merged innodb+ from mysql-trunk revision-id: vasil.dimov@oracle.com-20100422110752-1zowoqxel5xx3z2e

Then, some manual merge resolving and it worked. This should make it much
easier to merge the rest of InnoDB 1.1 and 1.2 from the mysql tree using
my bzr-reapply script.

This takes us to InnoDB 1.1.1(ish).

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "hash0hash.h"
34
34
#include "ut0byte.h"
35
35
#include "page0types.h"
 
36
#ifndef UNIV_HOTBACKUP
36
37
#include "ut0rbt.h"
37
 
#ifndef UNIV_HOTBACKUP
38
38
#include "os0proc.h"
39
39
 
40
40
/** @name Modes for buf_page_get_gen */
47
47
                                        it is error-prone programming
48
48
                                        not to set a latch, and it
49
49
                                        should be used with care */
 
50
#define BUF_GET_IF_IN_POOL_OR_WATCH     15
 
51
                                        /*!< Get the page only if it's in the
 
52
                                        buffer pool, if not then set a watch
 
53
                                        on the page. */
50
54
/* @} */
51
55
/** @name Modes for buf_page_get_known_nowait */
52
56
/* @{ */
59
63
                                        position of the block. */
60
64
/* @} */
61
65
 
62
 
extern buf_pool_t*      buf_pool;       /*!< The buffer pool of the database */
 
66
#define MAX_BUFFER_POOLS 64             /*!< The maximum number of buffer
 
67
                                        pools that can be defined */
 
68
 
 
69
#define BUF_POOL_WATCH_SIZE 1           /*!< Maximum number of concurrent
 
70
                                        buffer pool watches */
 
71
 
 
72
extern  buf_pool_t*     buf_pool_ptr[MAX_BUFFER_POOLS]; /*!< The buffer pools
 
73
                                        of the database */
63
74
#ifdef UNIV_DEBUG
64
75
extern ibool            buf_debug_prints;/*!< If this is set TRUE, the program
65
76
                                        prints info whenever read or flush
80
91
enum buf_page_state {
81
92
        BUF_BLOCK_ZIP_FREE = 0,         /*!< contains a free
82
93
                                        compressed page */
 
94
        BUF_BLOCK_POOL_WATCH = 0,       /*!< a sentinel for the buffer pool
 
95
                                        watch, element of buf_pool_watch[] */
83
96
        BUF_BLOCK_ZIP_PAGE,             /*!< contains a clean
84
97
                                        compressed page */
85
98
        BUF_BLOCK_ZIP_DIRTY,            /*!< contains a compressed
101
114
 
102
115
#ifndef UNIV_HOTBACKUP
103
116
/********************************************************************//**
 
117
Acquire mutex on all buffer pool instances */
 
118
UNIV_INLINE
 
119
void
 
120
buf_pool_mutex_enter_all(void);
 
121
/*===========================*/
 
122
 
 
123
/********************************************************************//**
 
124
Release mutex on all buffer pool instances */
 
125
UNIV_INLINE
 
126
void
 
127
buf_pool_mutex_exit_all(void);
 
128
/*==========================*/
 
129
 
 
130
/********************************************************************//**
104
131
Creates the buffer pool.
105
132
@return own: buf_pool object, NULL if not enough memory or error */
106
133
UNIV_INTERN
107
 
buf_pool_t*
108
 
buf_pool_init(void);
109
 
/*===============*/
 
134
ulint
 
135
buf_pool_init(
 
136
/*=========*/
 
137
        ulint   size,           /*!< in: Size of the total pool in bytes */
 
138
        ulint   n_instances);   /*!< in: Number of instances */
110
139
/********************************************************************//**
111
140
Frees the buffer pool at shutdown.  This must not be invoked before
112
141
freeing all mutexes. */
113
142
UNIV_INTERN
114
143
void
115
 
buf_pool_free(void);
116
 
/*===============*/
 
144
buf_pool_free(
 
145
/*==========*/
 
146
        ulint   n_instances);   /*!< in: numbere of instances to free */
117
147
 
118
148
/********************************************************************//**
119
149
Drops the adaptive hash index.  To prevent a livelock, this function
150
180
ulint
151
181
buf_pool_get_curr_size(void);
152
182
/*========================*/
 
183
/*********************************************************************//**
 
184
Gets the current size of buffer buf_pool in frames.
 
185
@return size in pages */
 
186
UNIV_INLINE
 
187
ulint
 
188
buf_pool_get_n_pages(void);
 
189
/*=======================*/
153
190
/********************************************************************//**
154
191
Gets the smallest oldest_modification lsn for any page in the pool. Returns
155
192
zero if all modified pages have been flushed to disk.
156
193
@return oldest modification in pool, zero if none */
157
 
UNIV_INLINE
 
194
UNIV_INTERN
158
195
ib_uint64_t
159
196
buf_pool_get_oldest_modification(void);
160
197
/*==================================*/
161
198
/********************************************************************//**
162
199
Allocates a buffer block.
163
200
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
164
 
UNIV_INLINE
 
201
UNIV_INTERN
165
202
buf_block_t*
166
203
buf_block_alloc(
167
204
/*============*/
168
 
        ulint   zip_size);      /*!< in: compressed page size in bytes,
169
 
                                or 0 if uncompressed tablespace */
 
205
        buf_pool_t*     buf_pool,       /*!< buffer pool instance */
 
206
        ulint           zip_size);      /*!< in: compressed page size in bytes,
 
207
                                        or 0 if uncompressed tablespace */
170
208
/********************************************************************//**
171
209
Frees a buffer block which does not contain a file page. */
172
210
UNIV_INLINE
284
322
        ulint           rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
285
323
        buf_block_t*    guess,  /*!< in: guessed block or NULL */
286
324
        ulint           mode,   /*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
287
 
                                BUF_GET_NO_LATCH */
 
325
                                BUF_GET_NO_LATCH or
 
326
                                BUF_GET_IF_IN_POOL_OR_WATCH */
288
327
        const char*     file,   /*!< in: file name */
289
328
        ulint           line,   /*!< in: line where called */
290
329
        mtr_t*          mtr);   /*!< in: mini-transaction */
334
373
buf_page_release(
335
374
/*=============*/
336
375
        buf_block_t*    block,          /*!< in: buffer block */
337
 
        ulint           rw_latch,       /*!< in: RW_S_LATCH, RW_X_LATCH,
 
376
        ulint           rw_latch);      /*!< in: RW_S_LATCH, RW_X_LATCH,
338
377
                                        RW_NO_LATCH */
339
 
        mtr_t*          mtr);           /*!< in: mtr */
340
378
/********************************************************************//**
341
379
Moves a page to the start of the buffer pool LRU list. This high-level
342
380
function can be used to prevent an important page from slipping out of
446
484
                                        page frame */
447
485
/********************************************************************//**
448
486
Increments the modify clock of a frame by 1. The caller must (1) own the
449
 
buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock
 
487
buf_pool->mutex and block bufferfix count has to be zero, (2) or own an x-lock
450
488
on the block. */
451
489
UNIV_INLINE
452
490
void
528
566
buf_block_t*
529
567
buf_pool_contains_zip(
530
568
/*==================*/
531
 
        const void*     data);  /*!< in: pointer to compressed page */
 
569
        buf_pool_t*     buf_pool,       /*!< in: buffer pool instance */
 
570
        const void*     data);          /*!< in: pointer to compressed page */
532
571
#endif /* UNIV_DEBUG */
533
572
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
534
573
/*********************************************************************//**
602
641
Refreshes the statistics used to print per-second averages. */
603
642
UNIV_INTERN
604
643
void
605
 
buf_refresh_io_stats(void);
606
 
/*======================*/
 
644
buf_refresh_io_stats(
 
645
/*=================*/
 
646
        buf_pool_t*     buf_pool);      /*!< buffer pool instance */
 
647
/**********************************************************************//**
 
648
Refreshes the statistics used to print per-second averages. */
 
649
UNIV_INTERN
 
650
void
 
651
buf_refresh_io_stats_all(void);
 
652
/*=================*/
607
653
/*********************************************************************//**
608
654
Asserts that all file pages in the buffer are in a replaceable state.
609
655
@return TRUE */
984
1030
        ulint   offset) /*!< in: offset of the page within space */
985
1031
        __attribute__((const));
986
1032
/******************************************************************//**
 
1033
Returns the buffer pool instance given a page instance
 
1034
@return buf_pool */
 
1035
UNIV_INLINE
 
1036
buf_pool_t*
 
1037
buf_pool_from_bpage(
 
1038
/*================*/
 
1039
        const buf_page_t*       bpage); /*!< in: buffer pool page */
 
1040
/******************************************************************//**
 
1041
Returns the buffer pool instance given a block instance
 
1042
@return buf_pool */
 
1043
UNIV_INLINE
 
1044
buf_pool_t*
 
1045
buf_pool_from_block(
 
1046
/*================*/
 
1047
        const buf_block_t*      block); /*!< in: block */
 
1048
/******************************************************************//**
 
1049
Returns the buffer pool instance given space and offset of page
 
1050
@return buffer pool */
 
1051
UNIV_INLINE
 
1052
buf_pool_t*
 
1053
buf_pool_get(
 
1054
/*==========*/
 
1055
        ulint   space,  /*!< in: space id */
 
1056
        ulint   offset);/*!< in: offset of the page within space */
 
1057
/******************************************************************//**
 
1058
Returns the buffer pool instance given its array index
 
1059
@return buffer pool */
 
1060
UNIV_INLINE
 
1061
buf_pool_t*
 
1062
buf_pool_from_array(
 
1063
/*====================*/
 
1064
        ulint   index); /*!< in: array index to get buffer pool instance from */
 
1065
/******************************************************************//**
987
1066
Returns the control block of a file page, NULL if not found.
988
1067
@return block, NULL if not found */
989
1068
UNIV_INLINE
990
1069
buf_page_t*
 
1070
buf_page_hash_get_low(
 
1071
/*==================*/
 
1072
        buf_pool_t*     buf_pool,       /*!< buffer pool instance */
 
1073
        ulint           space,          /*!< in: space id */
 
1074
        ulint           offset,         /*!< in: offset of the page
 
1075
                                        within space */
 
1076
        ulint           fold);          /*!< in: buf_page_address_fold(
 
1077
                                        space, offset) */
 
1078
/******************************************************************//**
 
1079
Returns the control block of a file page, NULL if not found.
 
1080
@return block, NULL if not found or not a real control block */
 
1081
UNIV_INLINE
 
1082
buf_page_t*
991
1083
buf_page_hash_get(
992
1084
/*==============*/
993
 
        ulint   space,  /*!< in: space id */
994
 
        ulint   offset);/*!< in: offset of the page within space */
 
1085
        buf_pool_t*     buf_pool,       /*!< in: buffer pool instance */
 
1086
        ulint           space,          /*!< in: space id */
 
1087
        ulint           offset);        /*!< in: offset of the page
 
1088
                                        within space */
995
1089
/******************************************************************//**
996
1090
Returns the control block of a file page, NULL if not found
997
1091
or an uncompressed page frame does not exist.
1000
1094
buf_block_t*
1001
1095
buf_block_hash_get(
1002
1096
/*===============*/
1003
 
        ulint   space,  /*!< in: space id */
1004
 
        ulint   offset);/*!< in: offset of the page within space */
 
1097
        buf_pool_t*     buf_pool,       /*!< in: buffer pool instance */
 
1098
        ulint           space,          /*!< in: space id */
 
1099
        ulint           offset);        /*!< in: offset of the page
 
1100
                                        within space */
1005
1101
/*********************************************************************//**
1006
1102
Gets the current length of the free list of buffer blocks.
1007
1103
@return length of the free list */
1009
1105
ulint
1010
1106
buf_get_free_list_len(void);
1011
1107
/*=======================*/
 
1108
 
 
1109
/********************************************************************
 
1110
Determine if a block is a sentinel for a buffer pool watch.
 
1111
@return TRUE if a sentinel for a buffer pool watch, FALSE if not */
 
1112
UNIV_INTERN
 
1113
ibool
 
1114
buf_pool_watch_is_sentinel(
 
1115
/*=======================*/
 
1116
        buf_pool_t*             buf_pool,       /*!< buffer pool instance */
 
1117
        const buf_page_t*       bpage)          /*!< in: block */
 
1118
        __attribute__((nonnull, warn_unused_result));
 
1119
/****************************************************************//**
 
1120
Add watch for the given page to be read in. Caller must have the buffer pool
 
1121
@return NULL if watch set, block if the page is in the buffer pool */
 
1122
UNIV_INTERN
 
1123
buf_page_t*
 
1124
buf_pool_watch_set(
 
1125
/*===============*/
 
1126
        ulint   space,  /*!< in: space id */
 
1127
        ulint   offset, /*!< in: page number */
 
1128
        ulint   fold)   /*!< in: buf_page_address_fold(space, offset) */
 
1129
        __attribute__((warn_unused_result));
 
1130
/****************************************************************//**
 
1131
Stop watching if the page has been read in.
 
1132
buf_pool_watch_set(space,offset) must have returned NULL before. */
 
1133
UNIV_INTERN
 
1134
void
 
1135
buf_pool_watch_unset(
 
1136
/*=================*/
 
1137
        ulint   space,  /*!< in: space id */
 
1138
        ulint   offset);/*!< in: page number */
 
1139
/****************************************************************//**
 
1140
Check if the page has been read in.
 
1141
This may only be called after buf_pool_watch_set(space,offset)
 
1142
has returned NULL and before invoking buf_pool_watch_unset(space,offset).
 
1143
@return FALSE if the given page was not read in, TRUE if it was */
 
1144
UNIV_INTERN
 
1145
ibool
 
1146
buf_pool_watch_occurred(
 
1147
/*====================*/
 
1148
        ulint   space,  /*!< in: space id */
 
1149
        ulint   offset) /*!< in: page number */
 
1150
        __attribute__((warn_unused_result));
 
1151
/********************************************************************//**
 
1152
Get total buffer pool statistics. */
 
1153
UNIV_INTERN
 
1154
void
 
1155
buf_get_total_list_len(
 
1156
/*===================*/
 
1157
        ulint*          LRU_len,        /*!< out: length of all LRU lists */
 
1158
        ulint*          free_len,       /*!< out: length of all free lists */
 
1159
        ulint*          flush_list_len);/*!< out: length of all flush lists */
 
1160
/********************************************************************//**
 
1161
Get total buffer pool statistics. */
 
1162
UNIV_INTERN
 
1163
void
 
1164
buf_get_total_stat(
 
1165
/*===============*/
 
1166
        buf_pool_stat_t*tot_stat);      /*!< out: buffer pool stats */
 
1167
 
1012
1168
#endif /* !UNIV_HOTBACKUP */
1013
1169
 
1014
 
 
1015
1170
/** The common buffer control block structure
1016
1171
for compressed and uncompressed frames */
1017
1172
 
1019
1174
        /** @name General fields
1020
1175
        None of these bit-fields must be modified without holding
1021
1176
        buf_page_get_mutex() [buf_block_struct::mutex or
1022
 
        buf_pool_zip_mutex], since they can be stored in the same
 
1177
        buf_pool->zip_mutex], since they can be stored in the same
1023
1178
        machine word.  Some of these fields are additionally protected
1024
 
        by buf_pool_mutex. */
 
1179
        by buf_pool->mutex. */
1025
1180
        /* @{ */
1026
1181
 
1027
1182
        unsigned        space:32;       /*!< tablespace id; also protected
1028
 
                                        by buf_pool_mutex. */
 
1183
                                        by buf_pool->mutex. */
1029
1184
        unsigned        offset:32;      /*!< page number; also protected
1030
 
                                        by buf_pool_mutex. */
 
1185
                                        by buf_pool->mutex. */
1031
1186
 
1032
1187
        unsigned        state:3;        /*!< state of the control block; also
1033
 
                                        protected by buf_pool_mutex.
 
1188
                                        protected by buf_pool->mutex.
1034
1189
                                        State transitions from
1035
1190
                                        BUF_BLOCK_READY_FOR_USE to
1036
1191
                                        BUF_BLOCK_MEMORY need not be
1042
1197
                                        flush_type.
1043
1198
                                        @see enum buf_flush */
1044
1199
        unsigned        io_fix:2;       /*!< type of pending I/O operation;
1045
 
                                        also protected by buf_pool_mutex
 
1200
                                        also protected by buf_pool->mutex
1046
1201
                                        @see enum buf_io_fix */
1047
1202
        unsigned        buf_fix_count:25;/*!< count of how manyfold this block
1048
1203
                                        is currently bufferfixed */
1050
1205
#endif /* !UNIV_HOTBACKUP */
1051
1206
        page_zip_des_t  zip;            /*!< compressed page; zip.data
1052
1207
                                        (but not the data it points to) is
1053
 
                                        also protected by buf_pool_mutex */
 
1208
                                        also protected by buf_pool_mutex;
 
1209
                                        state == BUF_BLOCK_ZIP_PAGE and
 
1210
                                        zip.data == NULL means an active
 
1211
                                        buf_pool_watch */
1054
1212
#ifndef UNIV_HOTBACKUP
1055
1213
        buf_page_t*     hash;           /*!< node used in chaining to
1056
1214
                                        buf_pool->page_hash or
1066
1224
 
1067
1225
        UT_LIST_NODE_T(buf_page_t) list;
1068
1226
                                        /*!< based on state, this is a
1069
 
                                        list node, protected only by
1070
 
                                        buf_pool_mutex, in one of the
 
1227
                                        list node, protected either by
 
1228
                                        buf_pool_mutex or by
 
1229
                                        flush_list_mutex, in one of the
1071
1230
                                        following lists in buf_pool:
1072
1231
 
1073
1232
                                        - BUF_BLOCK_NOT_USED:   free
1076
1235
                                        - BUF_BLOCK_ZIP_PAGE:   zip_clean
1077
1236
                                        - BUF_BLOCK_ZIP_FREE:   zip_free[]
1078
1237
 
 
1238
                                        If bpage is part of flush_list
 
1239
                                        then the node pointers are
 
1240
                                        covered by flush_list_mutex.
 
1241
                                        Otherwise these pointers are
 
1242
                                        protected by buf_pool_mutex.
 
1243
 
1079
1244
                                        The contents of the list node
1080
1245
                                        is undefined if !in_flush_list
1081
1246
                                        && state == BUF_BLOCK_FILE_PAGE,
1086
1251
 
1087
1252
#ifdef UNIV_DEBUG
1088
1253
        ibool           in_flush_list;  /*!< TRUE if in buf_pool->flush_list;
1089
 
                                        when buf_pool_mutex is free, the
 
1254
                                        when flush_list_mutex is free, the
1090
1255
                                        following should hold: in_flush_list
1091
1256
                                        == (state == BUF_BLOCK_FILE_PAGE
1092
 
                                            || state == BUF_BLOCK_ZIP_DIRTY) */
 
1257
                                            || state == BUF_BLOCK_ZIP_DIRTY)
 
1258
                                        Writes to this field must be
 
1259
                                        covered by both block->mutex
 
1260
                                        and flush_list_mutex. Hence
 
1261
                                        reads can happen while holding
 
1262
                                        any one of the two mutexes */
1093
1263
        ibool           in_free_list;   /*!< TRUE if in buf_pool->free; when
1094
1264
                                        buf_pool_mutex is free, the following
1095
1265
                                        should hold: in_free_list
1099
1269
                                        /*!< log sequence number of
1100
1270
                                        the youngest modification to
1101
1271
                                        this block, zero if not
1102
 
                                        modified */
 
1272
                                        modified. Protected by block
 
1273
                                        mutex */
1103
1274
        ib_uint64_t     oldest_modification;
1104
1275
                                        /*!< log sequence number of
1105
1276
                                        the START of the log entry
1107
1278
                                        modification to this block
1108
1279
                                        which has not yet been flushed
1109
1280
                                        on disk; zero if all
1110
 
                                        modifications are on disk */
 
1281
                                        modifications are on disk.
 
1282
                                        Writes to this field must be
 
1283
                                        covered by both block->mutex
 
1284
                                        and flush_list_mutex. Hence
 
1285
                                        reads can happen while holding
 
1286
                                        any one of the two mutexes */
1111
1287
        /* @} */
1112
1288
        /** @name LRU replacement algorithm fields
1113
 
        These fields are protected by buf_pool_mutex only (not
1114
 
        buf_pool_zip_mutex or buf_block_struct::mutex). */
 
1289
        These fields are protected by buf_pool->mutex only (not
 
1290
        buf_pool->zip_mutex or buf_block_struct::mutex). */
1115
1291
        /* @{ */
1116
1292
 
1117
1293
        UT_LIST_NODE_T(buf_page_t) LRU;
1141
1317
                                        frees a page in buffer pool */
1142
1318
# endif /* UNIV_DEBUG_FILE_ACCESSES */
1143
1319
#endif /* !UNIV_HOTBACKUP */
 
1320
        buf_pool_t*     buf_pool;       /*!< buffer pool instance this
 
1321
                                        page belongs to */
1144
1322
};
1145
1323
 
1146
1324
/** The buffer control block structure */
1180
1358
        unsigned        lock_hash_val:32;/*!< hashed value of the page address
1181
1359
                                        in the record lock hash table;
1182
1360
                                        protected by buf_block_t::lock
1183
 
                                        (or buf_block_t::mutex, buf_pool_mutex
 
1361
                                        (or buf_block_t::mutex, buf_pool->mutex
1184
1362
                                        in buf_page_get_gen(),
1185
1363
                                        buf_page_init_for_read()
1186
1364
                                        and buf_page_create()) */
1309
1487
                                buf_page_peek_if_too_old() */
1310
1488
};
1311
1489
 
 
1490
/** Statistics of buddy blocks of a given size. */
 
1491
struct buf_buddy_stat_struct {
 
1492
        /** Number of blocks allocated from the buddy system. */
 
1493
        ulint           used;
 
1494
        /** Number of blocks relocated by the buddy system. */
 
1495
        ib_uint64_t     relocated;
 
1496
        /** Total duration of block relocations, in microseconds. */
 
1497
        ib_uint64_t     relocated_usec;
 
1498
};
 
1499
 
1312
1500
/** @brief The buffer pool structure.
1313
1501
 
1314
1502
NOTE! The definition appears here only for other modules of this
1318
1506
 
1319
1507
        /** @name General fields */
1320
1508
        /* @{ */
1321
 
 
 
1509
        mutex_t         mutex;          /*!< Buffer pool mutex of this
 
1510
                                        instance */
 
1511
        mutex_t         zip_mutex;      /*!< Zip mutex of this buffer
 
1512
                                        pool instance, protects compressed
 
1513
                                        only pages (of type buf_page_t, not
 
1514
                                        buf_block_t */
 
1515
        ulint           instance_no;    /*!< Array index of this buffer
 
1516
                                        pool instance */
 
1517
        ulint           old_pool_size;  /*!< Old pool size in bytes */
 
1518
        ulint           curr_pool_size; /*!< Current pool size in bytes */
 
1519
        ulint           LRU_old_ratio;  /*!< Reserve this much of the buffer
 
1520
                                        pool for "old" blocks */
 
1521
#ifdef UNIV_DEBUG
 
1522
        ulint           buddy_n_frames; /*!< Number of frames allocated from
 
1523
                                        the buffer pool to the buddy system */
 
1524
#endif
 
1525
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 
1526
        ulint           mutex_exit_forbidden; /*!< Forbid release mutex */
 
1527
#endif
1322
1528
        ulint           n_chunks;       /*!< number of buffer pool chunks */
1323
1529
        buf_chunk_t*    chunks;         /*!< buffer pool chunks */
1324
1530
        ulint           curr_size;      /*!< current pool size in pages */
1330
1536
                                        whose frames are allocated to the
1331
1537
                                        zip buddy system,
1332
1538
                                        indexed by block->frame */
1333
 
        ulint           n_pend_reads;   /*!< number of pending read operations */
 
1539
        ulint           n_pend_reads;   /*!< number of pending read
 
1540
                                        operations */
1334
1541
        ulint           n_pend_unzip;   /*!< number of pending decompressions */
1335
1542
 
1336
1543
        time_t          last_printout_time;
1337
1544
                                        /*!< when buf_print_io was last time
1338
1545
                                        called */
 
1546
        buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES + 1];
 
1547
                                        /*!< Statistics of buddy system,
 
1548
                                        indexed by block size */
1339
1549
        buf_pool_stat_t stat;           /*!< current statistics */
1340
1550
        buf_pool_stat_t old_stat;       /*!< old statistics */
1341
1551
 
1345
1555
 
1346
1556
        /* @{ */
1347
1557
 
 
1558
        mutex_t         flush_list_mutex;/*!< mutex protecting the
 
1559
                                        flush list access. This mutex
 
1560
                                        protects flush_list, flush_rbt
 
1561
                                        and bpage::list pointers when
 
1562
                                        the bpage is on flush_list. It
 
1563
                                        also protects writes to
 
1564
                                        bpage::oldest_modification */
1348
1565
        UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
1349
1566
                                        /*!< base node of the modified block
1350
1567
                                        list */
1358
1575
                                        /*!< this is in the set state
1359
1576
                                        when there is no flush batch
1360
1577
                                        of the given type running */
1361
 
        ib_rbt_t*       flush_rbt;      /* !< a red-black tree is used
 
1578
        ib_rbt_t*       flush_rbt;      /*!< a red-black tree is used
1362
1579
                                        exclusively during recovery to
1363
1580
                                        speed up insertions in the
1364
1581
                                        flush_list. This tree contains
1370
1587
                                        also be on the flush_list.
1371
1588
                                        This tree is relevant only in
1372
1589
                                        recovery and is set to NULL
1373
 
                                        once the recovery is over. */
 
1590
                                        once the recovery is over.
 
1591
                                        Protected by flush_list_mutex */
1374
1592
        ulint           freed_page_clock;/*!< a sequence number used
1375
1593
                                        to count the number of buffer
1376
1594
                                        blocks removed from the end of
1384
1602
                                        this is incremented by one; this is
1385
1603
                                        set to zero when a buffer block is
1386
1604
                                        allocated */
 
1605
        /* @} */
1387
1606
 
1388
 
        /* @} */
1389
1607
        /** @name LRU replacement algorithm fields */
1390
1608
        /* @{ */
1391
1609
 
1423
1641
                                        /*!< unmodified compressed pages */
1424
1642
        UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES];
1425
1643
                                        /*!< buddy free lists */
 
1644
 
 
1645
        buf_page_t                      watch[BUF_POOL_WATCH_SIZE];
 
1646
                                        /*!< Sentinel records for buffer
 
1647
                                        pool watches. Protected by
 
1648
                                        buf_pool->mutex. */
 
1649
 
1426
1650
#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
1427
1651
# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
1428
1652
#endif
1444
1668
/* @{ */
1445
1669
 
1446
1670
/** Test if buf_pool_mutex is owned. */
1447
 
#define buf_pool_mutex_own() mutex_own(&buf_pool_mutex)
 
1671
#define buf_pool_mutex_own(b) mutex_own(&b->mutex)
1448
1672
/** Acquire the buffer pool mutex. */
1449
 
#define buf_pool_mutex_enter() do {             \
1450
 
        ut_ad(!mutex_own(&buf_pool_zip_mutex)); \
1451
 
        mutex_enter(&buf_pool_mutex);           \
1452
 
} while (0)
 
1673
#define buf_pool_mutex_enter(b) do {            \
 
1674
        ut_ad(!mutex_own(&b->zip_mutex));       \
 
1675
        mutex_enter(&b->mutex);         \
 
1676
} while (0)
 
1677
 
 
1678
/** Test if flush list mutex is owned. */
 
1679
#define buf_flush_list_mutex_own(b) mutex_own(&b->flush_list_mutex)
 
1680
 
 
1681
/** Acquire the flush list mutex. */
 
1682
#define buf_flush_list_mutex_enter(b) do {      \
 
1683
        mutex_enter(&b->flush_list_mutex);      \
 
1684
} while (0)
 
1685
/** Release the flush list mutex. */
 
1686
# define buf_flush_list_mutex_exit(b) do {      \
 
1687
        mutex_exit(&b->flush_list_mutex);       \
 
1688
} while (0)
 
1689
 
 
1690
 
1453
1691
 
1454
1692
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1455
 
/** Flag to forbid the release of the buffer pool mutex.
1456
 
Protected by buf_pool_mutex. */
1457
 
extern ulint    buf_pool_mutex_exit_forbidden;
1458
1693
/** Forbid the release of the buffer pool mutex. */
1459
 
# define buf_pool_mutex_exit_forbid() do {      \
1460
 
        ut_ad(buf_pool_mutex_own());            \
1461
 
        buf_pool_mutex_exit_forbidden++;        \
 
1694
# define buf_pool_mutex_exit_forbid(b) do {     \
 
1695
        ut_ad(buf_pool_mutex_own(b));           \
 
1696
        b->mutex_exit_forbidden++;              \
1462
1697
} while (0)
1463
1698
/** Allow the release of the buffer pool mutex. */
1464
 
# define buf_pool_mutex_exit_allow() do {       \
1465
 
        ut_ad(buf_pool_mutex_own());            \
1466
 
        ut_a(buf_pool_mutex_exit_forbidden);    \
1467
 
        buf_pool_mutex_exit_forbidden--;        \
 
1699
# define buf_pool_mutex_exit_allow(b) do {      \
 
1700
        ut_ad(buf_pool_mutex_own(b));           \
 
1701
        ut_a(b->mutex_exit_forbidden);  \
 
1702
        b->mutex_exit_forbidden--;              \
1468
1703
} while (0)
1469
1704
/** Release the buffer pool mutex. */
1470
 
# define buf_pool_mutex_exit() do {             \
1471
 
        ut_a(!buf_pool_mutex_exit_forbidden);   \
1472
 
        mutex_exit(&buf_pool_mutex);            \
 
1705
# define buf_pool_mutex_exit(b) do {            \
 
1706
        ut_a(!b->mutex_exit_forbidden);         \
 
1707
        mutex_exit(&b->mutex);                  \
1473
1708
} while (0)
1474
1709
#else
1475
1710
/** Forbid the release of the buffer pool mutex. */
1476
 
# define buf_pool_mutex_exit_forbid() ((void) 0)
 
1711
# define buf_pool_mutex_exit_forbid(b) ((void) 0)
1477
1712
/** Allow the release of the buffer pool mutex. */
1478
 
# define buf_pool_mutex_exit_allow() ((void) 0)
 
1713
# define buf_pool_mutex_exit_allow(b) ((void) 0)
1479
1714
/** Release the buffer pool mutex. */
1480
 
# define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex)
 
1715
# define buf_pool_mutex_exit(b) mutex_exit(&b->mutex)
1481
1716
#endif
1482
1717
#endif /* !UNIV_HOTBACKUP */
1483
1718
/* @} */