1
by brian
clean slate |
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 |
Updates the flush system data structures when a write is completed. */
|
|
19 |
||
20 |
void
|
|
21 |
buf_flush_write_complete( |
|
22 |
/*=====================*/
|
|
23 |
buf_block_t* block); /* in: pointer to the block in question */ |
|
24 |
/*************************************************************************
|
|
25 |
Flushes pages from the end of the LRU list if there is too small
|
|
26 |
a margin of replaceable pages there. */
|
|
27 |
||
28 |
void
|
|
29 |
buf_flush_free_margin(void); |
|
30 |
/*=======================*/
|
|
31 |
/************************************************************************
|
|
32 |
Initializes a page for writing to the tablespace. */
|
|
33 |
||
34 |
void
|
|
35 |
buf_flush_init_for_writing( |
|
36 |
/*=======================*/
|
|
37 |
byte* page, /* in: page */ |
|
38 |
dulint newest_lsn, /* in: newest modification lsn to the page */ |
|
39 |
ulint space, /* in: space id */ |
|
40 |
ulint page_no); /* in: page number */ |
|
41 |
/***********************************************************************
|
|
42 |
This utility flushes dirty blocks from the end of the LRU list or flush_list.
|
|
43 |
NOTE 1: in the case of an LRU flush the calling thread may own latches to
|
|
44 |
pages: to avoid deadlocks, this function must be written so that it cannot
|
|
45 |
end up waiting for these latches! NOTE 2: in the case of a flush list flush,
|
|
46 |
the calling thread is not allowed to own any latches on pages! */
|
|
47 |
||
48 |
ulint
|
|
49 |
buf_flush_batch( |
|
50 |
/*============*/
|
|
51 |
/* out: number of blocks for which the write
|
|
52 |
request was queued */
|
|
53 |
ulint flush_type, /* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST; if |
|
54 |
BUF_FLUSH_LIST, then the caller must not own
|
|
55 |
any latches on pages */
|
|
56 |
ulint min_n, /* in: wished minimum mumber of blocks flushed |
|
57 |
(it is not guaranteed that the actual number
|
|
58 |
is that big, though) */
|
|
59 |
dulint lsn_limit); /* in the case BUF_FLUSH_LIST all blocks whose |
|
60 |
oldest_modification is smaller than this
|
|
61 |
should be flushed (if their number does not
|
|
62 |
exceed min_n), otherwise ignored */
|
|
63 |
/**********************************************************************
|
|
64 |
Waits until a flush batch of the given type ends */
|
|
65 |
||
66 |
void
|
|
67 |
buf_flush_wait_batch_end( |
|
68 |
/*=====================*/
|
|
69 |
ulint type); /* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ |
|
70 |
/************************************************************************
|
|
71 |
This function should be called at a mini-transaction commit, if a page was
|
|
72 |
modified in it. Puts the block to the list of modified blocks, if it not
|
|
73 |
already in it. */
|
|
74 |
UNIV_INLINE
|
|
75 |
void
|
|
76 |
buf_flush_note_modification( |
|
77 |
/*========================*/
|
|
78 |
buf_block_t* block, /* in: block which is modified */ |
|
79 |
mtr_t* mtr); /* in: mtr */ |
|
80 |
/************************************************************************
|
|
81 |
This function should be called when recovery has modified a buffer page. */
|
|
82 |
UNIV_INLINE
|
|
83 |
void
|
|
84 |
buf_flush_recv_note_modification( |
|
85 |
/*=============================*/
|
|
86 |
buf_block_t* block, /* in: block which is modified */ |
|
87 |
dulint start_lsn, /* in: start lsn of the first mtr in a |
|
88 |
set of mtr's */
|
|
89 |
dulint end_lsn); /* in: end lsn of the last mtr in the |
|
90 |
set of mtr's */
|
|
91 |
/************************************************************************
|
|
92 |
Returns TRUE if the file page block is immediately suitable for replacement,
|
|
93 |
i.e., transition FILE_PAGE => NOT_USED allowed. */
|
|
94 |
ibool
|
|
95 |
buf_flush_ready_for_replace( |
|
96 |
/*========================*/
|
|
97 |
/* out: TRUE if can replace immediately */
|
|
98 |
buf_block_t* block); /* in: buffer control block, must be in state |
|
99 |
BUF_BLOCK_FILE_PAGE and in the LRU list */
|
|
100 |
/**********************************************************************
|
|
101 |
Validates the flush list. */
|
|
102 |
||
103 |
ibool
|
|
104 |
buf_flush_validate(void); |
|
105 |
/*====================*/
|
|
106 |
/* out: TRUE if ok */
|
|
107 |
||
108 |
/* When buf_flush_free_margin is called, it tries to make this many blocks
|
|
109 |
available to replacement in the free list and at the end of the LRU list (to
|
|
110 |
make sure that a read-ahead batch can be read efficiently in a single
|
|
111 |
sweep). */
|
|
112 |
||
113 |
#define BUF_FLUSH_FREE_BLOCK_MARGIN (5 + BUF_READ_AHEAD_AREA)
|
|
114 |
#define BUF_FLUSH_EXTRA_MARGIN (BUF_FLUSH_FREE_BLOCK_MARGIN / 4 + 100)
|
|
115 |
||
116 |
#ifndef UNIV_NONINL
|
|
117 |
#include "buf0flu.ic" |
|
118 |
#endif
|
|
119 |
||
120 |
#endif
|