00001 /***************************************************************************** 00002 00003 Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it under 00006 the terms of the GNU General Public License as published by the Free Software 00007 Foundation; version 2 of the License. 00008 00009 This program is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License along with 00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 00015 St, Fifth Floor, Boston, MA 02110-1301 USA 00016 00017 *****************************************************************************/ 00018 00019 /**************************************************/ 00026 #pragma once 00027 #ifndef buf0flu_h 00028 #define buf0flu_h 00029 00030 #include "univ.i" 00031 #include "ut0byte.h" 00032 #ifndef UNIV_HOTBACKUP 00033 #include "mtr0types.h" 00034 #include "buf0types.h" 00035 #include "log0log.h" 00036 00037 /********************************************************************/ 00039 UNIV_INTERN 00040 void 00041 buf_flush_remove( 00042 /*=============*/ 00043 buf_page_t* bpage); 00044 /*******************************************************************/ 00048 UNIV_INTERN 00049 void 00050 buf_flush_relocate_on_flush_list( 00051 /*=============================*/ 00052 buf_page_t* bpage, 00053 buf_page_t* dpage); 00054 /********************************************************************/ 00056 UNIV_INTERN 00057 void 00058 buf_flush_write_complete( 00059 /*=====================*/ 00060 buf_page_t* bpage); 00061 /*********************************************************************/ 00065 UNIV_INTERN 00066 void 00067 buf_flush_free_margin( 00068 /*==================*/ 00069 buf_pool_t* buf_pool); 00070 /*********************************************************************/ 00072 UNIV_INTERN 00073 void 00074 buf_flush_free_margins(void); 00075 /*=========================*/ 00076 #endif /* !UNIV_HOTBACKUP */ 00077 /********************************************************************/ 00079 UNIV_INTERN 00080 void 00081 buf_flush_init_for_writing( 00082 /*=======================*/ 00083 byte* page, 00084 void* page_zip_, 00085 ib_uint64_t newest_lsn); 00087 #ifndef UNIV_HOTBACKUP 00088 # if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG 00089 /********************************************************************/ 00095 UNIV_INTERN 00096 ibool 00097 buf_flush_page_try( 00098 /*===============*/ 00099 buf_pool_t* buf_pool, 00100 buf_block_t* block) 00101 __attribute__((nonnull, warn_unused_result)); 00102 # endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ 00103 /*******************************************************************/ 00110 UNIV_INTERN 00111 ulint 00112 buf_flush_LRU( 00113 /*==========*/ 00114 buf_pool_t* buf_pool, 00115 ulint min_n); 00118 /*******************************************************************/ 00124 UNIV_INTERN 00125 ulint 00126 buf_flush_list( 00127 /*============*/ 00128 ulint min_n, 00131 ib_uint64_t lsn_limit); 00136 /******************************************************************/ 00138 UNIV_INTERN 00139 void 00140 buf_flush_wait_batch_end( 00141 /*=====================*/ 00142 buf_pool_t* buf_pool, 00143 enum buf_flush type); 00145 /********************************************************************/ 00149 UNIV_INLINE 00150 void 00151 buf_flush_note_modification( 00152 /*========================*/ 00153 buf_block_t* block, 00154 mtr_t* mtr); 00155 /********************************************************************/ 00157 UNIV_INLINE 00158 void 00159 buf_flush_recv_note_modification( 00160 /*=============================*/ 00161 buf_block_t* block, 00162 ib_uint64_t start_lsn, 00164 ib_uint64_t end_lsn); 00166 /********************************************************************/ 00170 UNIV_INTERN 00171 ibool 00172 buf_flush_ready_for_replace( 00173 /*========================*/ 00174 buf_page_t* bpage); 00186 struct buf_flush_stat_struct 00187 { 00188 ib_uint64_t redo; 00189 ulint n_flushed; 00190 }; 00191 00193 typedef struct buf_flush_stat_struct buf_flush_stat_t; 00194 /********************************************************************* 00195 Update the historical stats that we are collecting for flush rate 00196 heuristics at the end of each interval. */ 00197 UNIV_INTERN 00198 void 00199 buf_flush_stat_update(void); 00200 /*=======================*/ 00201 /********************************************************************* 00202 Determines the fraction of dirty pages that need to be flushed based 00203 on the speed at which we generate redo log. Note that if redo log 00204 is generated at significant rate without a corresponding increase 00205 in the number of dirty pages (for example, an in-memory workload) 00206 it can cause IO bursts of flushing. This function implements heuristics 00207 to avoid this burstiness. 00208 @return number of dirty pages to be flushed / second */ 00209 UNIV_INTERN 00210 ulint 00211 buf_flush_get_desired_flush_rate(void); 00212 /*==================================*/ 00213 00214 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG 00215 /******************************************************************/ 00218 UNIV_INTERN 00219 ibool 00220 buf_flush_validate( 00221 /*===============*/ 00222 buf_pool_t* buf_pool); 00223 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ 00224 00225 /********************************************************************/ 00229 UNIV_INTERN 00230 void 00231 buf_flush_init_flush_rbt(void); 00232 /*==========================*/ 00233 00234 /********************************************************************/ 00236 UNIV_INTERN 00237 void 00238 buf_flush_free_flush_rbt(void); 00239 /*==========================*/ 00240 00245 #define BUF_FLUSH_FREE_BLOCK_MARGIN(b) (5 + BUF_READ_AHEAD_AREA(b)) 00246 00247 #define BUF_FLUSH_EXTRA_MARGIN(b) ((BUF_FLUSH_FREE_BLOCK_MARGIN(b) / 4 \ 00248 + 100) / srv_buf_pool_instances) 00249 #endif /* !UNIV_HOTBACKUP */ 00250 00251 #ifndef UNIV_NONINL 00252 #include "buf0flu.ic" 00253 #endif 00254 00255 #endif