~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
1819.5.221 by vasil
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6749 from MySQL InnoDB
3
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
16
17
*****************************************************************************/
18
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
19
/**************************************************//**
20
@file include/buf0buf.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
The database buffer pool high-level routines
22
23
Created 11/5/1995 Heikki Tuuri
24
*******************************************************/
25
26
#ifndef buf0buf_h
27
#define buf0buf_h
28
29
#include "univ.i"
30
#include "fil0fil.h"
31
#include "mtr0types.h"
32
#include "buf0types.h"
33
#include "hash0hash.h"
34
#include "ut0byte.h"
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
35
#include "page0types.h"
1819.5.251 by jyang
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6860 from MySQL InnoDB
36
#include "ut0rbt.h"
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
37
#ifndef UNIV_HOTBACKUP
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
38
#include "os0proc.h"
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
39
40
/** @name Modes for buf_page_get_gen */
41
/* @{ */
42
#define BUF_GET			10	/*!< get always */
43
#define	BUF_GET_IF_IN_POOL	11	/*!< get if in pool */
44
#define BUF_GET_NO_LATCH	14	/*!< get and bufferfix, but
45
					set no latch; we have
46
					separated this case, because
47
					it is error-prone programming
48
					not to set a latch, and it
49
					should be used with care */
50
/* @} */
51
/** @name Modes for buf_page_get_known_nowait */
52
/* @{ */
53
#define BUF_MAKE_YOUNG	51		/*!< Move the block to the
54
					start of the LRU list if there
55
					is a danger that the block
56
					would drift out of the buffer
57
					pool*/
58
#define BUF_KEEP_OLD	52		/*!< Preserve the current LRU
59
					position of the block. */
60
/* @} */
61
62
extern buf_pool_t*	buf_pool;	/*!< The buffer pool of the database */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
63
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
64
extern ibool		buf_debug_prints;/*!< If this is set TRUE, the program
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
65
					prints info whenever read or flush
66
					occurs */
67
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
68
#else /* !UNIV_HOTBACKUP */
69
extern buf_block_t*	back_block1;	/*!< first block, for --apply-log */
70
extern buf_block_t*	back_block2;	/*!< second block, for page reorganize */
71
#endif /* !UNIV_HOTBACKUP */
72
73
/** Magic value to use instead of checksums when they are disabled */
74
#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
75
76
/** @brief States of a control block
77
@see buf_page_struct
78
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
79
The enumeration values must be 0..7. */
80
enum buf_page_state {
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
81
	BUF_BLOCK_ZIP_FREE = 0,		/*!< contains a free
82
					compressed page */
83
	BUF_BLOCK_ZIP_PAGE,		/*!< contains a clean
84
					compressed page */
85
	BUF_BLOCK_ZIP_DIRTY,		/*!< contains a compressed
86
					page that is in the
87
					buf_pool->flush_list */
88
89
	BUF_BLOCK_NOT_USED,		/*!< is in the free list;
90
					must be after the BUF_BLOCK_ZIP_
91
					constants for compressed-only pages
92
					@see buf_block_state_valid() */
93
	BUF_BLOCK_READY_FOR_USE,	/*!< when buf_LRU_get_free_block
94
					returns a block, it is in this state */
95
	BUF_BLOCK_FILE_PAGE,		/*!< contains a buffered file page */
96
	BUF_BLOCK_MEMORY,		/*!< contains some main memory
97
					object */
98
	BUF_BLOCK_REMOVE_HASH		/*!< hash index should be removed
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
99
					before putting to the free list */
100
};
101
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
102
#ifndef UNIV_HOTBACKUP
103
/********************************************************************//**
104
Creates the buffer pool.
105
@return	own: buf_pool object, NULL if not enough memory or error */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
106
UNIV_INTERN
107
buf_pool_t*
108
buf_pool_init(void);
109
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
110
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
111
Frees the buffer pool at shutdown.  This must not be invoked before
112
freeing all mutexes. */
113
UNIV_INTERN
114
void
115
buf_pool_free(void);
116
/*===============*/
117
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
118
/********************************************************************//**
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
119
Drops the adaptive hash index.  To prevent a livelock, this function
120
is only to be called while holding btr_search_latch and while
121
btr_search_enabled == FALSE. */
122
UNIV_INTERN
123
void
124
buf_pool_drop_hash_index(void);
125
/*==========================*/
126
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
127
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
128
Relocate a buffer control block.  Relocates the block on the LRU list
129
and in buf_pool->page_hash.  Does not relocate bpage->list.
130
The caller must take care of relocating bpage->list. */
131
UNIV_INTERN
132
void
133
buf_relocate(
134
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
135
	buf_page_t*	bpage,	/*!< in/out: control block being relocated;
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
136
				buf_page_get_state(bpage) must be
137
				BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
138
	buf_page_t*	dpage)	/*!< in/out: destination control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
139
	__attribute__((nonnull));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
140
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
141
Resizes the buffer pool. */
142
UNIV_INTERN
143
void
144
buf_pool_resize(void);
145
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
146
/*********************************************************************//**
147
Gets the current size of buffer buf_pool in bytes.
148
@return	size in bytes */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
149
UNIV_INLINE
150
ulint
151
buf_pool_get_curr_size(void);
152
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
153
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
154
Gets the smallest oldest_modification lsn for any page in the pool. Returns
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
155
zero if all modified pages have been flushed to disk.
156
@return	oldest modification in pool, zero if none */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
157
UNIV_INLINE
158
ib_uint64_t
159
buf_pool_get_oldest_modification(void);
160
/*==================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
161
/********************************************************************//**
162
Allocates a buffer block.
163
@return	own: the allocated block, in state BUF_BLOCK_MEMORY */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
164
UNIV_INLINE
165
buf_block_t*
166
buf_block_alloc(
167
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
168
	ulint	zip_size);	/*!< in: compressed page size in bytes,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
169
				or 0 if uncompressed tablespace */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
170
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
171
Frees a buffer block which does not contain a file page. */
172
UNIV_INLINE
173
void
174
buf_block_free(
175
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
176
	buf_block_t*	block);	/*!< in, own: block to be freed */
177
#endif /* !UNIV_HOTBACKUP */
178
/*********************************************************************//**
179
Copies contents of a buffer frame to a given buffer.
180
@return	buf */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
181
UNIV_INLINE
182
byte*
183
buf_frame_copy(
184
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
185
	byte*			buf,	/*!< in: buffer to copy to */
186
	const buf_frame_t*	frame);	/*!< in: buffer frame */
187
#ifndef UNIV_HOTBACKUP
188
/**************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
189
NOTE! The following macros should be used instead of buf_page_get_gen,
190
to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed
191
in LA! */
192
#define buf_page_get(SP, ZS, OF, LA, MTR)	 buf_page_get_gen(\
193
				SP, ZS, OF, LA, NULL,\
194
				BUF_GET, __FILE__, __LINE__, MTR)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
195
/**************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
196
Use these macros to bufferfix a page with no latching. Remember not to
197
read the contents of the page unless you know it is safe. Do not modify
198
the contents of the page! We have separated this case, because it is
199
error-prone programming not to set a latch, and it should be used
200
with care. */
201
#define buf_page_get_with_no_latch(SP, ZS, OF, MTR)	   buf_page_get_gen(\
202
				SP, ZS, OF, RW_NO_LATCH, NULL,\
203
				BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
