1
/*****************************************************************************
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/buf0flu.ic
21
The database buffer pool flush algorithm
23
Created 11/5/1995 Heikki Tuuri
24
*******************************************************/
26
#ifndef UNIV_HOTBACKUP
31
/********************************************************************//**
32
Inserts a modified block into the flush list. */
35
buf_flush_insert_into_flush_list(
36
/*=============================*/
37
buf_block_t* block); /*!< in/out: block which is modified */
38
/********************************************************************//**
39
Inserts a modified block into the flush list in the right sorted position.
40
This function is used by recovery, because there the modifications do not
41
necessarily come in the order of lsn's. */
44
buf_flush_insert_sorted_into_flush_list(
45
/*====================================*/
46
buf_block_t* block); /*!< in/out: block which is modified */
48
/********************************************************************//**
49
This function should be called at a mini-transaction commit, if a page was
50
modified in it. Puts the block to the list of modified blocks, if it is not
54
buf_flush_note_modification(
55
/*========================*/
56
buf_block_t* block, /*!< in: block which is modified */
57
mtr_t* mtr) /*!< in: mtr */
60
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
61
ut_ad(block->page.buf_fix_count > 0);
62
#ifdef UNIV_SYNC_DEBUG
63
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
64
#endif /* UNIV_SYNC_DEBUG */
65
ut_ad(buf_pool_mutex_own());
67
ut_ad(mtr->start_lsn != 0);
68
ut_ad(mtr->modifications);
69
ut_ad(block->page.newest_modification <= mtr->end_lsn);
71
block->page.newest_modification = mtr->end_lsn;
73
if (!block->page.oldest_modification) {
75
block->page.oldest_modification = mtr->start_lsn;
76
ut_ad(block->page.oldest_modification != 0);
78
buf_flush_insert_into_flush_list(block);
80
ut_ad(block->page.oldest_modification <= mtr->start_lsn);
83
++srv_buf_pool_write_requests;
86
/********************************************************************//**
87
This function should be called when recovery has modified a buffer page. */
90
buf_flush_recv_note_modification(
91
/*=============================*/
92
buf_block_t* block, /*!< in: block which is modified */
93
ib_uint64_t start_lsn, /*!< in: start lsn of the first mtr in a
95
ib_uint64_t end_lsn) /*!< in: end lsn of the last mtr in the
99
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
100
ut_ad(block->page.buf_fix_count > 0);
101
#ifdef UNIV_SYNC_DEBUG
102
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
103
#endif /* UNIV_SYNC_DEBUG */
105
buf_pool_mutex_enter();
107
ut_ad(block->page.newest_modification <= end_lsn);
109
block->page.newest_modification = end_lsn;
111
if (!block->page.oldest_modification) {
113
block->page.oldest_modification = start_lsn;
115
ut_ad(block->page.oldest_modification != 0);
117
buf_flush_insert_sorted_into_flush_list(block);
119
ut_ad(block->page.oldest_modification <= start_lsn);
122
buf_pool_mutex_exit();
124
#endif /* !UNIV_HOTBACKUP */