641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
3 |
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
|
4 |
||
5 |
This program is free software; you can redistribute it and/or modify it under
|
|
6 |
the terms of the GNU General Public License as published by the Free Software
|
|
7 |
Foundation; version 2 of the License.
|
|
8 |
||
9 |
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
12 |
||
13 |
You should have received a copy of the GNU General Public License along with
|
|
14 |
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
15 |
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file include/buf0rea.h
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
The database buffer read
|
22 |
||
23 |
Created 11/5/1995 Heikki Tuuri
|
|
24 |
*******************************************************/
|
|
25 |
||
26 |
#ifndef buf0rea_h
|
|
27 |
#define buf0rea_h
|
|
28 |
||
29 |
#include "univ.i" |
|
30 |
#include "buf0types.h" |
|
31 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
32 |
/********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
33 |
High-level function which reads a page asynchronously from a file to the
|
34 |
buffer buf_pool if it is not already there. Sets the io_fix flag and sets
|
|
35 |
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
|
|
36 |
released by the i/o-handler thread. Does a random read-ahead if it seems
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
37 |
sensible.
|
38 |
@return number of page read requests issued: this can be greater than
|
|
39 |
1 if read-ahead occurred */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
40 |
UNIV_INTERN
|
41 |
ulint
|
|
42 |
buf_read_page( |
|
43 |
/*==========*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
44 |
ulint space, /*!< in: space id */ |
45 |
ulint zip_size,/*!< in: compressed page size in bytes, or 0 */ |
|
46 |
ulint offset);/*!< in: page number */ |
|
47 |
/********************************************************************//**
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
48 |
Applies linear read-ahead if in the buf_pool the page is a border page of
|
49 |
a linear read-ahead area and all the pages in the area have been accessed.
|
|
50 |
Does not read any page if the read-ahead mechanism is not activated. Note
|
|
51 |
that the the algorithm looks at the 'natural' adjacent successor and
|
|
52 |
predecessor of the page, which on the leaf level of a B-tree are the next
|
|
53 |
and previous page in the chain of leaves. To know these, the page specified
|
|
54 |
in (space, offset) must already be present in the buf_pool. Thus, the
|
|
55 |
natural way to use this function is to call it when a page in the buf_pool
|
|
56 |
is accessed the first time, calling this function just after it has been
|
|
57 |
bufferfixed.
|
|
58 |
NOTE 1: as this function looks at the natural predecessor and successor
|
|
59 |
fields on the page, what happens, if these are not initialized to any
|
|
60 |
sensible value? No problem, before applying read-ahead we check that the
|
|
61 |
area to read is within the span of the space, if not, read-ahead is not
|
|
62 |
applied. An uninitialized value may result in a useless read operation, but
|
|
63 |
only very improbably.
|
|
64 |
NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this
|
|
65 |
function must be written such that it cannot end up waiting for these
|
|
66 |
latches!
|
|
67 |
NOTE 3: the calling thread must want access to the page given: this rule is
|
|
68 |
set to prevent unintended read-aheads performed by ibuf routines, a situation
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
69 |
which could result in a deadlock if the OS does not support asynchronous io.
|
70 |
@return number of page read requests issued */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
71 |
UNIV_INTERN
|
72 |
ulint
|
|
73 |
buf_read_ahead_linear( |
|
74 |
/*==================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
75 |
ulint space, /*!< in: space id */ |
76 |
ulint zip_size,/*!< in: compressed page size in bytes, or 0 */ |
|
77 |
ulint offset);/*!< in: page number of a page; NOTE: the current thread |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
78 |
must want access to this page (see NOTE 3 above) */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
79 |
/********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
80 |
Issues read requests for pages which the ibuf module wants to read in, in
|
81 |
order to contract the insert buffer tree. Technically, this function is like
|
|
82 |
a read-ahead function. */
|
|
83 |
UNIV_INTERN
|
|
84 |
void
|
|
85 |
buf_read_ibuf_merge_pages( |
|
86 |
/*======================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
87 |
ibool sync, /*!< in: TRUE if the caller |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
88 |
wants this function to wait
|
89 |
for the highest address page
|
|
90 |
to get read in, before this
|
|
91 |
function returns */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
92 |
const ulint* space_ids, /*!< in: array of space ids */ |
93 |
const ib_int64_t* space_versions,/*!< in: the spaces must have |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
94 |
this version number
|
95 |
(timestamp), otherwise we
|
|
96 |
discard the read; we use this
|
|
97 |
to cancel reads if DISCARD +
|
|
98 |
IMPORT may have changed the
|
|
99 |
tablespace size */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
100 |
const ulint* page_nos, /*!< in: array of page numbers |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
101 |
to read, with the highest page
|
102 |
number the last in the
|
|
103 |
array */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
104 |
ulint n_stored); /*!< in: number of elements |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
105 |
in the arrays */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
106 |
/********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
107 |
Issues read requests for pages which recovery wants to read in. */
|
108 |
UNIV_INTERN
|
|
109 |
void
|
|
110 |
buf_read_recv_pages( |
|
111 |
/*================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
112 |
ibool sync, /*!< in: TRUE if the caller |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
113 |
wants this function to wait
|
114 |
for the highest address page
|
|
115 |
to get read in, before this
|
|
116 |
function returns */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
117 |
ulint space, /*!< in: space id */ |
118 |
ulint zip_size, /*!< in: compressed page size in |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
119 |
bytes, or 0 */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
120 |
const ulint* page_nos, /*!< in: array of page numbers |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
121 |
to read, with the highest page
|
122 |
number the last in the
|
|
123 |
array */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
124 |
ulint n_stored); /*!< in: number of page numbers |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
125 |
in the array */
|
126 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
127 |
/** The size in pages of the area which the read-ahead algorithms read if
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
128 |
invoked */
|
129 |
#define BUF_READ_AHEAD_AREA \
|
|
130 |
ut_min(64, ut_2_power_up(buf_pool->curr_size / 32))
|
|
131 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
132 |
/** @name Modes used in read-ahead @{ */
|
133 |
/** read only pages belonging to the insert buffer tree */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
134 |
#define BUF_READ_IBUF_PAGES_ONLY 131
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
135 |
/** read any page */
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
136 |
#define BUF_READ_ANY_PAGE 132
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
137 |
/* @} */
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
138 |
|
139 |
#endif
|