~drizzle-trunk/drizzle/development

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