204
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
205
This is the general function used to get optimistic access to a database
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
206
page.
207
@return	TRUE if success */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
208
UNIV_INTERN
209
ibool
1819.5.187 by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB
210
buf_page_optimistic_get(
211
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
212
	ulint		rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
213
	buf_block_t*	block,	/*!< in: guessed block */
214
	ib_uint64_t	modify_clock,/*!< in: modify clock value if mode is
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
215
				..._GUESS_ON_CLOCK */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
216
	const char*	file,	/*!< in: file name */
217
	ulint		line,	/*!< in: line where called */
218
	mtr_t*		mtr);	/*!< in: mini-transaction */
219
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
220
This is used to get access to a known database page, when no waiting can be
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
221
done.
222
@return	TRUE if success */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
223
UNIV_INTERN
224
ibool
225
buf_page_get_known_nowait(
226
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
227
	ulint		rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
228
	buf_block_t*	block,	/*!< in: the known page */
229
	ulint		mode,	/*!< in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */
230
	const char*	file,	/*!< in: file name */
231
	ulint		line,	/*!< in: line where called */
232
	mtr_t*		mtr);	/*!< in: mini-transaction */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
233
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
234
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
235
Given a tablespace id and page number tries to get that page. If the
236
page is not in the buffer pool it is not loaded and NULL is returned.
237
Suitable for using when holding the kernel mutex. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
238
UNIV_INTERN
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
239
const buf_block_t*
240
buf_page_try_get_func(
241
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
242
	ulint		space_id,/*!< in: tablespace id */
243
	ulint		page_no,/*!< in: page number */
244
	const char*	file,	/*!< in: file name */
245
	ulint		line,	/*!< in: line where called */
246
	mtr_t*		mtr);	/*!< in: mini-transaction */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
247
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
248
/** Tries to get a page. If the page is not in the buffer pool it is
249
not loaded.  Suitable for using when holding the kernel mutex.
250
@param space_id	in: tablespace id
251
@param page_no	in: page number
252
@param mtr	in: mini-transaction
253
@return		the page if in buffer pool, NULL if not */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
254
#define buf_page_try_get(space_id, page_no, mtr)	\
255
	buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
256
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
257
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
258
Get read access to a compressed page (usually of type
259
FIL_PAGE_TYPE_ZBLOB or FIL_PAGE_TYPE_ZBLOB2).
260
The page must be released with buf_page_release_zip().
261
NOTE: the page is not protected by any latch.  Mutual exclusion has to
262
be implemented at a higher level.  In other words, all possible
263
accesses to a given page through this function must be protected by
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
264
the same set of mutexes or latches.
265
@return	pointer to the block, or NULL if not compressed */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
266
UNIV_INTERN
267
buf_page_t*
268
buf_page_get_zip(
269
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
270
	ulint		space,	/*!< in: space id */
271
	ulint		zip_size,/*!< in: compressed page size */
272
	ulint		offset);/*!< in: page number */
273
/********************************************************************//**
274
This is the general function used to get access to a database page.
275
@return	pointer to the block or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
276
UNIV_INTERN
277
buf_block_t*
278
buf_page_get_gen(
279
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
280
	ulint		space,	/*!< in: space id */
281
	ulint		zip_size,/*!< in: compressed page size in bytes
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
282
				or 0 for uncompressed pages */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
283
	ulint		offset,	/*!< in: page number */
284
	ulint		rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
285
	buf_block_t*	guess,	/*!< in: guessed block or NULL */
286
	ulint		mode,	/*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
287
				BUF_GET_NO_LATCH */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
288
	const char*	file,	/*!< in: file name */
289
	ulint		line,	/*!< in: line where called */
290
	mtr_t*		mtr);	/*!< in: mini-transaction */
291
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
292
Initializes a page to the buffer buf_pool. The page is usually not read
293
from a file even if it cannot be found in the buffer buf_pool. This is one
294
of the functions which perform to a block a state transition NOT_USED =>
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
295
FILE_PAGE (the other is buf_page_get_gen).
296
@return	pointer to the block, page bufferfixed */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
297
UNIV_INTERN
298
buf_block_t*
299
buf_page_create(
300
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
301
	ulint	space,	/*!< in: space id */
302
	ulint	offset,	/*!< in: offset of the page within space in units of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
303
			a page */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
304
	ulint	zip_size,/*!< in: compressed page size, or 0 */
305
	mtr_t*	mtr);	/*!< in: mini-transaction handle */
306
#else /* !UNIV_HOTBACKUP */
307
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
308
Inits a page to the buffer buf_pool, for use in ibbackup --restore. */
309
UNIV_INTERN
310
void
311
buf_page_init_for_backup_restore(
312
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
313
	ulint		space,	/*!< in: space id */
314
	ulint		offset,	/*!< in: offset of the page within space
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
315
				in units of a page */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
316
	ulint		zip_size,/*!< in: compressed page size in bytes
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
317
				or 0 for uncompressed pages */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
318
	buf_block_t*	block);	/*!< in: block to init */
319
#endif /* !UNIV_HOTBACKUP */
320
321
#ifndef UNIV_HOTBACKUP
322
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
323
Releases a compressed-only page acquired with buf_page_get_zip(). */
324
UNIV_INLINE
325
void
326
buf_page_release_zip(
327
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
328
	buf_page_t*	bpage);		/*!< in: buffer block */
329
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
330
Decrements the bufferfix count of a buffer control block and releases
331
a latch, if specified. */
332
UNIV_INLINE
333
void
334
buf_page_release(
335
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
336
	buf_block_t*	block,		/*!< in: buffer block */
337
	ulint		rw_latch,	/*!< in: RW_S_LATCH, RW_X_LATCH,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
338
					RW_NO_LATCH */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
339
	mtr_t*		mtr);		/*!< in: mtr */
340
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
341
Moves a page to the start of the buffer pool LRU list. This high-level
1819.5.44 by stewart at flamingspork
[patch 044/129] Merge patch for revision 1832 from InnoDB SVN:
342
function can be used to prevent an important page from slipping out of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
343
the buffer pool. */
344
UNIV_INTERN
345
void
346
buf_page_make_young(
347
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
348
	buf_page_t*	bpage);	/*!< in: buffer block of a file page */
349
/********************************************************************//**
350
Returns TRUE if the page can be found in the buffer pool hash table.
351
352
NOTE that it is possible that the page is not yet read from disk,
353
though.
354
355
@return	TRUE if found in the page hash table */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
356
UNIV_INLINE
357
ibool
358
buf_page_peek(
359
/*==========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
360
	ulint	space,	/*!< in: space id */
361
	ulint	offset);/*!< in: page number */
362
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
363
Resets the check_index_page_at_flush field of a page if found in the buffer
364
pool. */
365
UNIV_INTERN
366
void
367
buf_reset_check_index_page_at_flush(
368
/*================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
369
	ulint	space,	/*!< in: space id */
370
	ulint	offset);/*!< in: page number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
371
#ifdef UNIV_DEBUG_FILE_ACCESSES
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
372
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
373
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
374
This function should be called when we free a file page and want the
375
debug version to check that it is not accessed any more unless
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
376
reallocated.
377
@return	control block if found in page hash table, otherwise NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
378
UNIV_INTERN
379
buf_page_t*
380
buf_page_set_file_page_was_freed(
381
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
382
	ulint	space,	/*!< in: space id */
383
	ulint	offset);/*!< in: page number */
