1
/*****************************************************************************
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
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.
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.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/buf0buf.h
21
The database buffer pool high-level routines
23
Created 11/5/1995 Heikki Tuuri
24
*******************************************************/
31
#include "mtr0types.h"
32
#include "buf0types.h"
33
#include "hash0hash.h"
35
#include "page0types.h"
36
#ifndef UNIV_HOTBACKUP
39
/** @name Modes for buf_page_get_gen */
41
#define BUF_GET 10 /*!< get always */
42
#define BUF_GET_IF_IN_POOL 11 /*!< get if in pool */
43
#define BUF_GET_NO_LATCH 14 /*!< get and bufferfix, but
45
separated this case, because
46
it is error-prone programming
47
not to set a latch, and it
48
should be used with care */
50
/** @name Modes for buf_page_get_known_nowait */
52
#define BUF_MAKE_YOUNG 51 /*!< Move the block to the
53
start of the LRU list if there
54
is a danger that the block
55
would drift out of the buffer
57
#define BUF_KEEP_OLD 52 /*!< Preserve the current LRU
58
position of the block. */
61
extern buf_pool_t* buf_pool; /*!< The buffer pool of the database */
63
extern ibool buf_debug_prints;/*!< If this is set TRUE, the program
64
prints info whenever read or flush
66
#endif /* UNIV_DEBUG */
67
#else /* !UNIV_HOTBACKUP */
68
extern buf_block_t* back_block1; /*!< first block, for --apply-log */
69
extern buf_block_t* back_block2; /*!< second block, for page reorganize */
70
#endif /* !UNIV_HOTBACKUP */
72
/** Magic value to use instead of checksums when they are disabled */
73
#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
75
/** @brief States of a control block
78
The enumeration values must be 0..7. */
80
BUF_BLOCK_ZIP_FREE = 0, /*!< contains a free
82
BUF_BLOCK_ZIP_PAGE, /*!< contains a clean
84
BUF_BLOCK_ZIP_DIRTY, /*!< contains a compressed
86
buf_pool->flush_list */
88
BUF_BLOCK_NOT_USED, /*!< is in the free list;
89
must be after the BUF_BLOCK_ZIP_
90
constants for compressed-only pages
91
@see buf_block_state_valid() */
92
BUF_BLOCK_READY_FOR_USE, /*!< when buf_LRU_get_free_block
93
returns a block, it is in this state */
94
BUF_BLOCK_FILE_PAGE, /*!< contains a buffered file page */
95
BUF_BLOCK_MEMORY, /*!< contains some main memory
97
BUF_BLOCK_REMOVE_HASH /*!< hash index should be removed
98
before putting to the free list */
101
#ifndef UNIV_HOTBACKUP
102
/********************************************************************//**
103
Creates the buffer pool.
104
@return own: buf_pool object, NULL if not enough memory or error */
109
/********************************************************************//**
110
Frees the buffer pool at shutdown. This must not be invoked before
111
freeing all mutexes. */
117
/********************************************************************//**
118
Drops the adaptive hash index. To prevent a livelock, this function
119
is only to be called while holding btr_search_latch and while
120
btr_search_enabled == FALSE. */
123
buf_pool_drop_hash_index(void);
124
/*==========================*/
126
/********************************************************************//**
127
Relocate a buffer control block. Relocates the block on the LRU list
128
and in buf_pool->page_hash. Does not relocate bpage->list.
129
The caller must take care of relocating bpage->list. */
134
buf_page_t* bpage, /*!< in/out: control block being relocated;
135
buf_page_get_state(bpage) must be
136
BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */
137
buf_page_t* dpage) /*!< in/out: destination control block */
138
__attribute__((nonnull));
139
/********************************************************************//**
140
Resizes the buffer pool. */
143
buf_pool_resize(void);
144
/*=================*/
145
/*********************************************************************//**
146
Gets the current size of buffer buf_pool in bytes.
147
@return size in bytes */
150
buf_pool_get_curr_size(void);
151
/*========================*/
152
/********************************************************************//**
153
Gets the smallest oldest_modification lsn for any page in the pool. Returns
154
zero if all modified pages have been flushed to disk.
155
@return oldest modification in pool, zero if none */
158
buf_pool_get_oldest_modification(void);
159
/*==================================*/
160
/********************************************************************//**
161
Allocates a buffer block.
162
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
167
ulint zip_size); /*!< in: compressed page size in bytes,
168
or 0 if uncompressed tablespace */
169
/********************************************************************//**
170
Frees a buffer block which does not contain a file page. */
175
buf_block_t* block); /*!< in, own: block to be freed */
176
#endif /* !UNIV_HOTBACKUP */
177
/*********************************************************************//**
178
Copies contents of a buffer frame to a given buffer.
184
byte* buf, /*!< in: buffer to copy to */
185
const buf_frame_t* frame); /*!< in: buffer frame */
186
#ifndef UNIV_HOTBACKUP
187
/**************************************************************//**
188
NOTE! The following macros should be used instead of buf_page_get_gen,
189
to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed
191
#define buf_page_get(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
192
SP, ZS, OF, LA, NULL,\
193
BUF_GET, __FILE__, __LINE__, MTR)
194
/**************************************************************//**
195
Use these macros to bufferfix a page with no latching. Remember not to
196
read the contents of the page unless you know it is safe. Do not modify
197
the contents of the page! We have separated this case, because it is
198
error-prone programming not to set a latch, and it should be used
200
#define buf_page_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
201
SP, ZS, OF, RW_NO_LATCH, NULL,\
202
BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
203
/**************************************************************//**
204
NOTE! The following macros should be used instead of
205
buf_page_optimistic_get_func, to improve debugging. Only values RW_S_LATCH and
206
RW_X_LATCH are allowed as LA! */
207
#define buf_page_optimistic_get(LA, BL, MC, MTR) \
208
buf_page_optimistic_get_func(LA, BL, MC, __FILE__, __LINE__, MTR)
209
/********************************************************************//**
210
This is the general function used to get optimistic access to a database
212
@return TRUE if success */
215
buf_page_optimistic_get_func(
216
/*=========================*/
217
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
218
buf_block_t* block, /*!< in: guessed block */
219
ib_uint64_t modify_clock,/*!< in: modify clock value if mode is
220
..._GUESS_ON_CLOCK */
221
const char* file, /*!< in: file name */
222
ulint line, /*!< in: line where called */
223
mtr_t* mtr); /*!< in: mini-transaction */
224
/********************************************************************//**
225
This is used to get access to a known database page, when no waiting can be
227
@return TRUE if success */
230
buf_page_get_known_nowait(
231
/*======================*/
232
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
233
buf_block_t* block, /*!< in: the known page */
234
ulint mode, /*!< in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */
235
const char* file, /*!< in: file name */
236
ulint line, /*!< in: line where called */
237
mtr_t* mtr); /*!< in: mini-transaction */
239
/*******************************************************************//**
240
Given a tablespace id and page number tries to get that page. If the
241
page is not in the buffer pool it is not loaded and NULL is returned.
242
Suitable for using when holding the kernel mutex. */
245
buf_page_try_get_func(
246
/*==================*/
247
ulint space_id,/*!< in: tablespace id */
248
ulint page_no,/*!< in: page number */
249
const char* file, /*!< in: file name */
250
ulint line, /*!< in: line where called */
251
mtr_t* mtr); /*!< in: mini-transaction */
253
/** Tries to get a page. If the page is not in the buffer pool it is
254
not loaded. Suitable for using when holding the kernel mutex.
255
@param space_id in: tablespace id
256
@param page_no in: page number
257
@param mtr in: mini-transaction
258
@return the page if in buffer pool, NULL if not */
259
#define buf_page_try_get(space_id, page_no, mtr) \
260
buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
262
/********************************************************************//**
263
Get read access to a compressed page (usually of type
264
FIL_PAGE_TYPE_ZBLOB or FIL_PAGE_TYPE_ZBLOB2).
265
The page must be released with buf_page_release_zip().
266
NOTE: the page is not protected by any latch. Mutual exclusion has to
267
be implemented at a higher level. In other words, all possible
268
accesses to a given page through this function must be protected by
269
the same set of mutexes or latches.
270
@return pointer to the block, or NULL if not compressed */
275
ulint space, /*!< in: space id */
276
ulint zip_size,/*!< in: compressed page size */
277
ulint offset);/*!< in: page number */
278
/********************************************************************//**
279
This is the general function used to get access to a database page.
280
@return pointer to the block or NULL */
285
ulint space, /*!< in: space id */
286
ulint zip_size,/*!< in: compressed page size in bytes
287
or 0 for uncompressed pages */
288
ulint offset, /*!< in: page number */
289
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
290
buf_block_t* guess, /*!< in: guessed block or NULL */
291
ulint mode, /*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
293
const char* file, /*!< in: file name */
294
ulint line, /*!< in: line where called */
295
mtr_t* mtr); /*!< in: mini-transaction */
296
/********************************************************************//**
297
Initializes a page to the buffer buf_pool. The page is usually not read
298
from a file even if it cannot be found in the buffer buf_pool. This is one
299
of the functions which perform to a block a state transition NOT_USED =>
300
FILE_PAGE (the other is buf_page_get_gen).
301
@return pointer to the block, page bufferfixed */
306
ulint space, /*!< in: space id */
307
ulint offset, /*!< in: offset of the page within space in units of
309
ulint zip_size,/*!< in: compressed page size, or 0 */
310
mtr_t* mtr); /*!< in: mini-transaction handle */
311
#else /* !UNIV_HOTBACKUP */
312
/********************************************************************//**
313
Inits a page to the buffer buf_pool, for use in ibbackup --restore. */
316
buf_page_init_for_backup_restore(
317
/*=============================*/
318
ulint space, /*!< in: space id */
319
ulint offset, /*!< in: offset of the page within space
320
in units of a page */
321
ulint zip_size,/*!< in: compressed page size in bytes
322
or 0 for uncompressed pages */
323
buf_block_t* block); /*!< in: block to init */
324
#endif /* !UNIV_HOTBACKUP */
326
#ifndef UNIV_HOTBACKUP
327
/********************************************************************//**
328
Releases a compressed-only page acquired with buf_page_get_zip(). */
331
buf_page_release_zip(
332
/*=================*/
333
buf_page_t* bpage); /*!< in: buffer block */
334
/********************************************************************//**
335
Decrements the bufferfix count of a buffer control block and releases
336
a latch, if specified. */
341
buf_block_t* block, /*!< in: buffer block */
342
ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH,
344
mtr_t* mtr); /*!< in: mtr */
345
/********************************************************************//**
346
Moves a page to the start of the buffer pool LRU list. This high-level
347
function can be used to prevent an important page from from slipping out of
353
buf_page_t* bpage); /*!< in: buffer block of a file page */
354
/********************************************************************//**
355
Returns TRUE if the page can be found in the buffer pool hash table.
357
NOTE that it is possible that the page is not yet read from disk,
360
@return TRUE if found in the page hash table */
365
ulint space, /*!< in: space id */
366
ulint offset);/*!< in: page number */
367
/********************************************************************//**
368
Resets the check_index_page_at_flush field of a page if found in the buffer
372
buf_reset_check_index_page_at_flush(
373
/*================================*/
374
ulint space, /*!< in: space id */
375
ulint offset);/*!< in: page number */
376
#ifdef UNIV_DEBUG_FILE_ACCESSES
377
/********************************************************************//**
378
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
379
This function should be called when we free a file page and want the
380
debug version to check that it is not accessed any more unless
382
@return control block if found in page hash table, otherwise NULL */
385
buf_page_set_file_page_was_freed(
386
/*=============================*/
387
ulint space, /*!< in: space id */
388
ulint offset);/*!< in: page number */
389
/********************************************************************//**
390
Sets file_page_was_freed FALSE if the page is found in the buffer pool.
391
This function should be called when we free a file page and want the
392
debug version to check that it is not accessed any more unless
394
@return control block if found in page hash table, otherwise NULL */
397
buf_page_reset_file_page_was_freed(
398
/*===============================*/
399
ulint space, /*!< in: space id */
400
ulint offset); /*!< in: page number */
401
#endif /* UNIV_DEBUG_FILE_ACCESSES */
402
/********************************************************************//**
403
Reads the freed_page_clock of a buffer block.
404
@return freed_page_clock */
407
buf_page_get_freed_page_clock(
408
/*==========================*/
409
const buf_page_t* bpage) /*!< in: block */
410
__attribute__((pure));
411
/********************************************************************//**
412
Reads the freed_page_clock of a buffer block.
413
@return freed_page_clock */
416
buf_block_get_freed_page_clock(
417
/*===========================*/
418
const buf_block_t* block) /*!< in: block */
419
__attribute__((pure));
421
/********************************************************************//**
422
Recommends a move of a block to the start of the LRU list if there is danger
423
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
425
@return TRUE if should be made younger */
428
buf_page_peek_if_too_old(
429
/*=====================*/
430
const buf_page_t* bpage); /*!< in: block to make younger */
431
/********************************************************************//**
432
Returns the current state of is_hashed of a page. FALSE if the page is
433
not in the pool. NOTE that this operation does not fix the page in the
434
pool if it is found there.
435
@return TRUE if page hash index is built in search system */
438
buf_page_peek_if_search_hashed(
439
/*===========================*/
440
ulint space, /*!< in: space id */
441
ulint offset);/*!< in: page number */
442
/********************************************************************//**
443
Gets the youngest modification log sequence number for a frame.
444
Returns zero if not file page or no modification occurred yet.
445
@return newest modification to page */
448
buf_page_get_newest_modification(
449
/*=============================*/
450
const buf_page_t* bpage); /*!< in: block containing the
452
/********************************************************************//**
453
Increments the modify clock of a frame by 1. The caller must (1) own the
454
buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock
458
buf_block_modify_clock_inc(
459
/*=======================*/
460
buf_block_t* block); /*!< in: block */
461
/********************************************************************//**
462
Returns the value of the modify clock. The caller must have an s-lock
463
or x-lock on the block.
467
buf_block_get_modify_clock(
468
/*=======================*/
469
buf_block_t* block); /*!< in: block */
470
#else /* !UNIV_HOTBACKUP */
471
# define buf_block_modify_clock_inc(block) ((void) 0)
472
#endif /* !UNIV_HOTBACKUP */
473
/********************************************************************//**
474
Calculates a page checksum which is stored to the page when it is written
475
to a file. Note that we must be careful to calculate the same value
476
on 32-bit and 64-bit architectures.
480
buf_calc_page_new_checksum(
481
/*=======================*/
482
const byte* page); /*!< in: buffer page */
483
/********************************************************************//**
484
In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only
485
looked at the first few bytes of the page. This calculates that old
487
NOTE: we must first store the new formula checksum to
488
FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum
489
because this takes that field as an input!
493
buf_calc_page_old_checksum(
494
/*=======================*/
495
const byte* page); /*!< in: buffer page */
496
/********************************************************************//**
497
Checks if a page is corrupt.
498
@return TRUE if corrupted */
501
buf_page_is_corrupted(
502
/*==================*/
503
const byte* read_buf, /*!< in: a database page */
504
ulint zip_size); /*!< in: size of compressed page;
505
0 for uncompressed pages */
506
#ifndef UNIV_HOTBACKUP
507
/**********************************************************************//**
508
Gets the space id, page offset, and byte offset within page of a
509
pointer pointing to a buffer frame containing a file page. */
512
buf_ptr_get_fsp_addr(
513
/*=================*/
514
const void* ptr, /*!< in: pointer to a buffer frame */
515
ulint* space, /*!< out: space id */
516
fil_addr_t* addr); /*!< out: page offset and byte offset */
517
/**********************************************************************//**
518
Gets the hash value of a block. This can be used in searches in the
520
@return lock hash value */
523
buf_block_get_lock_hash_val(
524
/*========================*/
525
const buf_block_t* block) /*!< in: block */
526
__attribute__((pure));
528
/*********************************************************************//**
529
Finds a block in the buffer pool that points to a
530
given compressed page.
531
@return buffer block pointing to the compressed page, or NULL */
534
buf_pool_contains_zip(
535
/*==================*/
536
const void* data); /*!< in: pointer to compressed page */
537
#endif /* UNIV_DEBUG */
538
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
539
/*********************************************************************//**
540
Validates the buffer pool data structure.
546
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
547
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
548
/*********************************************************************//**
549
Prints info of the buffer pool data structure. */
554
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
555
#endif /* !UNIV_HOTBACKUP */
556
/********************************************************************//**
557
Prints a page to stderr. */
562
const byte* read_buf, /*!< in: a database page */
563
ulint zip_size); /*!< in: compressed page size, or
564
0 for uncompressed pages */
565
/********************************************************************//**
567
@return TRUE if successful */
572
buf_block_t* block, /*!< in/out: block */
573
ibool check); /*!< in: TRUE=verify the page checksum */
574
#ifndef UNIV_HOTBACKUP
576
/*********************************************************************//**
577
Returns the number of latched pages in the buffer pool.
578
@return number of latched pages */
581
buf_get_latched_pages_number(void);
582
/*==============================*/
583
#endif /* UNIV_DEBUG */
584
/*********************************************************************//**
585
Returns the number of pending buf pool ios.
586
@return number of pending I/O operations */
589
buf_get_n_pending_ios(void);
590
/*=======================*/
591
/*********************************************************************//**
592
Prints info of the buffer i/o. */
597
FILE* file); /*!< in: file where to print */
598
/*********************************************************************//**
599
Returns the ratio in percents of modified pages in the buffer pool /
600
database pages in the buffer pool.
601
@return modified page percentage ratio */
604
buf_get_modified_ratio_pct(void);
605
/*============================*/
606
/**********************************************************************//**
607
Refreshes the statistics used to print per-second averages. */
610
buf_refresh_io_stats(void);
611
/*======================*/
612
/*********************************************************************//**
613
Asserts that all file pages in the buffer are in a replaceable state.
619
/*********************************************************************//**
620
Checks that there currently are no pending i/o-operations for the buffer
622
@return TRUE if there is no pending i/o */
625
buf_pool_check_no_pending_io(void);
626
/*==============================*/
627
/*********************************************************************//**
628
Invalidates the file pages in the buffer pool when an archive recovery is
629
completed. All the file pages buffered must be in a replaceable state when
630
this function is called: not latched and not modified. */
633
buf_pool_invalidate(void);
634
/*=====================*/
635
#endif /* !UNIV_HOTBACKUP */
637
/*========================================================================
638
--------------------------- LOWER LEVEL ROUTINES -------------------------
639
=========================================================================*/
641
#ifdef UNIV_SYNC_DEBUG
642
/*********************************************************************//**
643
Adds latch level info for the rw-lock protecting the buffer frame. This
644
should be called in the debug version after a successful latching of a
645
page if we know the latching order level of the acquired latch. */
648
buf_block_dbg_add_level(
649
/*====================*/
650
buf_block_t* block, /*!< in: buffer page
651
where we have acquired latch */
652
ulint level); /*!< in: latching order level */
653
#else /* UNIV_SYNC_DEBUG */
654
# define buf_block_dbg_add_level(block, level) /* nothing */
655
#endif /* UNIV_SYNC_DEBUG */
656
/*********************************************************************//**
657
Gets the state of a block.
663
const buf_page_t* bpage); /*!< in: pointer to the control block */
664
/*********************************************************************//**
665
Gets the state of a block.
671
const buf_block_t* block) /*!< in: pointer to the control block */
672
__attribute__((pure));
673
/*********************************************************************//**
674
Sets the state of a block. */
679
buf_page_t* bpage, /*!< in/out: pointer to control block */
680
enum buf_page_state state); /*!< in: state */
681
/*********************************************************************//**
682
Sets the state of a block. */
687
buf_block_t* block, /*!< in/out: pointer to control block */
688
enum buf_page_state state); /*!< in: state */
689
/*********************************************************************//**
690
Determines if a block is mapped to a tablespace.
691
@return TRUE if mapped */
696
const buf_page_t* bpage) /*!< in: pointer to control block */
697
__attribute__((pure));
698
#ifndef UNIV_HOTBACKUP
699
/*********************************************************************//**
700
Determines if a block should be on unzip_LRU list.
701
@return TRUE if block belongs to unzip_LRU */
704
buf_page_belongs_to_unzip_LRU(
705
/*==========================*/
706
const buf_page_t* bpage) /*!< in: pointer to control block */
707
__attribute__((pure));
708
/*********************************************************************//**
709
Determine the approximate LRU list position of a block.
710
@return LRU list position */
713
buf_page_get_LRU_position(
714
/*======================*/
715
const buf_page_t* bpage) /*!< in: control block */
716
__attribute__((pure));
718
/*********************************************************************//**
719
Gets the mutex of a block.
720
@return pointer to mutex protecting bpage */
725
const buf_page_t* bpage) /*!< in: pointer to control block */
726
__attribute__((pure));
728
/*********************************************************************//**
729
Get the flush type of a page.
730
@return flush type */
733
buf_page_get_flush_type(
734
/*====================*/
735
const buf_page_t* bpage) /*!< in: buffer page */
736
__attribute__((pure));
737
/*********************************************************************//**
738
Set the flush type of a page. */
741
buf_page_set_flush_type(
742
/*====================*/
743
buf_page_t* bpage, /*!< in: buffer page */
744
enum buf_flush flush_type); /*!< in: flush type */
745
/*********************************************************************//**
746
Map a block to a file page. */
749
buf_block_set_file_page(
750
/*====================*/
751
buf_block_t* block, /*!< in/out: pointer to control block */
752
ulint space, /*!< in: tablespace id */
753
ulint page_no);/*!< in: page number */
754
/*********************************************************************//**
755
Gets the io_fix state of a block.
756
@return io_fix state */
761
const buf_page_t* bpage) /*!< in: pointer to the control block */
762
__attribute__((pure));
763
/*********************************************************************//**
764
Gets the io_fix state of a block.
765
@return io_fix state */
768
buf_block_get_io_fix(
770
const buf_block_t* block) /*!< in: pointer to the control block */
771
__attribute__((pure));
772
/*********************************************************************//**
773
Sets the io_fix state of a block. */
778
buf_page_t* bpage, /*!< in/out: control block */
779
enum buf_io_fix io_fix);/*!< in: io_fix state */
780
/*********************************************************************//**
781
Sets the io_fix state of a block. */
784
buf_block_set_io_fix(
785
/*=================*/
786
buf_block_t* block, /*!< in/out: control block */
787
enum buf_io_fix io_fix);/*!< in: io_fix state */
789
/********************************************************************//**
790
Determine if a buffer block can be relocated in memory. The block
791
can be dirty, but it must not be I/O-fixed or bufferfixed. */
794
buf_page_can_relocate(
795
/*==================*/
796
const buf_page_t* bpage) /*!< control block being relocated */
797
__attribute__((pure));
799
/*********************************************************************//**
800
Determine if a block has been flagged old.
801
@return TRUE if old */
806
const buf_page_t* bpage) /*!< in: control block */
807
__attribute__((pure));
808
/*********************************************************************//**
814
buf_page_t* bpage, /*!< in/out: control block */
815
ibool old); /*!< in: old */
816
/*********************************************************************//**
817
Determine if a block has been accessed in the buffer pool.
818
@return TRUE if accessed */
821
buf_page_is_accessed(
822
/*=================*/
823
const buf_page_t* bpage) /*!< in: control block */
824
__attribute__((pure));
825
/*********************************************************************//**
826
Flag a block accessed. */
829
buf_page_set_accessed(
830
/*==================*/
831
buf_page_t* bpage, /*!< in/out: control block */
832
ibool accessed); /*!< in: accessed */
833
/*********************************************************************//**
834
Gets the buf_block_t handle of a buffered file block if an uncompressed
835
page frame exists, or NULL.
836
@return control block, or NULL */
841
buf_page_t* bpage) /*!< in: control block, or NULL */
842
__attribute__((pure));
843
#endif /* !UNIV_HOTBACKUP */
845
/*********************************************************************//**
846
Gets a pointer to the memory frame of a block.
847
@return pointer to the frame */
852
const buf_block_t* block) /*!< in: pointer to the control block */
853
__attribute__((pure));
854
#else /* UNIV_DEBUG */
855
# define buf_block_get_frame(block) (block)->frame
856
#endif /* UNIV_DEBUG */
857
/*********************************************************************//**
858
Gets the space id of a block.
864
const buf_page_t* bpage) /*!< in: pointer to the control block */
865
__attribute__((pure));
866
/*********************************************************************//**
867
Gets the space id of a block.
873
const buf_block_t* block) /*!< in: pointer to the control block */
874
__attribute__((pure));
875
/*********************************************************************//**
876
Gets the page number of a block.
877
@return page number */
880
buf_page_get_page_no(
881
/*=================*/
882
const buf_page_t* bpage) /*!< in: pointer to the control block */
883
__attribute__((pure));
884
/*********************************************************************//**
885
Gets the page number of a block.
886
@return page number */
889
buf_block_get_page_no(
890
/*==================*/
891
const buf_block_t* block) /*!< in: pointer to the control block */
892
__attribute__((pure));
893
/*********************************************************************//**
894
Gets the compressed page size of a block.
895
@return compressed page size, or 0 */
898
buf_page_get_zip_size(
899
/*==================*/
900
const buf_page_t* bpage) /*!< in: pointer to the control block */
901
__attribute__((pure));
902
/*********************************************************************//**
903
Gets the compressed page size of a block.
904
@return compressed page size, or 0 */
907
buf_block_get_zip_size(
908
/*===================*/
909
const buf_block_t* block) /*!< in: pointer to the control block */
910
__attribute__((pure));
911
/*********************************************************************//**
912
Gets the compressed page descriptor corresponding to an uncompressed page
914
#define buf_block_get_page_zip(block) \
915
(UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL)
916
#ifndef UNIV_HOTBACKUP
917
/*******************************************************************//**
918
Gets the block to whose frame the pointer is pointing to.
919
@return pointer to block, never NULL */
924
const byte* ptr); /*!< in: pointer to a frame */
925
/********************************************************************//**
926
Find out if a pointer belongs to a buf_block_t. It can be a pointer to
927
the buf_block_t itself or a member of it
928
@return TRUE if ptr belongs to a buf_block_t struct */
931
buf_pointer_is_block_field(
932
/*=======================*/
933
const void* ptr); /*!< in: pointer not
935
/** Find out if a pointer corresponds to a buf_block_t::mutex.
936
@param m in: mutex candidate
937
@return TRUE if m is a buf_block_t::mutex */
938
#define buf_pool_is_block_mutex(m) \
939
buf_pointer_is_block_field((const void*)(m))
940
/** Find out if a pointer corresponds to a buf_block_t::lock.
941
@param l in: rw-lock candidate
942
@return TRUE if l is a buf_block_t::lock */
943
#define buf_pool_is_block_lock(l) \
944
buf_pointer_is_block_field((const void*)(l))
946
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
947
/*********************************************************************//**
948
Gets the compressed page descriptor corresponding to an uncompressed page
950
@return compressed page descriptor, or NULL */
952
const page_zip_des_t*
953
buf_frame_get_page_zip(
954
/*===================*/
955
const byte* ptr); /*!< in: pointer to the page */
956
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
957
/********************************************************************//**
958
Function which inits a page for read to the buffer buf_pool. If the page is
959
(1) already in buf_pool, or
960
(2) if we specify to read only ibuf pages and the page is not an ibuf page, or
961
(3) if the space is deleted or being deleted,
962
then this function does nothing.
963
Sets the io_fix flag to BUF_IO_READ and sets a non-recursive exclusive lock
964
on the buffer frame. The io-handler must take care that the flag is cleared
965
and the lock released later.
966
@return pointer to the block or NULL */
969
buf_page_init_for_read(
970
/*===================*/
971
ulint* err, /*!< out: DB_SUCCESS or DB_TABLESPACE_DELETED */
972
ulint mode, /*!< in: BUF_READ_IBUF_PAGES_ONLY, ... */
973
ulint space, /*!< in: space id */
974
ulint zip_size,/*!< in: compressed page size, or 0 */
975
ibool unzip, /*!< in: TRUE=request uncompressed page */
976
ib_int64_t tablespace_version,/*!< in: prevents reading from a wrong
977
version of the tablespace in case we have done
979
ulint offset);/*!< in: page number */
980
/********************************************************************//**
981
Completes an asynchronous read or write request of a file page to or from
985
buf_page_io_complete(
986
/*=================*/
987
buf_page_t* bpage); /*!< in: pointer to the block in question */
988
/********************************************************************//**
989
Calculates a folded value of a file page address to use in the page hash
991
@return the folded value */
994
buf_page_address_fold(
995
/*==================*/
996
ulint space, /*!< in: space id */
997
ulint offset) /*!< in: offset of the page within space */
998
__attribute__((const));
999
/******************************************************************//**
1000
Returns the control block of a file page, NULL if not found.
1001
@return block, NULL if not found */
1006
ulint space, /*!< in: space id */
1007
ulint offset);/*!< in: offset of the page within space */
1008
/******************************************************************//**
1009
Returns the control block of a file page, NULL if not found
1010
or an uncompressed page frame does not exist.
1011
@return block, NULL if not found */
1016
ulint space, /*!< in: space id */
1017
ulint offset);/*!< in: offset of the page within space */
1018
/*******************************************************************//**
1019
Increments the pool clock by one and returns its new value. Remember that
1020
in the 32 bit version the clock wraps around at 4 billion!
1021
@return new clock value */
1024
buf_pool_clock_tic(void);
1025
/*====================*/
1026
/*********************************************************************//**
1027
Gets the current length of the free list of buffer blocks.
1028
@return length of the free list */
1031
buf_get_free_list_len(void);
1032
/*=======================*/
1033
#endif /* !UNIV_HOTBACKUP */
1036
/** The common buffer control block structure
1037
for compressed and uncompressed frames */
1039
struct buf_page_struct{
1040
/** @name General fields
1041
None of these bit-fields must be modified without holding
1042
buf_page_get_mutex() [buf_block_struct::mutex or
1043
buf_pool_zip_mutex], since they can be stored in the same
1044
machine word. Some of these fields are additionally protected
1045
by buf_pool_mutex. */
1048
unsigned space:32; /*!< tablespace id; also protected
1049
by buf_pool_mutex. */
1050
unsigned offset:32; /*!< page number; also protected
1051
by buf_pool_mutex. */
1053
unsigned state:3; /*!< state of the control block; also
1054
protected by buf_pool_mutex.
1055
State transitions from
1056
BUF_BLOCK_READY_FOR_USE to
1057
BUF_BLOCK_MEMORY need not be
1058
protected by buf_page_get_mutex().
1059
@see enum buf_page_state */
1060
#ifndef UNIV_HOTBACKUP
1061
unsigned flush_type:2; /*!< if this block is currently being
1062
flushed to disk, this tells the
1064
@see enum buf_flush */
1065
unsigned accessed:1; /*!< TRUE if the page has been accessed
1066
while in the buffer pool: read-ahead
1067
may read in pages which have not been
1068
accessed yet; a thread is allowed to
1069
read this for heuristic purposes
1070
without holding any mutex or latch */
1071
unsigned io_fix:2; /*!< type of pending I/O operation;
1072
also protected by buf_pool_mutex
1073
@see enum buf_io_fix */
1074
unsigned buf_fix_count:24;/*!< count of how manyfold this block
1075
is currently bufferfixed */
1077
#endif /* !UNIV_HOTBACKUP */
1078
page_zip_des_t zip; /*!< compressed page; zip.data
1079
(but not the data it points to) is
1080
also protected by buf_pool_mutex */
1081
#ifndef UNIV_HOTBACKUP
1082
buf_page_t* hash; /*!< node used in chaining to
1083
buf_pool->page_hash or
1084
buf_pool->zip_hash */
1086
ibool in_page_hash; /*!< TRUE if in buf_pool->page_hash */
1087
ibool in_zip_hash; /*!< TRUE if in buf_pool->zip_hash */
1088
#endif /* UNIV_DEBUG */
1090
/** @name Page flushing fields
1091
All these are protected by buf_pool_mutex. */
1094
UT_LIST_NODE_T(buf_page_t) list;
1095
/*!< based on state, this is a
1096
list node, protected only by
1097
buf_pool_mutex, in one of the
1098
following lists in buf_pool:
1100
- BUF_BLOCK_NOT_USED: free
1101
- BUF_BLOCK_FILE_PAGE: flush_list
1102
- BUF_BLOCK_ZIP_DIRTY: flush_list
1103
- BUF_BLOCK_ZIP_PAGE: zip_clean
1104
- BUF_BLOCK_ZIP_FREE: zip_free[] */
1106
ibool in_flush_list; /*!< TRUE if in buf_pool->flush_list;
1107
when buf_pool_mutex is free, the
1108
following should hold: in_flush_list
1109
== (state == BUF_BLOCK_FILE_PAGE
1110
|| state == BUF_BLOCK_ZIP_DIRTY) */
1111
ibool in_free_list; /*!< TRUE if in buf_pool->free; when
1112
buf_pool_mutex is free, the following
1113
should hold: in_free_list
1114
== (state == BUF_BLOCK_NOT_USED) */
1115
#endif /* UNIV_DEBUG */
1116
ib_uint64_t newest_modification;
1117
/*!< log sequence number of
1118
the youngest modification to
1119
this block, zero if not
1121
ib_uint64_t oldest_modification;
1122
/*!< log sequence number of
1123
the START of the log entry
1124
written of the oldest
1125
modification to this block
1126
which has not yet been flushed
1127
on disk; zero if all
1128
modifications are on disk */
1130
/** @name LRU replacement algorithm fields
1131
These fields are protected by buf_pool_mutex only (not
1132
buf_pool_zip_mutex or buf_block_struct::mutex). */
1135
UT_LIST_NODE_T(buf_page_t) LRU;
1136
/*!< node of the LRU list */
1138
ibool in_LRU_list; /*!< TRUE if the page is in
1139
the LRU list; used in
1141
#endif /* UNIV_DEBUG */
1142
unsigned old:1; /*!< TRUE if the block is in the old
1143
blocks in the LRU list */
1144
unsigned LRU_position:31;/*!< value which monotonically
1145
decreases (or may stay
1146
constant if old==TRUE) toward
1147
the end of the LRU list, if
1148
buf_pool->ulint_clock has not
1149
wrapped around: NOTE that this
1150
value can only be used in
1151
heuristic algorithms, because
1152
of the possibility of a
1154
unsigned freed_page_clock:32;/*!< the value of
1155
buf_pool->freed_page_clock
1156
when this block was the last
1157
time put to the head of the
1158
LRU list; a thread is allowed
1159
to read this for heuristic
1160
purposes without holding any
1163
# ifdef UNIV_DEBUG_FILE_ACCESSES
1164
ibool file_page_was_freed;
1165
/*!< this is set to TRUE when fsp
1166
frees a page in buffer pool */
1167
# endif /* UNIV_DEBUG_FILE_ACCESSES */
1168
#endif /* !UNIV_HOTBACKUP */
1171
/** The buffer control block structure */
1173
struct buf_block_struct{
1175
/** @name General fields */
1178
buf_page_t page; /*!< page information; this must
1179
be the first field, so that
1180
buf_pool->page_hash can point
1181
to buf_page_t or buf_block_t */
1182
byte* frame; /*!< pointer to buffer frame which
1183
is of size UNIV_PAGE_SIZE, and
1184
aligned to an address divisible by
1186
#ifndef UNIV_HOTBACKUP
1187
UT_LIST_NODE_T(buf_block_t) unzip_LRU;
1188
/*!< node of the decompressed LRU list;
1189
a block is in the unzip_LRU list
1190
if page.state == BUF_BLOCK_FILE_PAGE
1191
and page.zip.data != NULL */
1193
ibool in_unzip_LRU_list;/*!< TRUE if the page is in the
1194
decompressed LRU list;
1195
used in debugging */
1196
#endif /* UNIV_DEBUG */
1197
mutex_t mutex; /*!< mutex protecting this block:
1198
state (also protected by the buffer
1199
pool mutex), io_fix, buf_fix_count,
1200
and accessed; we introduce this new
1201
mutex in InnoDB-5.1 to relieve
1202
contention on the buffer pool mutex */
1203
rw_lock_t lock; /*!< read-write lock of the buffer
1205
unsigned lock_hash_val:32;/*!< hashed value of the page address
1206
in the record lock hash table */
1207
unsigned check_index_page_at_flush:1;
1208
/*!< TRUE if we know that this is
1209
an index page, and want the database
1210
to check its consistency before flush;
1211
note that there may be pages in the
1212
buffer pool which are index pages,
1213
but this flag is not set because
1214
we do not keep track of all pages */
1216
/** @name Optimistic search field */
1219
ib_uint64_t modify_clock; /*!< this clock is incremented every
1220
time a pointer to a record on the
1221
page may become obsolete; this is
1222
used in the optimistic cursor
1223
positioning: if the modify clock has
1224
not changed, we know that the pointer
1225
is still valid; this field may be
1226
changed if the thread (1) owns the
1227
pool mutex and the page is not
1228
bufferfixed, or (2) the thread has an
1229
x-latch on the block */
1231
/** @name Hash search fields (unprotected)
1232
NOTE that these fields are NOT protected by any semaphore! */
1235
ulint n_hash_helps; /*!< counter which controls building
1236
of a new hash index for the page */
1237
ulint n_fields; /*!< recommended prefix length for hash
1238
search: number of full fields */
1239
ulint n_bytes; /*!< recommended prefix: number of bytes
1240
in an incomplete field */
1241
ibool left_side; /*!< TRUE or FALSE, depending on
1242
whether the leftmost record of several
1243
records with the same prefix should be
1244
indexed in the hash index */
1247
/** @name Hash search fields
1248
These 6 fields may only be modified when we have
1249
an x-latch on btr_search_latch AND
1250
- we are holding an s-latch or x-latch on buf_block_struct::lock or
1251
- we know that buf_block_struct::buf_fix_count == 0.
1253
An exception to this is when we init or create a page
1254
in the buffer pool in buf0buf.c. */
1258
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1259
ulint n_pointers; /*!< used in debugging: the number of
1260
pointers in the adaptive hash index
1261
pointing to this frame */
1262
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
1263
unsigned is_hashed:1; /*!< TRUE if hash index has
1264
already been built on this
1265
page; note that it does not
1266
guarantee that the index is
1267
complete, though: there may
1268
have been hash collisions,
1269
record deletions, etc. */
1270
unsigned curr_n_fields:10;/*!< prefix length for hash indexing:
1271
number of full fields */
1272
unsigned curr_n_bytes:15;/*!< number of bytes in hash
1274
unsigned curr_left_side:1;/*!< TRUE or FALSE in hash indexing */
1275
dict_index_t* index; /*!< Index for which the adaptive
1276
hash index has been created. */
1278
# ifdef UNIV_SYNC_DEBUG
1279
/** @name Debug fields */
1281
rw_lock_t debug_latch; /*!< in the debug version, each thread
1282
which bufferfixes the block acquires
1283
an s-latch here; so we can use the
1284
debug utilities in sync0rw */
1287
#endif /* !UNIV_HOTBACKUP */
1290
/** Check if a buf_block_t object is in a valid state
1291
@param block buffer block
1292
@return TRUE if valid */
1293
#define buf_block_state_valid(block) \
1294
(buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
1295
&& (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
1297
#ifndef UNIV_HOTBACKUP
1298
/**********************************************************************//**
1299
Compute the hash fold value for blocks in buf_pool->zip_hash. */
1301
#define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE)
1302
#define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
1303
#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
1306
/** @brief The buffer pool structure.
1308
NOTE! The definition appears here only for other modules of this
1309
directory (buf) to see it. Do not use from outside! */
1311
struct buf_pool_struct{
1313
/** @name General fields */
1316
ulint n_chunks; /*!< number of buffer pool chunks */
1317
buf_chunk_t* chunks; /*!< buffer pool chunks */
1318
ulint curr_size; /*!< current pool size in pages */
1319
hash_table_t* page_hash; /*!< hash table of buf_page_t or
1320
buf_block_t file pages,
1321
buf_page_in_file() == TRUE,
1322
indexed by (space_id, offset) */
1323
hash_table_t* zip_hash; /*!< hash table of buf_block_t blocks
1324
whose frames are allocated to the
1326
indexed by block->frame */
1327
ulint n_pend_reads; /*!< number of pending read operations */
1328
ulint n_pend_unzip; /*!< number of pending decompressions */
1330
time_t last_printout_time; /*!< when buf_print was last time
1332
ulint n_pages_read; /*!< number read operations */
1333
ulint n_pages_written;/*!< number write operations */
1334
ulint n_pages_created;/*!< number of pages created
1335
in the pool with no read */
1336
ulint n_page_gets; /*!< number of page gets performed;
1337
also successful searches through
1338
the adaptive hash index are
1339
counted as page gets; this field
1340
is NOT protected by the buffer
1342
ulint n_page_gets_old;/*!< n_page_gets when buf_print was
1343
last time called: used to calculate
1345
ulint n_pages_read_old;/*!< n_pages_read when buf_print was
1347
ulint n_pages_written_old;/*!< number write operations */
1348
ulint n_pages_created_old;/*!< number of pages created in
1349
the pool with no read */
1351
/** @name Page flushing algorithm fields */
1354
UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
1355
/*!< base node of the modified block
1357
ibool init_flush[BUF_FLUSH_N_TYPES];
1358
/*!< this is TRUE when a flush of the
1359
given type is being initialized */
1360
ulint n_flush[BUF_FLUSH_N_TYPES];
1361
/*!< this is the number of pending
1362
writes in the given flush type */
1363
os_event_t no_flush[BUF_FLUSH_N_TYPES];
1364
/*!< this is in the set state
1365
when there is no flush batch
1366
of the given type running */
1367
ulint ulint_clock; /*!< a sequence number used to count
1368
time. NOTE! This counter wraps
1369
around at 4 billion (if ulint ==
1371
ulint freed_page_clock;/*!< a sequence number used
1372
to count the number of buffer
1373
blocks removed from the end of
1374
the LRU list; NOTE that this
1375
counter may wrap around at 4
1376
billion! A thread is allowed
1377
to read this for heuristic
1378
purposes without holding any
1380
ulint LRU_flush_ended;/*!< when an LRU flush ends for a page,
1381
this is incremented by one; this is
1382
set to zero when a buffer block is
1386
/** @name LRU replacement algorithm fields */
1389
UT_LIST_BASE_NODE_T(buf_page_t) free;
1390
/*!< base node of the free
1392
UT_LIST_BASE_NODE_T(buf_page_t) LRU;
1393
/*!< base node of the LRU list */
1394
buf_page_t* LRU_old; /*!< pointer to the about 3/8 oldest
1395
blocks in the LRU list; NULL if LRU
1396
length less than BUF_LRU_OLD_MIN_LEN;
1397
NOTE: when LRU_old != NULL, its length
1398
should always equal LRU_old_len */
1399
ulint LRU_old_len; /*!< length of the LRU list from
1400
the block to which LRU_old points
1401
onward, including that block;
1402
see buf0lru.c for the restrictions
1403
on this value; not defined if
1405
NOTE: LRU_old_len must be adjusted
1406
whenever LRU_old shrinks or grows! */
1408
UT_LIST_BASE_NODE_T(buf_block_t) unzip_LRU;
1409
/*!< base node of the
1413
/** @name Buddy allocator fields
1414
The buddy allocator is used for allocating compressed page
1415
frames and buf_page_t descriptors of blocks that exist
1416
in the buffer pool only in compressed form. */
1418
UT_LIST_BASE_NODE_T(buf_page_t) zip_clean;
1419
/*!< unmodified compressed pages */
1420
UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES];
1421
/*!< buddy free lists */
1422
#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
1423
# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
1425
#if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
1426
# error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
1431
/** mutex protecting the buffer pool struct and control blocks, except the
1432
read-write lock in them */
1433
extern mutex_t buf_pool_mutex;
1434
/** mutex protecting the control blocks of compressed-only pages
1435
(of type buf_page_t, not buf_block_t) */
1436
extern mutex_t buf_pool_zip_mutex;
1438
/** @name Accessors for buf_pool_mutex.
1439
Use these instead of accessing buf_pool_mutex directly. */
1442
/** Test if buf_pool_mutex is owned. */
1443
#define buf_pool_mutex_own() mutex_own(&buf_pool_mutex)
1444
/** Acquire the buffer pool mutex. */
1445
#define buf_pool_mutex_enter() do { \
1446
ut_ad(!mutex_own(&buf_pool_zip_mutex)); \
1447
mutex_enter(&buf_pool_mutex); \
1450
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1451
/** Flag to forbid the release of the buffer pool mutex.
1452
Protected by buf_pool_mutex. */
1453
extern ulint buf_pool_mutex_exit_forbidden;
1454
/** Forbid the release of the buffer pool mutex. */
1455
# define buf_pool_mutex_exit_forbid() do { \
1456
ut_ad(buf_pool_mutex_own()); \
1457
buf_pool_mutex_exit_forbidden++; \
1459
/** Allow the release of the buffer pool mutex. */
1460
# define buf_pool_mutex_exit_allow() do { \
1461
ut_ad(buf_pool_mutex_own()); \
1462
ut_a(buf_pool_mutex_exit_forbidden); \
1463
buf_pool_mutex_exit_forbidden--; \
1465
/** Release the buffer pool mutex. */
1466
# define buf_pool_mutex_exit() do { \
1467
ut_a(!buf_pool_mutex_exit_forbidden); \
1468
mutex_exit(&buf_pool_mutex); \
1471
/** Forbid the release of the buffer pool mutex. */
1472
# define buf_pool_mutex_exit_forbid() ((void) 0)
1473
/** Allow the release of the buffer pool mutex. */
1474
# define buf_pool_mutex_exit_allow() ((void) 0)
1475
/** Release the buffer pool mutex. */
1476
# define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex)
1478
#endif /* !UNIV_HOTBACKUP */
1481
/**********************************************************************
1482
Let us list the consistency conditions for different control block states.
1484
NOT_USED: is in free list, not in LRU list, not in flush list, nor
1486
READY_FOR_USE: is not in free list, LRU list, or flush list, nor page
1488
MEMORY: is not in free list, LRU list, or flush list, nor page
1490
FILE_PAGE: space and offset are defined, is in page hash table
1491
if io_fix == BUF_IO_WRITE,
1492
pool: no_flush[flush_type] is in reset state,
1493
pool: n_flush[flush_type] > 0
1495
(1) if buf_fix_count == 0, then
1496
is in LRU list, not in free list
1498
if and only if oldest_modification > 0
1500
if and only if io_fix == BUF_IO_READ
1502
if and only if io_fix == BUF_IO_WRITE
1504
(2) if buf_fix_count > 0, then
1505
is not in LRU list, not in free list
1507
if and only if oldest_modification > 0
1508
if io_fix == BUF_IO_READ,
1510
if io_fix == BUF_IO_WRITE,
1515
NOT_USED => READY_FOR_USE
1516
READY_FOR_USE => MEMORY
1517
READY_FOR_USE => FILE_PAGE
1519
FILE_PAGE => NOT_USED NOTE: This transition is allowed if and only if
1520
(1) buf_fix_count == 0,
1521
(2) oldest_modification == 0, and
1526
#include "buf0buf.ic"