~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/buf0rea.h

Tags: innodb-plugin-1.0.1
Imported 1.0.1 with clean - with no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
The database buffer read
 
3
 
 
4
(c) 1995 Innobase Oy
 
5
 
 
6
Created 11/5/1995 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef buf0rea_h
 
10
#define buf0rea_h
 
11
 
 
12
#include "univ.i"
 
13
#include "buf0types.h"
 
14
 
 
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
 
20
sensible. */
 
21
UNIV_INTERN
 
22
ulint
 
23
buf_read_page(
 
24
/*==========*/
 
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   zip_size,/* in: compressed page size in bytes, or 0 */
 
29
        ulint   offset);/* in: page number */
 
30
/************************************************************************
 
31
Applies linear read-ahead if in the buf_pool the page is a border page of
 
32
a linear read-ahead area and all the pages in the area have been accessed.
 
33
Does not read any page if the read-ahead mechanism is not activated. Note
 
34
that the the algorithm looks at the 'natural' adjacent successor and
 
35
predecessor of the page, which on the leaf level of a B-tree are the next
 
36
and previous page in the chain of leaves. To know these, the page specified
 
37
in (space, offset) must already be present in the buf_pool. Thus, the
 
38
natural way to use this function is to call it when a page in the buf_pool
 
39
is accessed the first time, calling this function just after it has been
 
40
bufferfixed.
 
41
NOTE 1: as this function looks at the natural predecessor and successor
 
42
fields on the page, what happens, if these are not initialized to any
 
43
sensible value? No problem, before applying read-ahead we check that the
 
44
area to read is within the span of the space, if not, read-ahead is not
 
45
applied. An uninitialized value may result in a useless read operation, but
 
46
only very improbably.
 
47
NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this
 
48
function must be written such that it cannot end up waiting for these
 
49
latches!
 
50
NOTE 3: the calling thread must want access to the page given: this rule is
 
51
set to prevent unintended read-aheads performed by ibuf routines, a situation
 
52
which could result in a deadlock if the OS does not support asynchronous io. */
 
53
UNIV_INTERN
 
54
ulint
 
55
buf_read_ahead_linear(
 
56
/*==================*/
 
57
                        /* out: number of page read requests issued */
 
58
        ulint   space,  /* in: space id */
 
59
        ulint   zip_size,/* in: compressed page size in bytes, or 0 */
 
60
        ulint   offset);/* in: page number of a page; NOTE: the current thread
 
61
                        must want access to this page (see NOTE 3 above) */
 
62
/************************************************************************
 
63
Issues read requests for pages which the ibuf module wants to read in, in
 
64
order to contract the insert buffer tree. Technically, this function is like
 
65
a read-ahead function. */
 
66
UNIV_INTERN
 
67
void
 
68
buf_read_ibuf_merge_pages(
 
69
/*======================*/
 
70
        ibool           sync,           /* in: TRUE if the caller
 
71
                                        wants this function to wait
 
72
                                        for the highest address page
 
73
                                        to get read in, before this
 
74
                                        function returns */
 
75
        const ulint*    space_ids,      /* in: array of space ids */
 
76
        const ib_int64_t* space_versions,/* in: the spaces must have
 
77
                                        this version number
 
78
                                        (timestamp), otherwise we
 
79
                                        discard the read; we use this
 
80
                                        to cancel reads if DISCARD +
 
81
                                        IMPORT may have changed the
 
82
                                        tablespace size */
 
83
        const ulint*    page_nos,       /* in: array of page numbers
 
84
                                        to read, with the highest page
 
85
                                        number the last in the
 
86
                                        array */
 
87
        ulint           n_stored);      /* in: number of elements
 
88
                                        in the arrays */
 
89
/************************************************************************
 
90
Issues read requests for pages which recovery wants to read in. */
 
91
UNIV_INTERN
 
92
void
 
93
buf_read_recv_pages(
 
94
/*================*/
 
95
        ibool           sync,           /* in: TRUE if the caller
 
96
                                        wants this function to wait
 
97
                                        for the highest address page
 
98
                                        to get read in, before this
 
99
                                        function returns */
 
100
        ulint           space,          /* in: space id */
 
101
        ulint           zip_size,       /* in: compressed page size in
 
102
                                        bytes, or 0 */
 
103
        const ulint*    page_nos,       /* in: array of page numbers
 
104
                                        to read, with the highest page
 
105
                                        number the last in the
 
106
                                        array */
 
107
        ulint           n_stored);      /* in: number of page numbers
 
108
                                        in the array */
 
109
 
 
110
/* The size in pages of the area which the read-ahead algorithms read if
 
111
invoked */
 
112
 
 
113
#define BUF_READ_AHEAD_AREA                                     \
 
114
        ut_min(64, ut_2_power_up(buf_pool->curr_size / 32))
 
115
 
 
116
/* Modes used in read-ahead */
 
117
#define BUF_READ_IBUF_PAGES_ONLY        131
 
118
#define BUF_READ_ANY_PAGE               132
 
119
 
 
120
#endif