1
/******************************************************
2
The database buffer read
6
Created 11/5/1995 Heikki Tuuri
7
*******************************************************/
13
#include "buf0types.h"
15
/************************************************************************
16
High-level function which reads a page asynchronously from a file to the
17
buffer buf_pool if it is not already there. Sets the io_fix flag and sets
18
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
19
released by the i/o-handler thread. Does a random read-ahead if it seems
25
/* out: number of page read requests issued: this can
26
be > 1 if read-ahead occurred */
27
ulint space, /* in: space id */
28
ulint offset);/* in: page number */
29
/************************************************************************
30
Applies linear read-ahead if in the buf_pool the page is a border page of
31
a linear read-ahead area and all the pages in the area have been accessed.
32
Does not read any page if the read-ahead mechanism is not activated. Note
33
that the the algorithm looks at the 'natural' adjacent successor and
34
predecessor of the page, which on the leaf level of a B-tree are the next
35
and previous page in the chain of leaves. To know these, the page specified
36
in (space, offset) must already be present in the buf_pool. Thus, the
37
natural way to use this function is to call it when a page in the buf_pool
38
is accessed the first time, calling this function just after it has been
40
NOTE 1: as this function looks at the natural predecessor and successor
41
fields on the page, what happens, if these are not initialized to any
42
sensible value? No problem, before applying read-ahead we check that the
43
area to read is within the span of the space, if not, read-ahead is not
44
applied. An uninitialized value may result in a useless read operation, but
46
NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this
47
function must be written such that it cannot end up waiting for these
49
NOTE 3: the calling thread must want access to the page given: this rule is
50
set to prevent unintended read-aheads performed by ibuf routines, a situation
51
which could result in a deadlock if the OS does not support asynchronous io. */
54
buf_read_ahead_linear(
55
/*==================*/
56
/* out: number of page read requests issued */
57
ulint space, /* in: space id */
58
ulint offset);/* in: page number of a page; NOTE: the current thread
59
must want access to this page (see NOTE 3 above) */
60
/************************************************************************
61
Issues read requests for pages which the ibuf module wants to read in, in
62
order to contract the insert buffer tree. Technically, this function is like
63
a read-ahead function. */
66
buf_read_ibuf_merge_pages(
67
/*======================*/
68
ibool sync, /* in: TRUE if the caller wants this function
69
to wait for the highest address page to get
70
read in, before this function returns */
71
ulint* space_ids, /* in: array of space ids */
72
ib_longlong* space_versions,/* in: the spaces must have this version
73
number (timestamp), otherwise we discard the
74
read; we use this to cancel reads if
75
DISCARD + IMPORT may have changed the
77
ulint* page_nos, /* in: array of page numbers to read, with the
78
highest page number the last in the array */
79
ulint n_stored); /* in: number of page numbers in the array */
80
/************************************************************************
81
Issues read requests for pages which recovery wants to read in. */
86
ibool sync, /* in: TRUE if the caller wants this function
87
to wait for the highest address page to get
88
read in, before this function returns */
89
ulint space, /* in: space id */
90
ulint* page_nos, /* in: array of page numbers to read, with the
91
highest page number the last in the array */
92
ulint n_stored); /* in: number of page numbers in the array */
94
/* The size in pages of the area which the read-ahead algorithms read if
97
#define BUF_READ_AHEAD_AREA \
98
ut_min(64, ut_2_power_up(buf_pool->curr_size / 32))
100
/* Modes used in read-ahead */
101
#define BUF_READ_IBUF_PAGES_ONLY 131
102
#define BUF_READ_ANY_PAGE 132