~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/buf0flu.ic

  • Committer: Brian Aker
  • Date: 2009-10-07 16:55:53 UTC
  • mfrom: (1161.2.1 bug444827)
  • Revision ID: brian@gaz-20091007165553-9tnp7liw1k9g6gvc
Merge Padraig

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
4
 
 
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.
8
 
 
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.
12
 
 
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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/buf0flu.ic
21
 
The database buffer pool flush algorithm
22
 
 
23
 
Created 11/5/1995 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef UNIV_HOTBACKUP
27
 
#include "buf0buf.h"
28
 
#include "mtr0mtr.h"
29
 
#include "srv0srv.h"
30
 
 
31
 
/********************************************************************//**
32
 
Inserts a modified block into the flush list. */
33
 
UNIV_INTERN
34
 
void
35
 
buf_flush_insert_into_flush_list(
36
 
/*=============================*/
37
 
        buf_pool_t*     buf_pool,       /*!< buffer pool instance */
38
 
        buf_block_t*    block,          /*!< in/out: block which is modified */
39
 
        ib_uint64_t     lsn);           /*!< in: oldest modification */
40
 
/********************************************************************//**
41
 
Inserts a modified block into the flush list in the right sorted position.
42
 
This function is used by recovery, because there the modifications do not
43
 
necessarily come in the order of lsn's. */
44
 
UNIV_INTERN
45
 
void
46
 
buf_flush_insert_sorted_into_flush_list(
47
 
/*====================================*/
48
 
        buf_pool_t*     buf_pool,       /*!< buffer pool instance */
49
 
        buf_block_t*    block,          /*!< in/out: block which is modified */
50
 
        ib_uint64_t     lsn);           /*!< in: oldest modification */
51
 
 
52
 
/********************************************************************//**
53
 
This function should be called at a mini-transaction commit, if a page was
54
 
modified in it. Puts the block to the list of modified blocks, if it is not
55
 
already in it. */
56
 
UNIV_INLINE
57
 
void
58
 
buf_flush_note_modification(
59
 
/*========================*/
60
 
        buf_block_t*    block,  /*!< in: block which is modified */
61
 
        mtr_t*          mtr)    /*!< in: mtr */
62
 
{
63
 
        buf_pool_t*     buf_pool = buf_pool_from_block(block);
64
 
 
65
 
        ut_ad(block);
66
 
        ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
67
 
        ut_ad(block->page.buf_fix_count > 0);
68
 
#ifdef UNIV_SYNC_DEBUG
69
 
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
70
 
#endif /* UNIV_SYNC_DEBUG */
71
 
 
72
 
        ut_ad(!buf_pool_mutex_own(buf_pool));
73
 
        ut_ad(!buf_flush_list_mutex_own(buf_pool));
74
 
        ut_ad(log_flush_order_mutex_own());
75
 
 
76
 
        ut_ad(mtr->start_lsn != 0);
77
 
        ut_ad(mtr->modifications);
78
 
 
79
 
        mutex_enter(&block->mutex);
80
 
        ut_ad(block->page.newest_modification <= mtr->end_lsn);
81
 
 
82
 
        block->page.newest_modification = mtr->end_lsn;
83
 
 
84
 
        if (!block->page.oldest_modification) {
85
 
                buf_flush_insert_into_flush_list(
86
 
                        buf_pool, block, mtr->start_lsn);
87
 
        } else {
88
 
                ut_ad(block->page.oldest_modification <= mtr->start_lsn);
89
 
        }
90
 
 
91
 
        mutex_exit(&block->mutex);
92
 
 
93
 
        ++srv_buf_pool_write_requests;
94
 
}
95
 
 
96
 
/********************************************************************//**
97
 
This function should be called when recovery has modified a buffer page. */
98
 
UNIV_INLINE
99
 
void
100
 
buf_flush_recv_note_modification(
101
 
/*=============================*/
102
 
        buf_block_t*    block,          /*!< in: block which is modified */
103
 
        ib_uint64_t     start_lsn,      /*!< in: start lsn of the first mtr in a
104
 
                                        set of mtr's */
105
 
        ib_uint64_t     end_lsn)        /*!< in: end lsn of the last mtr in the
106
 
                                        set of mtr's */
107
 
{
108
 
        buf_pool_t*     buf_pool = buf_pool_from_block(block);
109
 
 
110
 
        ut_ad(block);
111
 
        ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
112
 
        ut_ad(block->page.buf_fix_count > 0);
113
 
#ifdef UNIV_SYNC_DEBUG
114
 
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
115
 
#endif /* UNIV_SYNC_DEBUG */
116
 
 
117
 
        ut_ad(!buf_pool_mutex_own(buf_pool));
118
 
        ut_ad(!buf_flush_list_mutex_own(buf_pool));
119
 
        ut_ad(log_flush_order_mutex_own());
120
 
 
121
 
        ut_ad(start_lsn != 0);
122
 
        ut_ad(block->page.newest_modification <= end_lsn);
123
 
 
124
 
        mutex_enter(&block->mutex);
125
 
        block->page.newest_modification = end_lsn;
126
 
 
127
 
        if (!block->page.oldest_modification) {
128
 
                buf_flush_insert_sorted_into_flush_list(
129
 
                        buf_pool, block, start_lsn);
130
 
        } else {
131
 
                ut_ad(block->page.oldest_modification <= start_lsn);
132
 
        }
133
 
 
134
 
        mutex_exit(&block->mutex);
135
 
 
136
 
}
137
 
#endif /* !UNIV_HOTBACKUP */