~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Lee
  • Date: 2008-10-30 22:02:01 UTC
  • mto: (572.1.2 devel)
  • mto: This revision was merged to the branch mainline in revision 573.
  • Revision ID: lbieber@lbieber-desktop-20081030220201-elb6qprbzpn7c5a4
add my name to the AUTHORS file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
The database buffer pool flush algorithm
 
3
 
 
4
(c) 1995 Innobase Oy
 
5
 
 
6
Created 11/5/1995 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef buf0flu_h
 
10
#define buf0flu_h
 
11
 
 
12
#include "univ.i"
 
13
#include "buf0types.h"
 
14
#include "ut0byte.h"
 
15
#include "mtr0types.h"
 
16
 
 
17
/************************************************************************
 
18
Inserts a modified block into the flush list. */
 
19
UNIV_INTERN
 
20
void
 
21
buf_flush_insert_into_flush_list(
 
22
/*=============================*/
 
23
        buf_page_t*     bpage); /* in: block which is modified */
 
24
/************************************************************************
 
25
Remove a block from the flush list of modified blocks. */
 
26
UNIV_INTERN
 
27
void
 
28
buf_flush_remove(
 
29
/*=============*/
 
30
        buf_page_t*     bpage); /* in: pointer to the block in question */
 
31
/************************************************************************
 
32
Updates the flush system data structures when a write is completed. */
 
33
UNIV_INTERN
 
34
void
 
35
buf_flush_write_complete(
 
36
/*=====================*/
 
37
        buf_page_t*     bpage); /* in: pointer to the block in question */
 
38
/*************************************************************************
 
39
Flushes pages from the end of the LRU list if there is too small
 
40
a margin of replaceable pages there. */
 
41
UNIV_INTERN
 
42
void
 
43
buf_flush_free_margin(void);
 
44
/*=======================*/
 
45
/************************************************************************
 
46
Initializes a page for writing to the tablespace. */
 
47
UNIV_INTERN
 
48
void
 
49
buf_flush_init_for_writing(
 
50
/*=======================*/
 
51
        byte*           page,           /* in/out: page */
 
52
        void*           page_zip_,      /* in/out: compressed page, or NULL */
 
53
        ib_uint64_t     newest_lsn);    /* in: newest modification lsn
 
54
                                        to the page */
 
55
/***********************************************************************
 
56
This utility flushes dirty blocks from the end of the LRU list or flush_list.
 
57
NOTE 1: in the case of an LRU flush the calling thread may own latches to
 
58
pages: to avoid deadlocks, this function must be written so that it cannot
 
59
end up waiting for these latches! NOTE 2: in the case of a flush list flush,
 
60
the calling thread is not allowed to own any latches on pages! */
 
61
UNIV_INTERN
 
62
ulint
 
63
buf_flush_batch(
 
64
/*============*/
 
65
                                        /* out: number of blocks for which the
 
66
                                        write request was queued;
 
67
                                        ULINT_UNDEFINED if there was a flush
 
68
                                        of the same type already running */
 
69
        enum buf_flush  flush_type,     /* in: BUF_FLUSH_LRU or
 
70
                                        BUF_FLUSH_LIST; if BUF_FLUSH_LIST,
 
71
                                        then the caller must not own any
 
72
                                        latches on pages */
 
73
        ulint           min_n,          /* in: wished minimum mumber of blocks
 
74
                                        flushed (it is not guaranteed that the
 
75
                                        actual number is that big, though) */
 
76
        ib_uint64_t     lsn_limit);     /* in the case BUF_FLUSH_LIST all
 
77
                                        blocks whose oldest_modification is
 
78
                                        smaller than this should be flushed
 
79
                                        (if their number does not exceed
 
80
                                        min_n), otherwise ignored */
 
81
/**********************************************************************
 
82
Waits until a flush batch of the given type ends */
 
83
UNIV_INTERN
 
84
void
 
85
buf_flush_wait_batch_end(
 
86
/*=====================*/
 
87
        enum buf_flush  type);  /* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
 
88
/************************************************************************
 
89
This function should be called at a mini-transaction commit, if a page was
 
90
modified in it. Puts the block to the list of modified blocks, if it not
 
91
already in it. */
 
92
UNIV_INLINE
 
93
void
 
94
buf_flush_note_modification(
 
95
/*========================*/
 
96
        buf_block_t*    block,  /* in: block which is modified */
 
97
        mtr_t*          mtr);   /* in: mtr */
 
98
/************************************************************************
 
99
This function should be called when recovery has modified a buffer page. */
 
100
UNIV_INLINE
 
101
void
 
102
buf_flush_recv_note_modification(
 
103
/*=============================*/
 
104
        buf_block_t*    block,          /* in: block which is modified */
 
105
        ib_uint64_t     start_lsn,      /* in: start lsn of the first mtr in a
 
106
                                        set of mtr's */
 
107
        ib_uint64_t     end_lsn);       /* in: end lsn of the last mtr in the
 
108
                                        set of mtr's */
 
109
/************************************************************************
 
110
Returns TRUE if the file page block is immediately suitable for replacement,
 
111
i.e., transition FILE_PAGE => NOT_USED allowed. */
 
112
UNIV_INTERN
 
113
ibool
 
114
buf_flush_ready_for_replace(
 
115
/*========================*/
 
116
                                /* out: TRUE if can replace immediately */
 
117
        buf_page_t*     bpage); /* in: buffer control block, must be
 
118
                                buf_page_in_file(bpage) and in the LRU list */
 
119
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 
120
/**********************************************************************
 
121
Validates the flush list. */
 
122
UNIV_INTERN
 
123
ibool
 
124
buf_flush_validate(void);
 
125
/*====================*/
 
126
                /* out: TRUE if ok */
 
127
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
 
128
 
 
129
/* When buf_flush_free_margin is called, it tries to make this many blocks
 
130
available to replacement in the free list and at the end of the LRU list (to
 
131
make sure that a read-ahead batch can be read efficiently in a single
 
132
sweep). */
 
133
 
 
134
#define BUF_FLUSH_FREE_BLOCK_MARGIN     (5 + BUF_READ_AHEAD_AREA)
 
135
#define BUF_FLUSH_EXTRA_MARGIN          (BUF_FLUSH_FREE_BLOCK_MARGIN / 4 + 100)
 
136
 
 
137
#ifndef UNIV_NONINL
 
138
#include "buf0flu.ic"
 
139
#endif
 
140
 
 
141
#endif