384
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
385
Sets file_page_was_freed FALSE if the page is found in the buffer pool.
386
This function should be called when we free a file page and want the
387
debug version to check that it is not accessed any more unless
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
388
reallocated.
389
@return	control block if found in page hash table, otherwise NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
390
UNIV_INTERN
391
buf_page_t*
392
buf_page_reset_file_page_was_freed(
393
/*===============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
394
	ulint	space,	/*!< in: space id */
395
	ulint	offset);	/*!< in: page number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
396
#endif /* UNIV_DEBUG_FILE_ACCESSES */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
397
/********************************************************************//**
398
Reads the freed_page_clock of a buffer block.
399
@return	freed_page_clock */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
400
UNIV_INLINE
401
ulint
402
buf_page_get_freed_page_clock(
403
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
404
	const buf_page_t*	bpage)	/*!< in: block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
405
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
406
/********************************************************************//**
407
Reads the freed_page_clock of a buffer block.
408
@return	freed_page_clock */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
409
UNIV_INLINE
410
ulint
411
buf_block_get_freed_page_clock(
412
/*===========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
413
	const buf_block_t*	block)	/*!< in: block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
414
	__attribute__((pure));
415
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
416
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
417
Recommends a move of a block to the start of the LRU list if there is danger
418
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
419
mutex.
420
@return	TRUE if should be made younger */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
421
UNIV_INLINE
422
ibool
423
buf_page_peek_if_too_old(
424
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
425
	const buf_page_t*	bpage);	/*!< in: block to make younger */
426
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
427
Returns the current state of is_hashed of a page. FALSE if the page is
428
not in the pool. NOTE that this operation does not fix the page in the
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
429
pool if it is found there.
430
@return	TRUE if page hash index is built in search system */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
431
UNIV_INTERN
432
ibool
433
buf_page_peek_if_search_hashed(
434
/*===========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
435
	ulint	space,	/*!< in: space id */
436
	ulint	offset);/*!< in: page number */
437
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
438
Gets the youngest modification log sequence number for a frame.
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
439
Returns zero if not file page or no modification occurred yet.
440
@return	newest modification to page */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
441
UNIV_INLINE
442
ib_uint64_t
443
buf_page_get_newest_modification(
444
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
445
	const buf_page_t*	bpage);	/*!< in: block containing the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
446
					page frame */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
447
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
448
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
450
on the block. */
451
UNIV_INLINE
452
void
453
buf_block_modify_clock_inc(
454
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
455
	buf_block_t*	block);	/*!< in: block */
456
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
457
Returns the value of the modify clock. The caller must have an s-lock
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
458
or x-lock on the block.
459
@return	value */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
460
UNIV_INLINE
461
ib_uint64_t
462
buf_block_get_modify_clock(
463
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
464
	buf_block_t*	block);	/*!< in: block */
465
#else /* !UNIV_HOTBACKUP */
466
# define buf_block_modify_clock_inc(block) ((void) 0)
467
#endif /* !UNIV_HOTBACKUP */
468
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
469
Calculates a page checksum which is stored to the page when it is written
470
to a file. Note that we must be careful to calculate the same value
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
471
on 32-bit and 64-bit architectures.
472
@return	checksum */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
473
UNIV_INTERN
474
ulint
475
buf_calc_page_new_checksum(
476
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
477
	const byte*	page);	/*!< in: buffer page */
478
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
479
In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only
480
looked at the first few bytes of the page. This calculates that old
481
checksum.
482
NOTE: we must first store the new formula checksum to
483
FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
484
because this takes that field as an input!
485
@return	checksum */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
486
UNIV_INTERN
487
ulint
488
buf_calc_page_old_checksum(
489
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
490
	const byte*	 page);	/*!< in: buffer page */
491
/********************************************************************//**
492
Checks if a page is corrupt.
493
@return	TRUE if corrupted */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
494
UNIV_INTERN
495
ibool
496
buf_page_is_corrupted(
497
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
498
	const byte*	read_buf,	/*!< in: a database page */
499
	ulint		zip_size);	/*!< in: size of compressed page;
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
500
					0 for uncompressed pages */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
501
#ifndef UNIV_HOTBACKUP
502
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
503
Gets the space id, page offset, and byte offset within page of a
504
pointer pointing to a buffer frame containing a file page. */
505
UNIV_INLINE
506
void
507
buf_ptr_get_fsp_addr(
508
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
509
	const void*	ptr,	/*!< in: pointer to a buffer frame */
510
	ulint*		space,	/*!< out: space id */
511
	fil_addr_t*	addr);	/*!< out: page offset and byte offset */
512
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
513
Gets the hash value of a block. This can be used in searches in the
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
514
lock hash table.
515
@return	lock hash value */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
516
UNIV_INLINE
517
ulint
518
buf_block_get_lock_hash_val(
519
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
520
	const buf_block_t*	block)	/*!< in: block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
521
	__attribute__((pure));
522
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
523
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
524
Finds a block in the buffer pool that points to a
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
525
given compressed page.
526
@return	buffer block pointing to the compressed page, or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
527
UNIV_INTERN
528
buf_block_t*
529
buf_pool_contains_zip(
530
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
531
	const void*	data);	/*!< in: pointer to compressed page */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
532
#endif /* UNIV_DEBUG */
533
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
534
/*********************************************************************//**
535
Validates the buffer pool data structure.
536
@return	TRUE */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
537
UNIV_INTERN
538
ibool
539
buf_validate(void);
540
/*==============*/
541
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
542
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
543
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
544
Prints info of the buffer pool data structure. */
545
UNIV_INTERN
546
void
547
buf_print(void);
548
/*============*/
549
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
550
#endif /* !UNIV_HOTBACKUP */
551
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
552
Prints a page to stderr. */
553
UNIV_INTERN
554
void
555
buf_page_print(
556
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
557
	const byte*	read_buf,	/*!< in: a database page */
558
	ulint		zip_size);	/*!< in: compressed page size, or
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
559
					0 for uncompressed pages */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
560
/********************************************************************//**
561
Decompress a block.
562
@return	TRUE if successful */
563
UNIV_INTERN
564
ibool
565
buf_zip_decompress(
566
/*===============*/
567
	buf_block_t*	block,	/*!< in/out: block */
568
	ibool		check);	/*!< in: TRUE=verify the page checksum */
569
#ifndef UNIV_HOTBACKUP
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
570
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
571
/*********************************************************************//**
572
Returns the number of latched pages in the buffer pool.
573
@return	number of latched pages */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
574
UNIV_INTERN
575
ulint
576
buf_get_latched_pages_number(void);
577
/*==============================*/
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
578
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
579
/*********************************************************************//**
580
Returns the number of pending buf pool ios.
581
@return	number of pending I/O operations */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
582
UNIV_INTERN
583
ulint
584
buf_get_n_pending_ios(void);
585
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
586
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
587
Prints info of the buffer i/o. */
588
UNIV_INTERN
589
void
590
buf_print_io(
591
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
592
	FILE*	file);	/*!< in: file where to print */
593
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
594
Returns the ratio in percents of modified pages in the buffer pool /
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
595
database pages in the buffer pool.
596
@return	modified page percentage ratio */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
597
UNIV_INTERN
598
ulint
599
buf_get_modified_ratio_pct(void);
600
/*============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
601
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
602
Refreshes the statistics used to print per-second averages. */
603
UNIV_INTERN
604
void
605
buf_refresh_io_stats(void);
606
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
607
/*********************************************************************//**
608
Asserts that all file pages in the buffer are in a replaceable state.
609
@return	TRUE */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
610
UNIV_INTERN
611
ibool
612
buf_all_freed(void);
613
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
614
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
615
Checks that there currently are no pending i/o-operations for the buffer
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
616
pool.
617
@return	TRUE if there is no pending i/o */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
618
UNIV_INTERN
619
ibool
620
buf_pool_check_no_pending_io(void);
621
/*==============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
622
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
623
Invalidates the file pages in the buffer pool when an archive recovery is
624
completed. All the file pages buffered must be in a replaceable state when
625
this function is called: not latched and not modified. */
626
UNIV_INTERN
627
void
628
buf_pool_invalidate(void);
629
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
630
#endif /* !UNIV_HOTBACKUP */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
631
632
/*========================================================================
633
--------------------------- LOWER LEVEL ROUTINES -------------------------
634
=========================================================================*/
635
636
#ifdef UNIV_SYNC_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
637
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
638
Adds latch level info for the rw-lock protecting the buffer frame. This
639
should be called in the debug version after a successful latching of a
640
page if we know the latching order level of the acquired latch. */
641
UNIV_INLINE
642
void
643
buf_block_dbg_add_level(
644
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
645
	buf_block_t*	block,	/*!< in: buffer page
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
646
				where we have acquired latch */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
647
	ulint		level);	/*!< in: latching order level */
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
648
#else /* UNIV_SYNC_DEBUG */
649
# define buf_block_dbg_add_level(block, level) /* nothing */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
650
#endif /* UNIV_SYNC_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
651
/*********************************************************************//**
652
Gets the state of a block.
653
@return	state */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
654
UNIV_INLINE
655
enum buf_page_state
656
buf_page_get_state(
657
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
658
	const buf_page_t*	bpage);	/*!< in: pointer to the control block */
659
/*********************************************************************//**
660
Gets the state of a block.
661
@return	state */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
662
UNIV_INLINE
663
enum buf_page_state
664
buf_block_get_state(
665
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
666
	const buf_block_t*	block)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
667
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
668
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
669
Sets the state of a block. */
670
UNIV_INLINE
671
void
672
buf_page_set_state(
673
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
674
	buf_page_t*		bpage,	/*!< in/out: pointer to control block */
675
	enum buf_page_state	state);	/*!< in: state */
676
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
677
Sets the state of a block. */
678
UNIV_INLINE
679
void
680
buf_block_set_state(
681
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
682
	buf_block_t*		block,	/*!< in/out: pointer to control block */
683
	enum buf_page_state	state);	/*!< in: state */
684
/*********************************************************************//**
685
Determines if a block is mapped to a tablespace.
686
@return	TRUE if mapped */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
687
UNIV_INLINE
688
ibool
689
buf_page_in_file(
690
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
691
	const buf_page_t*	bpage)	/*!< in: pointer to control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
692
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
693
#ifndef UNIV_HOTBACKUP
694
/*********************************************************************//**
695
Determines if a block should be on unzip_LRU list.
696
@return	TRUE if block belongs to unzip_LRU */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
697
UNIV_INLINE
698
ibool
699
buf_page_belongs_to_unzip_LRU(
700
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
701
	const buf_page_t*	bpage)	/*!< in: pointer to control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
702
	__attribute__((pure));
703
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
704
/*********************************************************************//**
705
Gets the mutex of a block.
706
@return	pointer to mutex protecting bpage */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
707
UNIV_INLINE
708
mutex_t*
709
buf_page_get_mutex(
710
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
711
	const buf_page_t*	bpage)	/*!< in: pointer to control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
712
	__attribute__((pure));
713
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
714
/*********************************************************************//**
715
Get the flush type of a page.
716
@return	flush type */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
717
UNIV_INLINE
718
enum buf_flush
719
buf_page_get_flush_type(
720
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
721
	const buf_page_t*	bpage)	/*!< in: buffer page */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
722
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
723
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
724
Set the flush type of a page. */
725
UNIV_INLINE
726
void
727
buf_page_set_flush_type(
728
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
729
	buf_page_t*	bpage,		/*!< in: buffer page */
730
	enum buf_flush	flush_type);	/*!< in: flush type */
731
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
732
Map a block to a file page. */
733
UNIV_INLINE
734
void
735
buf_block_set_file_page(
736
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
737
	buf_block_t*		block,	/*!< in/out: pointer to control block */
738
	ulint			space,	/*!< in: tablespace id */
739
	ulint			page_no);/*!< in: page number */
740
/*********************************************************************//**
741
Gets the io_fix state of a block.
742
@return	io_fix state */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
743
UNIV_INLINE
744
enum buf_io_fix
745
buf_page_get_io_fix(
746
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
747
	const buf_page_t*	bpage)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
748
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
749
/*********************************************************************//**
750
Gets the io_fix state of a block.
751
@return	io_fix state */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
752
UNIV_INLINE
753
enum buf_io_fix
754
buf_block_get_io_fix(
755
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
756
	const buf_block_t*	block)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
757
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
758
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
759
Sets the io_fix state of a block. */
760
UNIV_INLINE
761
void
762
buf_page_set_io_fix(
763
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
764
	buf_page_t*	bpage,	/*!< in/out: control block */
765
	enum buf_io_fix	io_fix);/*!< in: io_fix state */
766
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
767
Sets the io_fix state of a block. */
768
UNIV_INLINE
769
void
770
buf_block_set_io_fix(
771
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
772
	buf_block_t*	block,	/*!< in/out: control block */
773
	enum buf_io_fix	io_fix);/*!< in: io_fix state */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
774
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
775
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
776
Determine if a buffer block can be relocated in memory.  The block
777
can be dirty, but it must not be I/O-fixed or bufferfixed. */
778
UNIV_INLINE
779
ibool
780
buf_page_can_relocate(
781
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
782
	const buf_page_t*	bpage)	/*!< control block being relocated */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
783
	__attribute__((pure));
784
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
785
/*********************************************************************//**
786
Determine if a block has been flagged old.
787
@return	TRUE if old */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
788
UNIV_INLINE
789
ibool
790
buf_page_is_old(
791
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
792
	const buf_page_t*	bpage)	/*!< in: control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
793
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
794
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
795
Flag a block old. */
796
UNIV_INLINE
797
void
798
buf_page_set_old(
799
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
800
	buf_page_t*	bpage,	/*!< in/out: control block */
801
	ibool		old);	/*!< in: old */
802
/*********************************************************************//**
1819.5.40 by stewart at flamingspork
[patch 040/129] Merge patch for revision 1828 from InnoDB SVN:
803
Determine the time of first access of a block in the buffer pool.
804
@return	ut_time_ms() at the time of first access, 0 if not accessed */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
805
UNIV_INLINE
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
806
unsigned
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
807
buf_page_is_accessed(
808
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
809
	const buf_page_t*	bpage)	/*!< in: control block */
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
810
	__attribute__((nonnull, pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
811
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
812
Flag a block accessed. */
813
UNIV_INLINE
814
void
815
buf_page_set_accessed(
816
/*==================*/
1819.5.45 by stewart at flamingspork
[patch 045/129] Merge patch for revision 1833 from InnoDB SVN:
817
	buf_page_t*	bpage,		/*!< in/out: control block */
818
	ulint		time_ms)	/*!< in: ut_time_ms() */
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
819
	__attribute__((nonnull));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
820
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
821
Gets the buf_block_t handle of a buffered file block if an uncompressed
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
822
page frame exists, or NULL.
823
@return	control block, or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
824
UNIV_INLINE
825
buf_block_t*
826
buf_page_get_block(
827
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
828
	buf_page_t*	bpage)	/*!< in: control block, or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
829
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
830
#endif /* !UNIV_HOTBACKUP */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
831
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
832
/*********************************************************************//**
833
Gets a pointer to the memory frame of a block.
834
@return	pointer to the frame */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
835
UNIV_INLINE
836
buf_frame_t*
837
buf_block_get_frame(
838
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
839
	const buf_block_t*	block)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
840
	__attribute__((pure));
841
#else /* UNIV_DEBUG */
842
# define buf_block_get_frame(block) (block)->frame
843
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
844
/*********************************************************************//**
845
Gets the space id of a block.
846
@return	space id */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
847
UNIV_INLINE
848
ulint
849
buf_page_get_space(
850
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
851
	const buf_page_t*	bpage)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
852
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
853
/*********************************************************************//**
854
Gets the space id of a block.
855
@return	space id */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
856
UNIV_INLINE
857
ulint
858
buf_block_get_space(
859
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
860
	const buf_block_t*	block)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
861
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
862
/*********************************************************************//**
863
Gets the page number of a block.
864
@return	page number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
865
UNIV_INLINE
866
ulint
867
buf_page_get_page_no(
868
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
869
	const buf_page_t*	bpage)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
870
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
871
/*********************************************************************//**
872
Gets the page number of a block.
873
@return	page number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
874
UNIV_INLINE
875
ulint
876
buf_block_get_page_no(
877
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
878
	const buf_block_t*	block)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
879
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
880
/*********************************************************************//**
881
Gets the compressed page size of a block.
882
@return	compressed page size, or 0 */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
883
UNIV_INLINE
884
ulint
885
buf_page_get_zip_size(
886
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
887
	const buf_page_t*	bpage)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
888
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
889
/*********************************************************************//**
890
Gets the compressed page size of a block.
891
@return	compressed page size, or 0 */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
892
UNIV_INLINE
893
ulint
894
buf_block_get_zip_size(
895
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
896
	const buf_block_t*	block)	/*!< in: pointer to the control block */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
897
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
898
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
899
Gets the compressed page descriptor corresponding to an uncompressed page
900
if applicable. */
901
#define buf_block_get_page_zip(block) \
902
	(UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
903
#ifndef UNIV_HOTBACKUP
904
/*******************************************************************//**
905
Gets the block to whose frame the pointer is pointing to.
906
@return	pointer to block, never NULL */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
907
UNIV_INTERN
908
buf_block_t*
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
909
buf_block_align(
910
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
911
	const byte*	ptr);	/*!< in: pointer to a frame */
912
/********************************************************************//**
913
Find out if a pointer belongs to a buf_block_t. It can be a pointer to
914
the buf_block_t itself or a member of it
915
@return	TRUE if ptr belongs to a buf_block_t struct */
916
UNIV_INTERN
917
ibool
918
buf_pointer_is_block_field(
919
/*=======================*/
920
	const void*		ptr);	/*!< in: pointer not
921
					dereferenced */
922
/** Find out if a pointer corresponds to a buf_block_t::mutex.
923
@param m	in: mutex candidate
924
@return		TRUE if m is a buf_block_t::mutex */
925
#define buf_pool_is_block_mutex(m)			\
926
	buf_pointer_is_block_field((const void*)(m))
927
/** Find out if a pointer corresponds to a buf_block_t::lock.
928
@param l	in: rw-lock candidate
929
@return		TRUE if l is a buf_block_t::lock */
930
#define buf_pool_is_block_lock(l)			\
931
	buf_pointer_is_block_field((const void*)(l))
932
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
933
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
934
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
935
Gets the compressed page descriptor corresponding to an uncompressed page
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
936
if applicable.
937
@return	compressed page descriptor, or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
938
UNIV_INLINE
939
const page_zip_des_t*
940
buf_frame_get_page_zip(
941
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
942
	const byte*	ptr);	/*!< in: pointer to the page */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
943
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
944
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
945
Function which inits a page for read to the buffer buf_pool. If the page is
946
(1) already in buf_pool, or
947
(2) if we specify to read only ibuf pages and the page is not an ibuf page, or
948
(3) if the space is deleted or being deleted,
949
then this function does nothing.
950
Sets the io_fix flag to BUF_IO_READ and sets a non-recursive exclusive lock
951
on the buffer frame. The io-handler must take care that the flag is cleared
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
952
and the lock released later.
953
@return	pointer to the block or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
954
UNIV_INTERN
955
buf_page_t*
956
buf_page_init_for_read(
957
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
958
	ulint*		err,	/*!< out: DB_SUCCESS or DB_TABLESPACE_DELETED */
959
	ulint		mode,	/*!< in: BUF_READ_IBUF_PAGES_ONLY, ... */
960
	ulint		space,	/*!< in: space id */
961
	ulint		zip_size,/*!< in: compressed page size, or 0 */
962
	ibool		unzip,	/*!< in: TRUE=request uncompressed page */
963
	ib_int64_t	tablespace_version,/*!< in: prevents reading from a wrong
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
964
				version of the tablespace in case we have done
965
				DISCARD + IMPORT */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
966
	ulint		offset);/*!< in: page number */
967
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
968
Completes an asynchronous read or write request of a file page to or from
969
the buffer pool. */
970
UNIV_INTERN
971
void
972
buf_page_io_complete(
973
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
974
	buf_page_t*	bpage);	/*!< in: pointer to the block in question */
975
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
976
Calculates a folded value of a file page address to use in the page hash
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
977
table.
978
@return	the folded value */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
979
UNIV_INLINE
980
ulint
981
buf_page_address_fold(
982
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
983
	ulint	space,	/*!< in: space id */
984
	ulint	offset)	/*!< in: offset of the page within space */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
985
	__attribute__((const));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
986
/******************************************************************//**
987
Returns the control block of a file page, NULL if not found.
988
@return	block, NULL if not found */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
989
UNIV_INLINE
990
buf_page_t*
991
buf_page_hash_get(
992
/*==============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
993
	ulint	space,	/*!< in: space id */
994
	ulint	offset);/*!< in: offset of the page within space */
995
/******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
996
Returns the control block of a file page, NULL if not found
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
997
or an uncompressed page frame does not exist.
998
@return	block, NULL if not found */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
999
UNIV_INLINE
1000
buf_block_t*
1001
buf_block_hash_get(
1002
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1003
	ulint	space,	/*!< in: space id */
1004
	ulint	offset);/*!< in: offset of the page within space */
1005
/*********************************************************************//**
1006
Gets the current length of the free list of buffer blocks.
1007
@return	length of the free list */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1008
UNIV_INTERN
1009
ulint
1010
buf_get_free_list_len(void);
1011
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1012
#endif /* !UNIV_HOTBACKUP */
1013
1014
1015
/** The common buffer control block structure
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1016
for compressed and uncompressed frames */
1017
1018
struct buf_page_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1019
	/** @name General fields
1020
	None of these bit-fields must be modified without holding
1021
	buf_page_get_mutex() [buf_block_struct::mutex or
1022
	buf_pool_zip_mutex], since they can be stored in the same
1023
	machine word.  Some of these fields are additionally protected
1024
	by buf_pool_mutex. */
1025
	/* @{ */
1026
1027
	unsigned	space:32;	/*!< tablespace id; also protected
1028
					by buf_pool_mutex. */
1029
	unsigned	offset:32;	/*!< page number; also protected
1030
					by buf_pool_mutex. */
1031
1032
	unsigned	state:3;	/*!< state of the control block; also
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1033
					protected by buf_pool_mutex.
1034
					State transitions from
1035
					BUF_BLOCK_READY_FOR_USE to
1036
					BUF_BLOCK_MEMORY need not be
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1037
					protected by buf_page_get_mutex().
1038
					@see enum buf_page_state */
1039
#ifndef UNIV_HOTBACKUP
1040
	unsigned	flush_type:2;	/*!< if this block is currently being
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1041
					flushed to disk, this tells the
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1042
					flush_type.
1043
					@see enum buf_flush */
1044
	unsigned	io_fix:2;	/*!< type of pending I/O operation;
1045
					also protected by buf_pool_mutex
1046
					@see enum buf_io_fix */
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
1047
	unsigned	buf_fix_count:25;/*!< count of how manyfold this block
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1048
					is currently bufferfixed */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1049
	/* @} */
1050
#endif /* !UNIV_HOTBACKUP */
1051
	page_zip_des_t	zip;		/*!< compressed page; zip.data
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1052
					(but not the data it points to) is
1053
					also protected by buf_pool_mutex */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1054
#ifndef UNIV_HOTBACKUP
1055
	buf_page_t*	hash;		/*!< node used in chaining to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1056
					buf_pool->page_hash or
1057
					buf_pool->zip_hash */
1058
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1059
	ibool		in_page_hash;	/*!< TRUE if in buf_pool->page_hash */
1060
	ibool		in_zip_hash;	/*!< TRUE if in buf_pool->zip_hash */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1061
#endif /* UNIV_DEBUG */
1062
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1063
	/** @name Page flushing fields
1064
	All these are protected by buf_pool_mutex. */
1065
	/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1066
1067
	UT_LIST_NODE_T(buf_page_t) list;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1068
					/*!< based on state, this is a
1069
					list node, protected only by
1070
					buf_pool_mutex, in one of the
1071
					following lists in buf_pool:
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1072
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1073
					- BUF_BLOCK_NOT_USED:	free
1074
					- BUF_BLOCK_FILE_PAGE:	flush_list
1075
					- BUF_BLOCK_ZIP_DIRTY:	flush_list
1076
					- BUF_BLOCK_ZIP_PAGE:	zip_clean
1819.5.10 by stewart at flamingspork
[patch 010/129] Merge patch for revision 1795 from InnoDB SVN:
1077
					- BUF_BLOCK_ZIP_FREE:	zip_free[]
1078
1079
					The contents of the list node
1080
					is undefined if !in_flush_list
1081
					&& state == BUF_BLOCK_FILE_PAGE,
1082
					or if state is one of
1083
					BUF_BLOCK_MEMORY,
1084
					BUF_BLOCK_REMOVE_HASH or
1085
					BUF_BLOCK_READY_IN_USE. */
1086
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1087
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1088
	ibool		in_flush_list;	/*!< TRUE if in buf_pool->flush_list;
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1089
					when buf_pool_mutex is free, the
1090
					following should hold: in_flush_list
1091
					== (state == BUF_BLOCK_FILE_PAGE
1092
					    || state == BUF_BLOCK_ZIP_DIRTY) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1093
	ibool		in_free_list;	/*!< TRUE if in buf_pool->free; when
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1094
					buf_pool_mutex is free, the following
1095
					should hold: in_free_list
1096
					== (state == BUF_BLOCK_NOT_USED) */
1097
#endif /* UNIV_DEBUG */
1098
	ib_uint64_t	newest_modification;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1099
					/*!< log sequence number of
1100
					the youngest modification to
1101
					this block, zero if not
1102
					modified */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1103
	ib_uint64_t	oldest_modification;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1104
					/*!< log sequence number of
1105
					the START of the log entry
1106
					written of the oldest
1107
					modification to this block
1108
					which has not yet been flushed
1109
					on disk; zero if all
1110
					modifications are on disk */
1111
	/* @} */
1112
	/** @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). */
1115
	/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1116
1117
	UT_LIST_NODE_T(buf_page_t) LRU;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1118
					/*!< node of the LRU list */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1119
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1120
	ibool		in_LRU_list;	/*!< TRUE if the page is in
1121
					the LRU list; used in
1122
					debugging */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1123
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1124
	unsigned	old:1;		/*!< TRUE if the block is in the old
1819.5.102 by stewart at flamingspork
[patch 102/129] Merge patch for revision 1908 from InnoDB SVN:
1125
					blocks in buf_pool->LRU_old */
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
1126
	unsigned	freed_page_clock:31;/*!< the value of
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1127
					buf_pool->freed_page_clock
1128
					when this block was the last
1129
					time put to the head of the
1130
					LRU list; a thread is allowed
1131
					to read this for heuristic
1132
					purposes without holding any
1133
					mutex or latch */
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
1134
	unsigned	access_time:32;	/*!< time of first access, or
1135
					0 if the block was never accessed
1136
					in the buffer pool */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1137
	/* @} */
1138
# ifdef UNIV_DEBUG_FILE_ACCESSES
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1139
	ibool		file_page_was_freed;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1140
					/*!< this is set to TRUE when fsp
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1141
					frees a page in buffer pool */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1142
# endif /* UNIV_DEBUG_FILE_ACCESSES */
1143
#endif /* !UNIV_HOTBACKUP */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1144
};
1145
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1146
/** The buffer control block structure */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1147
1148
struct buf_block_struct{
1149
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1150
	/** @name General fields */
1151
	/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1152
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1153
	buf_page_t	page;		/*!< page information; this must
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1154
					be the first field, so that
1155
					buf_pool->page_hash can point
1156
					to buf_page_t or buf_block_t */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1157
	byte*		frame;		/*!< pointer to buffer frame which
1158
					is of size UNIV_PAGE_SIZE, and
1159
					aligned to an address divisible by
1160
					UNIV_PAGE_SIZE */
1161
#ifndef UNIV_HOTBACKUP
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1162
	UT_LIST_NODE_T(buf_block_t) unzip_LRU;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1163
					/*!< node of the decompressed LRU list;
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1164
					a block is in the unzip_LRU list
1165
					if page.state == BUF_BLOCK_FILE_PAGE
1166
					and page.zip.data != NULL */
1167
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1168
	ibool		in_unzip_LRU_list;/*!< TRUE if the page is in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1169
					decompressed LRU list;
1170
					used in debugging */
1171
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1172
	mutex_t		mutex;		/*!< mutex protecting this block:
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1173
					state (also protected by the buffer
1174
					pool mutex), io_fix, buf_fix_count,
1175
					and accessed; we introduce this new
1176
					mutex in InnoDB-5.1 to relieve
1177
					contention on the buffer pool mutex */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1178
	rw_lock_t	lock;		/*!< read-write lock of the buffer
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1179
					frame */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1180
	unsigned	lock_hash_val:32;/*!< hashed value of the page address
1819.5.240 by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6798 from MySQL InnoDB
1181
					in the record lock hash table;
1182
					protected by buf_block_t::lock
1183
					(or buf_block_t::mutex, buf_pool_mutex
1184
				        in buf_page_get_gen(),
1185
					buf_page_init_for_read()
1186
					and buf_page_create()) */
1187
	ibool		check_index_page_at_flush;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1188
					/*!< TRUE if we know that this is
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1189
					an index page, and want the database
1190
					to check its consistency before flush;
1191
					note that there may be pages in the
1192
					buffer pool which are index pages,
1193
					but this flag is not set because
1819.5.240 by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6798 from MySQL InnoDB
1194
					we do not keep track of all pages;
1195
					NOT protected by any mutex */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1196
	/* @} */
1197
	/** @name Optimistic search field */
1198
	/* @{ */
1199
1200
	ib_uint64_t	modify_clock;	/*!< this clock is incremented every
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1201
					time a pointer to a record on the
1202
					page may become obsolete; this is
1203
					used in the optimistic cursor
1204
					positioning: if the modify clock has
1205
					not changed, we know that the pointer
1206
					is still valid; this field may be
1207
					changed if the thread (1) owns the
1208
					pool mutex and the page is not
1209
					bufferfixed, or (2) the thread has an
1210
					x-latch on the block */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1211
	/* @} */
1212
	/** @name Hash search fields (unprotected)
1213
	NOTE that these fields are NOT protected by any semaphore! */
1214
	/* @{ */
1215
1216
	ulint		n_hash_helps;	/*!< counter which controls building
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1217
					of a new hash index for the page */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1218
	ulint		n_fields;	/*!< recommended prefix length for hash
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1219
					search: number of full fields */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1220
	ulint		n_bytes;	/*!< recommended prefix: number of bytes
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1221
					in an incomplete field */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1222
	ibool		left_side;	/*!< TRUE or FALSE, depending on
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1223
					whether the leftmost record of several
1224
					records with the same prefix should be
1225
					indexed in the hash index */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1226
	/* @} */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1227
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1228
	/** @name Hash search fields
1229
	These 6 fields may only be modified when we have
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1230
	an x-latch on btr_search_latch AND
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1231
	- we are holding an s-latch or x-latch on buf_block_struct::lock or
1232
	- we know that buf_block_struct::buf_fix_count == 0.
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1233
1234
	An exception to this is when we init or create a page
1235
	in the buffer pool in buf0buf.c. */
1236
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1237
	/* @{ */
1238
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1239
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1240
	ulint		n_pointers;	/*!< used in debugging: the number of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1241
					pointers in the adaptive hash index
1242
					pointing to this frame */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1243
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1244
	unsigned	is_hashed:1;	/*!< TRUE if hash index has
1245
					already been built on this
1246
					page; note that it does not
1247
					guarantee that the index is
1248
					complete, though: there may
1249
					have been hash collisions,
1250
					record deletions, etc. */
1251
	unsigned	curr_n_fields:10;/*!< prefix length for hash indexing:
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1252
					number of full fields */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1253
	unsigned	curr_n_bytes:15;/*!< number of bytes in hash
1254
					indexing */
1255
	unsigned	curr_left_side:1;/*!< TRUE or FALSE in hash indexing */
1256
	dict_index_t*	index;		/*!< Index for which the adaptive
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1257
					hash index has been created. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1258
	/* @} */
1259
# ifdef UNIV_SYNC_DEBUG
1260
	/** @name Debug fields */
1261
	/* @{ */
1262
	rw_lock_t	debug_latch;	/*!< in the debug version, each thread
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1263
					which bufferfixes the block acquires
1264
					an s-latch here; so we can use the
1265
					debug utilities in sync0rw */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1266
	/* @} */
1267
# endif
1268
#endif /* !UNIV_HOTBACKUP */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1269
};
1270
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1271
/** Check if a buf_block_t object is in a valid state
1272
@param block	buffer block
1273
@return		TRUE if valid */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1274
#define buf_block_state_valid(block)				\
1275
(buf_block_get_state(block) >= BUF_BLOCK_NOT_USED		\
1276
 && (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
1277
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1278
#ifndef UNIV_HOTBACKUP
1279
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1280
Compute the hash fold value for blocks in buf_pool->zip_hash. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1281
/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1282
#define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE)
1283
#define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
1284
#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1285
/* @} */
1286
1819.5.19 by stewart at flamingspork
[patch 019/129] Merge patch for revision 1805 from InnoDB SVN:
1287
/** @brief The buffer pool statistics structure. */
1288
struct buf_pool_stat_struct{
1289
	ulint	n_page_gets;	/*!< number of page gets performed;
1290
				also successful searches through
1291
				the adaptive hash index are
1292
				counted as page gets; this field
1293
				is NOT protected by the buffer
1294
				pool mutex */
1295
	ulint	n_pages_read;	/*!< number read operations */
1296
	ulint	n_pages_written;/*!< number write operations */
1297
	ulint	n_pages_created;/*!< number of pages created
1298
				in the pool with no read */
1299
	ulint	n_ra_pages_read;/*!< number of pages read in
1300
				as part of read ahead */
1301
	ulint	n_ra_pages_evicted;/*!< number of read ahead
1302
				pages that are evicted without
1303
				being accessed */
1304
	ulint	n_pages_made_young; /*!< number of pages made young, in
1305
				calls to buf_LRU_make_block_young() */
1306
	ulint	n_pages_not_made_young; /*!< number of pages not made
1307
				young because the first access
1308
				was not long enough ago, in
1309
				buf_page_peek_if_too_old() */
1310
};
1311
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1312
/** @brief The buffer pool structure.
1313
1314
NOTE! The definition appears here only for other modules of this
1315
directory (buf) to see it. Do not use from outside! */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1316
1317
struct buf_pool_struct{
1318
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1319
	/** @name General fields */
1320
	/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1321
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1322
	ulint		n_chunks;	/*!< number of buffer pool chunks */
1323
	buf_chunk_t*	chunks;		/*!< buffer pool chunks */
1324
	ulint		curr_size;	/*!< current pool size in pages */
1325
	hash_table_t*	page_hash;	/*!< hash table of buf_page_t or
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1326
					buf_block_t file pages,
1327
					buf_page_in_file() == TRUE,
1328
					indexed by (space_id, offset) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1329
	hash_table_t*	zip_hash;	/*!< hash table of buf_block_t blocks
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1330
					whose frames are allocated to the
1331
					zip buddy system,
1332
					indexed by block->frame */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1333
	ulint		n_pend_reads;	/*!< number of pending read operations */
1334
	ulint		n_pend_unzip;	/*!< number of pending decompressions */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1335
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
1336
	time_t		last_printout_time;
1337
					/*!< when buf_print_io was last time
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1338
					called */
1819.5.19 by stewart at flamingspork
[patch 019/129] Merge patch for revision 1805 from InnoDB SVN:
1339
	buf_pool_stat_t	stat;		/*!< current statistics */
1340
	buf_pool_stat_t	old_stat;	/*!< old statistics */
1341
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1342
	/* @} */
1819.5.19 by stewart at flamingspork
[patch 019/129] Merge patch for revision 1805 from InnoDB SVN:
1343
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1344
	/** @name Page flushing algorithm fields */
1819.5.19 by stewart at flamingspork
[patch 019/129] Merge patch for revision 1805 from InnoDB SVN:
1345
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1346
	/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1347
1348
	UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1349
					/*!< base node of the modified block
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1350
					list */
1351
	ibool		init_flush[BUF_FLUSH_N_TYPES];
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1352
					/*!< this is TRUE when a flush of the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1353
					given type is being initialized */
1354
	ulint		n_flush[BUF_FLUSH_N_TYPES];
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1355
					/*!< this is the number of pending
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1356
					writes in the given flush type */
1357
	os_event_t	no_flush[BUF_FLUSH_N_TYPES];
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1358
					/*!< this is in the set state
1359
					when there is no flush batch
1360
					of the given type running */
1819.5.251 by jyang
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6860 from MySQL InnoDB
1361
	ib_rbt_t*	flush_rbt;	/* !< a red-black tree is used
1362
					exclusively during recovery to
1363
					speed up insertions in the
1364
					flush_list. This tree contains
1365
					blocks in order of
1366
					oldest_modification LSN and is
1367
					kept in sync with the
1368
					flush_list.
1369
					Each member of the tree MUST
1370
					also be on the flush_list.
1371
					This tree is relevant only in
1372
					recovery and is set to NULL
1373
					once the recovery is over. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1374
	ulint		freed_page_clock;/*!< a sequence number used
1375
					to count the number of buffer
1376
					blocks removed from the end of
1377
					the LRU list; NOTE that this
1378
					counter may wrap around at 4
1379
					billion! A thread is allowed
1380
					to read this for heuristic
1381
					purposes without holding any
1382
					mutex or latch */
1383
	ulint		LRU_flush_ended;/*!< when an LRU flush ends for a page,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1384
					this is incremented by one; this is
1385
					set to zero when a buffer block is
1386
					allocated */
1387
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1388
	/* @} */
1389
	/** @name LRU replacement algorithm fields */
1390
	/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1391
1392
	UT_LIST_BASE_NODE_T(buf_page_t) free;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1393
					/*!< base node of the free
1394
					block list */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1395
	UT_LIST_BASE_NODE_T(buf_page_t) LRU;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1396
					/*!< base node of the LRU list */
1819.5.16 by stewart at flamingspork
[patch 016/129] Merge patch for revision 1802 from InnoDB SVN:
1397
	buf_page_t*	LRU_old;	/*!< pointer to the about
1398
					buf_LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV
1399
					oldest blocks in the LRU list;
1400
					NULL if LRU length less than
1401
					BUF_LRU_OLD_MIN_LEN;
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
1402
					NOTE: when LRU_old != NULL, its length
1403
					should always equal LRU_old_len */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1404
	ulint		LRU_old_len;	/*!< length of the LRU list from
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1405
					the block to which LRU_old points
1406
					onward, including that block;
1407
					see buf0lru.c for the restrictions
1819.5.102 by stewart at flamingspork
[patch 102/129] Merge patch for revision 1908 from InnoDB SVN:
1408
					on this value; 0 if LRU_old == NULL;
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
1409
					NOTE: LRU_old_len must be adjusted
1410
					whenever LRU_old shrinks or grows! */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1411
1412
	UT_LIST_BASE_NODE_T(buf_block_t) unzip_LRU;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1413
					/*!< base node of the
1414
					unzip_LRU list */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1415
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1416
	/* @} */
1417
	/** @name Buddy allocator fields
1418
	The buddy allocator is used for allocating compressed page
1419
	frames and buf_page_t descriptors of blocks that exist
1420
	in the buffer pool only in compressed form. */
1421
	/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1422
	UT_LIST_BASE_NODE_T(buf_page_t)	zip_clean;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1423
					/*!< unmodified compressed pages */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1424
	UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES];
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1425
					/*!< buddy free lists */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1426
#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
1427
# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
1428
#endif
1429
#if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
1430
# error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
1431
#endif
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1432
	/* @} */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1433
};
1434
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1435
/** mutex protecting the buffer pool struct and control blocks, except the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1436
read-write lock in them */
1437
extern mutex_t	buf_pool_mutex;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1438
/** mutex protecting the control blocks of compressed-only pages
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1439
(of type buf_page_t, not buf_block_t) */
1440
extern mutex_t	buf_pool_zip_mutex;
1441
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1442
/** @name Accessors for buf_pool_mutex.
1443
Use these instead of accessing buf_pool_mutex directly. */
1444
/* @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1445
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1446
/** Test if buf_pool_mutex is owned. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1447
#define buf_pool_mutex_own() mutex_own(&buf_pool_mutex)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1448
/** Acquire the buffer pool mutex. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
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)
1453
1454
#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;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1458
/** Forbid the release of the buffer pool mutex. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1459
# define buf_pool_mutex_exit_forbid() do {	\
1460
	ut_ad(buf_pool_mutex_own());		\
1461
	buf_pool_mutex_exit_forbidden++;	\
1462
} while (0)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1463
/** Allow the release of the buffer pool mutex. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
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--;	\
1468
} while (0)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1469
/** Release the buffer pool mutex. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1470
# define buf_pool_mutex_exit() do {		\
1471
	ut_a(!buf_pool_mutex_exit_forbidden);	\
1472
	mutex_exit(&buf_pool_mutex);		\
1473
} while (0)
1474
#else
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1475
/** Forbid the release of the buffer pool mutex. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1476
# define buf_pool_mutex_exit_forbid() ((void) 0)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1477
/** Allow the release of the buffer pool mutex. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1478
# define buf_pool_mutex_exit_allow() ((void) 0)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1479
/** Release the buffer pool mutex. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1480
# define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex)
1481
#endif
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1482
#endif /* !UNIV_HOTBACKUP */
1483
/* @} */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1484
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
1485
/**********************************************************************
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
1486
Let us list the consistency conditions for different control block states.
1487
1488
NOT_USED:	is in free list, not in LRU list, not in flush list, nor
1489
		page hash table
1490
READY_FOR_USE:	is not in free list, LRU list, or flush list, nor page
1491
		hash table
1492
MEMORY:		is not in free list, LRU list, or flush list, nor page
1493
		hash table
1494
FILE_PAGE:	space and offset are defined, is in page hash table
1495
		if io_fix == BUF_IO_WRITE,
1496
			pool: no_flush[flush_type] is in reset state,
1497
			pool: n_flush[flush_type] > 0
1498
1499
		(1) if buf_fix_count == 0, then
1500
			is in LRU list, not in free list
1501
			is in flush list,
1502
				if and only if oldest_modification > 0
1503
			is x-locked,
1504
				if and only if io_fix == BUF_IO_READ
1505
			is s-locked,
1506
				if and only if io_fix == BUF_IO_WRITE
1507
1508
		(2) if buf_fix_count > 0, then
1509
			is not in LRU list, not in free list
1510
			is in flush list,
1511
				if and only if oldest_modification > 0
1512
			if io_fix == BUF_IO_READ,
1513
				is x-locked
1514
			if io_fix == BUF_IO_WRITE,
1515
				is s-locked
1516
1517
State transitions:
1518
1519
NOT_USED => READY_FOR_USE
1520
READY_FOR_USE => MEMORY
1521
READY_FOR_USE => FILE_PAGE
1522
MEMORY => NOT_USED
1523
FILE_PAGE => NOT_USED	NOTE: This transition is allowed if and only if
1524
				(1) buf_fix_count == 0,
1525
				(2) oldest_modification == 0, and
1526
				(3) io_fix == 0.
1527
*/
1528
1529
#ifndef UNIV_NONINL
1530
#include "buf0buf.ic"
1531
#endif
1532
1533
#endif