~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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
 
 
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   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
 
39
bufferfixed.
 
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
 
45
only very improbably.
 
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
 
48
latches!
 
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. */
 
52
 
 
53
ulint
 
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. */
 
64
 
 
65
void
 
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
 
76
                                tablespace size */
 
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. */
 
82
 
 
83
void
 
84
buf_read_recv_pages(
 
85
/*================*/
 
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 */
 
93
 
 
94
/* The size in pages of the area which the read-ahead algorithms read if
 
95
invoked */
 
96
 
 
97
#define BUF_READ_AHEAD_AREA                                     \
 
98
        ut_min(64, ut_2_power_up(buf_pool->curr_size / 32))
 
99
 
 
100
/* Modes used in read-ahead */
 
101
#define BUF_READ_IBUF_PAGES_ONLY        131
 
102
#define BUF_READ_ANY_PAGE               132
 
103
 
 
104
#endif