641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
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 |
#include "buf0buf.h" |
|
10 |
#include "mtr0mtr.h" |
|
641.1.4
by Monty Taylor
Merged in InnoDB changes. |
11 |
#include "srv0srv.h" |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
12 |
|
13 |
/************************************************************************
|
|
14 |
Inserts a modified block into the flush list in the right sorted position.
|
|
15 |
This function is used by recovery, because there the modifications do not
|
|
16 |
necessarily come in the order of lsn's. */
|
|
17 |
UNIV_INTERN
|
|
18 |
void
|
|
19 |
buf_flush_insert_sorted_into_flush_list( |
|
20 |
/*====================================*/
|
|
21 |
buf_page_t* bpage); /* in: block which is modified */ |
|
22 |
||
23 |
/************************************************************************
|
|
24 |
This function should be called at a mini-transaction commit, if a page was
|
|
25 |
modified in it. Puts the block to the list of modified blocks, if it is not
|
|
26 |
already in it. */
|
|
27 |
UNIV_INLINE
|
|
28 |
void
|
|
29 |
buf_flush_note_modification( |
|
30 |
/*========================*/
|
|
31 |
buf_block_t* block, /* in: block which is modified */ |
|
32 |
mtr_t* mtr) /* in: mtr */ |
|
33 |
{
|
|
34 |
ut_ad(block); |
|
35 |
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); |
|
36 |
ut_ad(block->page.buf_fix_count > 0); |
|
37 |
#ifdef UNIV_SYNC_DEBUG
|
|
38 |
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); |
|
39 |
#endif /* UNIV_SYNC_DEBUG */ |
|
40 |
ut_ad(buf_pool_mutex_own()); |
|
41 |
||
42 |
ut_ad(mtr->start_lsn != 0); |
|
43 |
ut_ad(mtr->modifications); |
|
44 |
ut_ad(block->page.newest_modification <= mtr->end_lsn); |
|
45 |
||
46 |
block->page.newest_modification = mtr->end_lsn; |
|
47 |
||
48 |
if (!block->page.oldest_modification) { |
|
49 |
||
50 |
block->page.oldest_modification = mtr->start_lsn; |
|
51 |
ut_ad(block->page.oldest_modification != 0); |
|
52 |
||
53 |
buf_flush_insert_into_flush_list(&block->page); |
|
54 |
} else { |
|
55 |
ut_ad(block->page.oldest_modification <= mtr->start_lsn); |
|
56 |
}
|
|
57 |
||
58 |
++srv_buf_pool_write_requests; |
|
59 |
}
|
|
60 |
||
61 |
/************************************************************************
|
|
62 |
This function should be called when recovery has modified a buffer page. */
|
|
63 |
UNIV_INLINE
|
|
64 |
void
|
|
65 |
buf_flush_recv_note_modification( |
|
66 |
/*=============================*/
|
|
67 |
buf_block_t* block, /* in: block which is modified */ |
|
68 |
ib_uint64_t start_lsn, /* in: start lsn of the first mtr in a |
|
69 |
set of mtr's */
|
|
70 |
ib_uint64_t end_lsn) /* in: end lsn of the last mtr in the |
|
71 |
set of mtr's */
|
|
72 |
{
|
|
73 |
ut_ad(block); |
|
74 |
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); |
|
75 |
ut_ad(block->page.buf_fix_count > 0); |
|
76 |
#ifdef UNIV_SYNC_DEBUG
|
|
77 |
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); |
|
78 |
#endif /* UNIV_SYNC_DEBUG */ |
|
79 |
||
80 |
buf_pool_mutex_enter(); |
|
81 |
||
82 |
ut_ad(block->page.newest_modification <= end_lsn); |
|
83 |
||
84 |
block->page.newest_modification = end_lsn; |
|
85 |
||
86 |
if (!block->page.oldest_modification) { |
|
87 |
||
88 |
block->page.oldest_modification = start_lsn; |
|
89 |
||
90 |
ut_ad(block->page.oldest_modification != 0); |
|
91 |
||
92 |
buf_flush_insert_sorted_into_flush_list(&block->page); |
|
93 |
} else { |
|
94 |
ut_ad(block->page.oldest_modification <= start_lsn); |
|
95 |
}
|
|
96 |
||
97 |
buf_pool_mutex_exit(); |
|
98 |
}
|