The world's most popular open source database
#include "buf0buf.h"#include "mem0mem.h"#include "btr0btr.h"#include "fil0fil.h"#include "lock0lock.h"#include "btr0sea.h"#include "ibuf0ibuf.h"#include "dict0dict.h"#include "log0recv.h"#include "log0log.h"#include "trx0undo.h"#include "srv0srv.h"Include dependency graph for buf0buf.c:

Go to the source code of this file.
| ibool buf_all_freed | ( | void | ) |
Definition at line 2398 of file buf0buf.c.
References yaSSL::block, BUF_BLOCK_FILE_PAGE, buf_flush_ready_for_replace(), buf_pool, buf_pool_get_nth_block(), buf_pool_struct::curr_size, buf_pool_struct::mutex, mutex_enter, ut_ad, and ut_error.
Referenced by buf_pool_invalidate(), and logs_empty_and_mark_files_at_shutdown().
02400 { 02401 buf_block_t* block; 02402 ulint i; 02403 02404 ut_ad(buf_pool); 02405 02406 mutex_enter(&(buf_pool->mutex)); 02407 02408 for (i = 0; i < buf_pool->curr_size; i++) { 02409 02410 block = buf_pool_get_nth_block(buf_pool, i); 02411 02412 if (block->state == BUF_BLOCK_FILE_PAGE) { 02413 02414 if (!buf_flush_ready_for_replace(block)) { 02415 02416 fprintf(stderr, 02417 "Page %lu %lu still fixed or dirty\n", 02418 (ulong) block->space, (ulong) block->offset); 02419 ut_error; 02420 } 02421 } 02422 } 02423 02424 mutex_exit(&(buf_pool->mutex)); 02425 02426 return(TRUE); 02427 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_awe_map_page_to_frame | ( | buf_block_t * | block, | |
| ibool | add_to_mapped_list | |||
| ) |
Definition at line 766 of file buf0buf.c.
References yaSSL::block, buf_pool_struct::blocks_of_frames, BUF_BLOCK_FILE_PAGE, buf_block_struct::buf_fix_count, buf_pool, buf_block_struct::frame, buf_pool_struct::frame_zero, buf_block_struct::io_fix, buf_pool_struct::mutex, buf_pool_struct::n_pages_awe_remapped, NULL, os_awe_map_physical_mem_to_window(), OS_AWE_X86_PAGE_SIZE, buf_block_struct::state, UNIV_PAGE_SIZE, ut_a, ut_ad, UT_LIST_ADD_FIRST, UT_LIST_GET_LAST, UT_LIST_GET_LEN, UT_LIST_GET_PREV, and UT_LIST_REMOVE.
Referenced by buf_flush_try_page(), buf_LRU_get_free_block(), and buf_page_get_gen().
00768 : block whose page should be 00769 mapped to a frame */ 00770 ibool add_to_mapped_list) /* in: TRUE if we in the case 00771 we need to map the page should also 00772 add the block to the 00773 awe_LRU_free_mapped list */ 00774 { 00775 buf_block_t* bck; 00776 00777 #ifdef UNIV_SYNC_DEBUG 00778 ut_ad(mutex_own(&(buf_pool->mutex))); 00779 #endif /* UNIV_SYNC_DEBUG */ 00780 ut_ad(block); 00781 00782 if (block->frame) { 00783 00784 return; 00785 } 00786 00787 /* Scan awe_LRU_free_mapped from the end and try to find a block 00788 which is not bufferfixed or io-fixed */ 00789 00790 bck = UT_LIST_GET_LAST(buf_pool->awe_LRU_free_mapped); 00791 00792 while (bck) { 00793 if (bck->state == BUF_BLOCK_FILE_PAGE 00794 && (bck->buf_fix_count != 0 || bck->io_fix != 0)) { 00795 00796 /* We have to skip this */ 00797 bck = UT_LIST_GET_PREV(awe_LRU_free_mapped, bck); 00798 } else { 00799 /* We can map block to the frame of bck */ 00800 00801 os_awe_map_physical_mem_to_window( 00802 bck->frame, 00803 UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE, 00804 block->awe_info); 00805 00806 block->frame = bck->frame; 00807 00808 *(buf_pool->blocks_of_frames 00809 + (((ulint)(block->frame 00810 - buf_pool->frame_zero)) 00811 >> UNIV_PAGE_SIZE_SHIFT)) 00812 = block; 00813 00814 bck->frame = NULL; 00815 UT_LIST_REMOVE(awe_LRU_free_mapped, 00816 buf_pool->awe_LRU_free_mapped, 00817 bck); 00818 00819 if (add_to_mapped_list) { 00820 UT_LIST_ADD_FIRST(awe_LRU_free_mapped, 00821 buf_pool->awe_LRU_free_mapped, 00822 block); 00823 } 00824 00825 buf_pool->n_pages_awe_remapped++; 00826 00827 return; 00828 } 00829 } 00830 00831 fprintf(stderr, 00832 "InnoDB: AWE: Fatal error: cannot find a page to unmap\n" 00833 "InnoDB: awe_LRU_free_mapped list length %lu\n", 00834 (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); 00835 00836 ut_a(0); 00837 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE buf_block_t* buf_block_alloc | ( | void | ) |
Definition at line 843 of file buf0buf.c.
References yaSSL::block, and buf_LRU_get_free_block().
Referenced by buf_frame_alloc(), and buf_page_init_for_read().
00845 : the allocated block; also if AWE 00846 is used it is guaranteed that the page is 00847 mapped to a frame */ 00848 { 00849 buf_block_t* block; 00850 00851 block = buf_LRU_get_free_block(); 00852 00853 return(block); 00854 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE void buf_block_free | ( | buf_block_t * | block | ) |
Definition at line 902 of file buf0buf.c.
References yaSSL::block, BUF_BLOCK_FILE_PAGE, buf_LRU_block_free_non_file_page(), buf_pool, buf_pool_struct::mutex, mutex_enter, mutex_exit(), and ut_a.
Referenced by buf_frame_free(), buf_page_create(), and buf_page_init_for_read().
00904 : block to be freed */ 00905 { 00906 ut_a(block->state != BUF_BLOCK_FILE_PAGE); 00907 00908 mutex_enter(&(buf_pool->mutex)); 00909 00910 buf_LRU_block_free_non_file_page(block); 00911 00912 mutex_exit(&(buf_pool->mutex)); 00913 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void buf_block_init | ( | buf_block_t * | block, | |
| byte * | frame | |||
| ) | [static] |
Definition at line 498 of file buf0buf.c.
References yaSSL::block, BUF_BLOCK_NOT_USED, FALSE, NULL, rw_lock_create, rw_lock_validate(), SYNC_LEVEL_VARYING, SYNC_NO_ORDER_CHECK, ut_ad, and ut_dulint_zero.
Referenced by buf_pool_init().
00500 : pointer to control block */ 00501 byte* frame) /* in: pointer to buffer frame, or NULL if in 00502 the case of AWE there is no frame */ 00503 { 00504 block->magic_n = 0; 00505 00506 block->state = BUF_BLOCK_NOT_USED; 00507 00508 block->frame = frame; 00509 00510 block->awe_info = NULL; 00511 00512 block->buf_fix_count = 0; 00513 block->io_fix = 0; 00514 00515 block->modify_clock = ut_dulint_zero; 00516 00517 block->file_page_was_freed = FALSE; 00518 00519 block->check_index_page_at_flush = FALSE; 00520 block->index = NULL; 00521 00522 block->in_free_list = FALSE; 00523 block->in_LRU_list = FALSE; 00524 00525 block->n_pointers = 0; 00526 00527 rw_lock_create(&block->lock, SYNC_LEVEL_VARYING); 00528 ut_ad(rw_lock_validate(&(block->lock))); 00529 00530 #ifdef UNIV_SYNC_DEBUG 00531 rw_lock_create(&block->debug_latch, SYNC_NO_ORDER_CHECK); 00532 #endif /* UNIV_SYNC_DEBUG */ 00533 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE void buf_block_make_young | ( | buf_block_t * | block | ) |
Definition at line 861 of file buf0buf.c.
References yaSSL::block, buf_LRU_make_block_young(), buf_pool, buf_pool_struct::curr_size, and buf_pool_struct::freed_page_clock.
Referenced by buf_page_get_gen(), buf_page_get_known_nowait(), and buf_page_optimistic_get_func().
00863 : block to make younger */ 00864 { 00865 if (buf_pool->freed_page_clock >= block->freed_page_clock 00866 + 1 + (buf_pool->curr_size / 1024)) { 00867 00868 /* There has been freeing activity in the LRU list: 00869 best to move to the head of the LRU list */ 00870 00871 buf_LRU_make_block_young(block); 00872 } 00873 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 240 of file buf0buf.c.
References FIL_PAGE_DATA, FIL_PAGE_END_LSN_OLD_CHKSUM, FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_OFFSET, UNIV_PAGE_SIZE, and ut_fold_binary().
00242 : checksum */ 00243 byte* page) /* in: buffer page */ 00244 { 00245 ulint checksum; 00246 00247 /* Since the field FIL_PAGE_FILE_FLUSH_LSN, and in versions <= 4.1.x 00248 ..._ARCH_LOG_NO, are written outside the buffer pool to the first 00249 pages of data files, we have to skip them in the page checksum 00250 calculation. 00251 We must also skip the field FIL_PAGE_SPACE_OR_CHKSUM where the 00252 checksum is stored, and also the last 8 bytes of page because 00253 there we store the old formula checksum. */ 00254 00255 checksum = ut_fold_binary(page + FIL_PAGE_OFFSET, 00256 FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET) 00257 + ut_fold_binary(page + FIL_PAGE_DATA, 00258 UNIV_PAGE_SIZE - FIL_PAGE_DATA 00259 - FIL_PAGE_END_LSN_OLD_CHKSUM); 00260 checksum = checksum & 0xFFFFFFFFUL; 00261 00262 return(checksum); 00263 }
Here is the call graph for this function:

Definition at line 274 of file buf0buf.c.
References FIL_PAGE_FILE_FLUSH_LSN, and ut_fold_binary().
00276 : checksum */ 00277 byte* page) /* in: buffer page */ 00278 { 00279 ulint checksum; 00280 00281 checksum = ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN); 00282 00283 checksum = checksum & 0xFFFFFFFFUL; 00284 00285 return(checksum); 00286 }
Here is the call graph for this function:

| buf_frame_t* buf_frame_alloc | ( | void | ) |
Definition at line 919 of file buf0buf.c.
References buf_block_alloc().
Referenced by btr_page_reorganize_low(), btr_search_check_free_space_in_heap(), mem_heap_create_block(), and recv_apply_log_recs_for_backup().
00921 : buffer frame */ 00922 { 00923 return(buf_block_alloc()->frame); 00924 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_frame_free | ( | buf_frame_t * | frame | ) |
Definition at line 930 of file buf0buf.c.
References buf_block_align(), and buf_block_free().
Referenced by btr_page_reorganize_low(), btr_search_check_free_space_in_heap(), mem_heap_block_free(), and mem_heap_free_block_free().
00932 : buffer frame */ 00933 { 00934 buf_block_free(buf_block_align(frame)); 00935 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ulint buf_get_free_list_len | ( | void | ) |
Definition at line 2459 of file buf0buf.c.
References buf_pool, buf_pool_struct::mutex, mutex_enter, mutex_exit(), and UT_LIST_GET_LEN.
02461 { 02462 ulint len; 02463 02464 mutex_enter(&(buf_pool->mutex)); 02465 02466 len = UT_LIST_GET_LEN(buf_pool->free); 02467 02468 mutex_exit(&(buf_pool->mutex)); 02469 02470 return(len); 02471 }
Here is the call graph for this function:

| ulint buf_get_latched_pages_number | ( | void | ) |
Definition at line 2233 of file buf0buf.c.
References yaSSL::block, BUF_BLOCK_MAGIC_N, buf_pool, buf_pool_get_nth_block(), buf_pool_struct::curr_size, buf_pool_struct::mutex, mutex_enter, and mutex_exit().
Referenced by srv_export_innodb_status().
02234 { 02235 buf_block_t* block; 02236 ulint i; 02237 ulint fixed_pages_number = 0; 02238 02239 mutex_enter(&(buf_pool->mutex)); 02240 02241 for (i = 0; i < buf_pool->curr_size; i++) { 02242 02243 block = buf_pool_get_nth_block(buf_pool, i); 02244 02245 if (((block->buf_fix_count != 0) || (block->io_fix != 0)) && 02246 block->magic_n == BUF_BLOCK_MAGIC_N ) 02247 fixed_pages_number++; 02248 } 02249 02250 mutex_exit(&(buf_pool->mutex)); 02251 02252 return(fixed_pages_number); 02253 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ulint buf_get_modified_ratio_pct | ( | void | ) |
Definition at line 2273 of file buf0buf.c.
References buf_pool, buf_pool_struct::mutex, mutex_enter, mutex_exit(), and UT_LIST_GET_LEN.
Referenced by srv_master_thread().
02275 { 02276 ulint ratio; 02277 02278 mutex_enter(&(buf_pool->mutex)); 02279 02280 ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list)) 02281 / (1 + UT_LIST_GET_LEN(buf_pool->LRU) 02282 + UT_LIST_GET_LEN(buf_pool->free)); 02283 02284 /* 1 + is there to avoid division by zero */ 02285 02286 mutex_exit(&(buf_pool->mutex)); 02287 02288 return(ratio); 02289 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ulint buf_get_n_pending_ios | ( | void | ) |
Definition at line 2259 of file buf0buf.c.
References BUF_FLUSH_LIST, BUF_FLUSH_LRU, BUF_FLUSH_SINGLE_PAGE, buf_pool, buf_pool_struct::n_flush, and buf_pool_struct::n_pend_reads.
Referenced by srv_master_thread().
02261 { 02262 return(buf_pool->n_pend_reads 02263 + buf_pool->n_flush[BUF_FLUSH_LRU] 02264 + buf_pool->n_flush[BUF_FLUSH_LIST] 02265 + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); 02266 }
Here is the caller graph for this function:

| buf_frame_t* buf_page_create | ( | ulint | space, | |
| ulint | offset, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 1747 of file buf0buf.c.
References yaSSL::block, buf_block_free(), buf_flush_free_margin(), buf_LRU_add_block(), buf_LRU_get_free_block(), buf_page_get_with_no_latch, buf_page_hash_get(), buf_page_init(), buf_pool, FALSE, FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_NEXT, FIL_PAGE_PREV, FIL_PAGE_TYPE, FIL_PAGE_TYPE_ALLOCATED, free_block(), ibuf_merge_or_delete_for_page(), mach_write_to_2(), memset, MTR_MEMO_BUF_FIX, mtr_memo_push(), buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_pages_created, NULL, TRUE, ut_a, and ut_ad.
Referenced by fseg_alloc_free_page_low(), fsp_alloc_free_page(), fsp_fill_free_list(), and fsp_header_init().
01749 : pointer to the frame, page bufferfixed */ 01750 ulint space, /* in: space id */ 01751 ulint offset, /* in: offset of the page within space in units of 01752 a page */ 01753 mtr_t* mtr) /* in: mini-transaction handle */ 01754 { 01755 buf_frame_t* frame; 01756 buf_block_t* block; 01757 buf_block_t* free_block = NULL; 01758 01759 ut_ad(mtr); 01760 01761 free_block = buf_LRU_get_free_block(); 01762 01763 mutex_enter(&(buf_pool->mutex)); 01764 01765 block = buf_page_hash_get(space, offset); 01766 01767 if (block != NULL) { 01768 #ifdef UNIV_IBUF_DEBUG 01769 ut_a(ibuf_count_get(block->space, block->offset) == 0); 01770 #endif 01771 block->file_page_was_freed = FALSE; 01772 01773 /* Page can be found in buf_pool */ 01774 mutex_exit(&(buf_pool->mutex)); 01775 01776 buf_block_free(free_block); 01777 01778 frame = buf_page_get_with_no_latch(space, offset, mtr); 01779 01780 return(frame); 01781 } 01782 01783 /* If we get here, the page was not in buf_pool: init it there */ 01784 01785 #ifdef UNIV_DEBUG 01786 if (buf_debug_prints) { 01787 fprintf(stderr, "Creating space %lu page %lu to buffer\n", 01788 (ulong) space, (ulong) offset); 01789 } 01790 #endif /* UNIV_DEBUG */ 01791 01792 block = free_block; 01793 01794 buf_page_init(space, offset, block); 01795 01796 /* The block must be put to the LRU list */ 01797 buf_LRU_add_block(block, FALSE); 01798 01799 #ifdef UNIV_SYNC_DEBUG 01800 buf_block_buf_fix_inc_debug(block, __FILE__, __LINE__); 01801 #else 01802 buf_block_buf_fix_inc(block); 01803 #endif 01804 mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX); 01805 01806 block->accessed = TRUE; 01807 01808 buf_pool->n_pages_created++; 01809 01810 mutex_exit(&(buf_pool->mutex)); 01811 01812 /* Delete possible entries for the page from the insert buffer: 01813 such can exist if the page belonged to an index which was dropped */ 01814 01815 ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE); 01816 01817 /* Flush pages from the end of the LRU list if necessary */ 01818 buf_flush_free_margin(); 01819 01820 frame = block->frame; 01821 01822 memset(frame + FIL_PAGE_PREV, 0xff, 4); 01823 memset(frame + FIL_PAGE_NEXT, 0xff, 4); 01824 mach_write_to_2(frame + FIL_PAGE_TYPE, FIL_PAGE_TYPE_ALLOCATED); 01825 01826 /* Reset to zero the file flush lsn field in the page; if the first 01827 page of an ibdata file is 'created' in this function into the buffer 01828 pool then we lose the original contents of the file flush lsn stamp. 01829 Then InnoDB could in a crash recovery print a big, false, corruption 01830 warning if the stamp contains an lsn bigger than the ib_logfile lsn. */ 01831 01832 memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); 01833 01834 #ifdef UNIV_DEBUG 01835 buf_dbg_counter++; 01836 01837 if (buf_dbg_counter % 357 == 0) { 01838 ut_ad(buf_validate()); 01839 } 01840 #endif 01841 #ifdef UNIV_IBUF_DEBUG 01842 ut_a(ibuf_count_get(block->space, block->offset) == 0); 01843 #endif 01844 return(frame); 01845 }
Here is the call graph for this function:

Here is the caller graph for this function:

| buf_frame_t* buf_page_get_gen | ( | ulint | space, | |
| ulint | offset, | |||
| ulint | rw_latch, | |||
| buf_frame_t * | guess, | |||
| ulint | mode, | |||
| const char * | file, | |||
| ulint | line, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 1099 of file buf0buf.c.
References yaSSL::block, buf_awe_map_page_to_frame(), buf_block_align(), BUF_BLOCK_FILE_PAGE, buf_block_make_young(), BUF_GET, BUF_GET_IF_IN_POOL, BUF_GET_NO_LATCH, BUF_GET_NOWAIT, BUF_IO_READ, buf_page_hash_get(), buf_pool, buf_read_page(), FALSE, ibuf_inside(), ibuf_page(), MTR_MEMO_BUF_FIX, MTR_MEMO_PAGE_S_FIX, MTR_MEMO_PAGE_X_FIX, buf_pool_struct::mutex, mutex_enter, mutex_enter_fast, mutex_exit(), buf_pool_struct::n_page_gets, NULL, os_thread_sleep(), rw_lock_s_lock_func_nowait(), rw_lock_s_unlock, rw_lock_x_lock_func_nowait(), RW_NO_LATCH, RW_S_LATCH, RW_X_LATCH, srv_use_awe, TRUE, ut_a, and ut_ad.
Referenced by btr_cur_open_at_index_side(), btr_cur_open_at_rnd_pos(), btr_cur_search_to_nth_level(), btr_search_drop_page_hash_when_freed(), lock_rec_print(), and trx_undo_report_row_operation().
01101 : pointer to the frame or NULL */ 01102 ulint space, /* in: space id */ 01103 ulint offset, /* in: page number */ 01104 ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */ 01105 buf_frame_t* guess, /* in: guessed frame or NULL */ 01106 ulint mode, /* in: BUF_GET, BUF_GET_IF_IN_POOL, 01107 BUF_GET_NO_LATCH, BUF_GET_NOWAIT */ 01108 const char* file, /* in: file name */ 01109 ulint line, /* in: line where called */ 01110 mtr_t* mtr) /* in: mini-transaction */ 01111 { 01112 buf_block_t* block; 01113 ibool accessed; 01114 ulint fix_type; 01115 ibool success; 01116 ibool must_read; 01117 01118 ut_ad(mtr); 01119 ut_ad((rw_latch == RW_S_LATCH) 01120 || (rw_latch == RW_X_LATCH) 01121 || (rw_latch == RW_NO_LATCH)); 01122 ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH)); 01123 ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL) 01124 || (mode == BUF_GET_NO_LATCH) || (mode == BUF_GET_NOWAIT)); 01125 #ifndef UNIV_LOG_DEBUG 01126 ut_ad(!ibuf_inside() || ibuf_page(space, offset)); 01127 #endif 01128 buf_pool->n_page_gets++; 01129 loop: 01130 mutex_enter_fast(&(buf_pool->mutex)); 01131 01132 block = NULL; 01133 01134 if (guess) { 01135 block = buf_block_align(guess); 01136 01137 if ((offset != block->offset) || (space != block->space) 01138 || (block->state != BUF_BLOCK_FILE_PAGE)) { 01139 01140 block = NULL; 01141 } 01142 } 01143 01144 if (block == NULL) { 01145 block = buf_page_hash_get(space, offset); 01146 } 01147 01148 if (block == NULL) { 01149 /* Page not in buf_pool: needs to be read from file */ 01150 01151 mutex_exit(&(buf_pool->mutex)); 01152 01153 if (mode == BUF_GET_IF_IN_POOL) { 01154 01155 return(NULL); 01156 } 01157 01158 buf_read_page(space, offset); 01159 01160 #ifdef UNIV_DEBUG 01161 buf_dbg_counter++; 01162 01163 if (buf_dbg_counter % 37 == 0) { 01164 ut_ad(buf_validate()); 01165 } 01166 #endif 01167 goto loop; 01168 } 01169 01170 ut_a(block->state == BUF_BLOCK_FILE_PAGE); 01171 01172 must_read = FALSE; 01173 01174 if (block->io_fix == BUF_IO_READ) { 01175 01176 must_read = TRUE; 01177 01178 if (mode == BUF_GET_IF_IN_POOL) { 01179 01180 /* The page is only being read to buffer */ 01181 mutex_exit(&(buf_pool->mutex)); 01182 01183 return(NULL); 01184 } 01185 } 01186 01187 /* If AWE is enabled and the page is not mapped to a frame, then 01188 map it */ 01189 01190 if (block->frame == NULL) { 01191 ut_a(srv_use_awe); 01192 01193 /* We set second parameter TRUE because the block is in the 01194 LRU list and we must put it to awe_LRU_free_mapped list once 01195 mapped to a frame */ 01196 01197 buf_awe_map_page_to_frame(block, TRUE); 01198 } 01199 01200 #ifdef UNIV_SYNC_DEBUG 01201 buf_block_buf_fix_inc_debug(block, file, line); 01202 #else 01203 buf_block_buf_fix_inc(block); 01204 #endif 01205 buf_block_make_young(block); 01206 01207 /* Check if this is the first access to the page */ 01208 01209 accessed = block->accessed; 01210 01211 block->accessed = TRUE; 01212 01213 #ifdef UNIV_DEBUG_FILE_ACCESSES 01214 ut_a(block->file_page_was_freed == FALSE); 01215 #endif 01216 mutex_exit(&(buf_pool->mutex)); 01217 01218 #ifdef UNIV_DEBUG 01219 buf_dbg_counter++; 01220 01221 if (buf_dbg_counter % 5771 == 0) { 01222 ut_ad(buf_validate()); 01223 } 01224 #endif 01225 ut_ad(block->buf_fix_count > 0); 01226 ut_ad(block->state == BUF_BLOCK_FILE_PAGE); 01227 01228 if (mode == BUF_GET_NOWAIT) { 01229 if (rw_latch == RW_S_LATCH) { 01230 success = rw_lock_s_lock_func_nowait(&(block->lock), 01231 file, line); 01232 fix_type = MTR_MEMO_PAGE_S_FIX; 01233 } else { 01234 ut_ad(rw_latch == RW_X_LATCH); 01235 success = rw_lock_x_lock_func_nowait(&(block->lock), 01236 file, line); 01237 fix_type = MTR_MEMO_PAGE_X_FIX; 01238 } 01239 01240 if (!success) { 01241 mutex_enter(&(buf_pool->mutex)); 01242 01243 block->buf_fix_count--; 01244 #ifdef UNIV_SYNC_DEBUG 01245 rw_lock_s_unlock(&(block->debug_latch)); 01246 #endif 01247 mutex_exit(&(buf_pool->mutex)); 01248 01249 return(NULL); 01250 } 01251 } else if (rw_latch == RW_NO_LATCH) { 01252 01253 if (must_read) { 01254 /* Let us wait until the read operation 01255 completes */ 01256 01257 for (;;) { 01258 mutex_enter(&(buf_pool->mutex)); 01259 01260 if (block->io_fix == BUF_IO_READ) { 01261 01262 mutex_exit(&(buf_pool->mutex)); 01263 01264 /* Sleep 20 milliseconds */ 01265 01266 os_thread_sleep(20000); 01267 } else { 01268 01269 mutex_exit(&(buf_pool->mutex)); 01270 01271 break; 01272 } 01273 } 01274 } 01275 01276 fix_type = MTR_MEMO_BUF_FIX; 01277 } else if (rw_latch == RW_S_LATCH) { 01278 01279 rw_lock_s_lock_func(&(block->lock), 0, file, line); 01280 01281 fix_type = MTR_MEMO_PAGE_S_FIX; 01282 } else { 01283 rw_lock_x_lock_func(&(block->lock), 0, file, line); 01284 01285 fix_type = MTR_MEMO_PAGE_X_FIX; 01286 } 01287 01288 mtr_memo_push(mtr, block, fix_type); 01289 01290 if (!accessed) { 01291 /* In the case of a first access, try to apply linear 01292 read-ahead */ 01293 01294 buf_read_ahead_linear(space, offset); 01295 } 01296 01297 #ifdef UNIV_IBUF_DEBUG 01298 ut_a(ibuf_count_get(block->space, block->offset) == 0); 01299 #endif 01300 return(block->frame); 01301 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ibool buf_page_get_known_nowait | ( | ulint | rw_latch, | |
| buf_frame_t * | guess, | |||
| ulint | mode, | |||
| const char * | file, | |||
| ulint | line, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 1433 of file buf0buf.c.
References yaSSL::block, buf_block_align(), BUF_BLOCK_FILE_PAGE, buf_block_make_young(), BUF_BLOCK_REMOVE_HASH, BUF_KEEP_OLD, BUF_MAKE_YOUNG, buf_pool, FALSE, ibuf_inside(), MTR_MEMO_PAGE_S_FIX, MTR_MEMO_PAGE_X_FIX, mtr_memo_push(), buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_page_gets, rw_lock_s_lock_func_nowait(), rw_lock_s_unlock, rw_lock_x_lock_func_nowait(), RW_S_LATCH, RW_X_LATCH, TRUE, ut_a, and ut_ad.
Referenced by btr_search_guess_on_hash(), ibuf_merge_or_delete_for_page(), and recv_recover_page().
01435 : TRUE if success */ 01436 ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */ 01437 buf_frame_t* guess, /* in: the known page frame */ 01438 ulint mode, /* in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */ 01439 const char* file, /* in: file name */ 01440 ulint line, /* in: line where called */ 01441 mtr_t* mtr) /* in: mini-transaction */ 01442 { 01443 buf_block_t* block; 01444 ibool success; 01445 ulint fix_type; 01446 01447 ut_ad(mtr); 01448 ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH)); 01449 01450 mutex_enter(&(buf_pool->mutex)); 01451 01452 block = buf_block_align(guess); 01453 01454 if (block->state == BUF_BLOCK_REMOVE_HASH) { 01455 /* Another thread is just freeing the block from the LRU list 01456 of the buffer pool: do not try to access this page; this 01457 attempt to access the page can only come through the hash 01458 index because when the buffer block state is ..._REMOVE_HASH, 01459 we have already removed it from the page address hash table 01460 of the buffer pool. */ 01461 01462 mutex_exit(&(buf_pool->mutex)); 01463 01464 return(FALSE); 01465 } 01466 01467 ut_a(block->state == BUF_BLOCK_FILE_PAGE); 01468 01469 #ifdef UNIV_SYNC_DEBUG 01470 buf_block_buf_fix_inc_debug(block, file, line); 01471 #else 01472 buf_block_buf_fix_inc(block); 01473 #endif 01474 if (mode == BUF_MAKE_YOUNG) { 01475 buf_block_make_young(block); 01476 } 01477 01478 mutex_exit(&(buf_pool->mutex)); 01479 01480 ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD)); 01481 01482 if (rw_latch == RW_S_LATCH) { 01483 success = rw_lock_s_lock_func_nowait(&(block->lock), 01484 file, line); 01485 fix_type = MTR_MEMO_PAGE_S_FIX; 01486 } else { 01487 success = rw_lock_x_lock_func_nowait(&(block->lock), 01488 file, line); 01489 fix_type = MTR_MEMO_PAGE_X_FIX; 01490 } 01491 01492 if (!success) { 01493 mutex_enter(&(buf_pool->mutex)); 01494 01495 block->buf_fix_count--; 01496 #ifdef UNIV_SYNC_DEBUG 01497 rw_lock_s_unlock(&(block->debug_latch)); 01498 #endif 01499 mutex_exit(&(buf_pool->mutex)); 01500 01501 return(FALSE); 01502 } 01503 01504 mtr_memo_push(mtr, block, fix_type); 01505 01506 #ifdef UNIV_DEBUG 01507 buf_dbg_counter++; 01508 01509 if (buf_dbg_counter % 5771 == 0) { 01510 ut_ad(buf_validate()); 01511 } 01512 #endif 01513 ut_ad(block->buf_fix_count > 0); 01514 ut_ad(block->state == BUF_BLOCK_FILE_PAGE); 01515 #ifdef UNIV_DEBUG_FILE_ACCESSES 01516 ut_a(block->file_page_was_freed == FALSE); 01517 #endif 01518 01519 #ifdef UNIV_IBUF_DEBUG 01520 ut_a((mode == BUF_KEEP_OLD) 01521 || (ibuf_count_get(block->space, block->offset) == 0)); 01522 #endif 01523 buf_pool->n_page_gets++; 01524 01525 return(TRUE); 01526 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void buf_page_init | ( | ulint | space, | |
| ulint | offset, | |||
| buf_block_t * | block | |||
| ) | [static] |
Definition at line 1571 of file buf0buf.c.
References yaSSL::block, BTR_SEARCH_LEFT_SIDE, BUF_BLOCK_FILE_PAGE, BUF_BLOCK_MAGIC_N, buf_page_address_fold(), buf_page_hash_get(), buf_pool, FALSE, hash(), HASH_INSERT, lock_rec_hash(), buf_pool_struct::mutex, NULL, buf_pool_struct::page_hash, ut_a, ut_ad, and ut_dulint_zero.
Referenced by buf_page_create(), and buf_page_init_for_read().
01573 : space id */ 01574 ulint offset, /* in: offset of the page within space 01575 in units of a page */ 01576 buf_block_t* block) /* in: block to init */ 01577 { 01578 #ifdef UNIV_SYNC_DEBUG 01579 ut_ad(mutex_own(&(buf_pool->mutex))); 01580 #endif /* UNIV_SYNC_DEBUG */ 01581 ut_a(block->state != BUF_BLOCK_FILE_PAGE); 01582 01583 /* Set the state of the block */ 01584 block->magic_n = BUF_BLOCK_MAGIC_N; 01585 01586 block->state = BUF_BLOCK_FILE_PAGE; 01587 block->space = space; 01588 block->offset = offset; 01589 01590 block->check_index_page_at_flush = FALSE; 01591 block->index = NULL; 01592 01593 block->lock_hash_val = lock_rec_hash(space, offset); 01594 block->lock_mutex = NULL; 01595 01596 /* Insert into the hash table of file pages */ 01597 01598 if (buf_page_hash_get(space, offset)) { 01599 fprintf(stderr, 01600 "InnoDB: Error: page %lu %lu already found from the hash table\n", 01601 (ulong) space, 01602 (ulong) offset); 01603 #ifdef UNIV_DEBUG 01604 buf_print(); 01605 buf_LRU_print(); 01606 buf_validate(); 01607 buf_LRU_validate(); 01608 #endif /* UNIV_DEBUG */ 01609 ut_a(0); 01610 } 01611 01612 HASH_INSERT(buf_block_t, hash, buf_pool->page_hash, 01613 buf_page_address_fold(space, offset), block); 01614 01615 block->freed_page_clock = 0; 01616 01617 block->newest_modification = ut_dulint_zero; 01618 block->oldest_modification = ut_dulint_zero; 01619 01620 block->accessed = FALSE; 01621 block->buf_fix_count = 0; 01622 block->io_fix = 0; 01623 01624 block->n_hash_helps = 0; 01625 block->is_hashed = FALSE; 01626 block->n_fields = 1; 01627 block->n_bytes = 0; 01628 block->side = BTR_SEARCH_LEFT_SIDE; 01629 01630 block->file_page_was_freed = FALSE; 01631 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_page_init_for_backup_restore | ( | ulint | space, | |
| ulint | offset, | |||
| buf_block_t * | block | |||
| ) |
Definition at line 1532 of file buf0buf.c.
References yaSSL::block, BTR_SEARCH_LEFT_SIDE, BUF_BLOCK_FILE_PAGE, BUF_BLOCK_MAGIC_N, FALSE, NULL, and ut_dulint_zero.
Referenced by recv_apply_log_recs_for_backup().
01534 : space id */ 01535 ulint offset, /* in: offset of the page within space 01536 in units of a page */ 01537 buf_block_t* block) /* in: block to init */ 01538 { 01539 /* Set the state of the block */ 01540 block->magic_n = BUF_BLOCK_MAGIC_N; 01541 01542 block->state = BUF_BLOCK_FILE_PAGE; 01543 block->space = space; 01544 block->offset = offset; 01545 01546 block->lock_hash_val = 0; 01547 block->lock_mutex = NULL; 01548 01549 block->freed_page_clock = 0; 01550 01551 block->newest_modification = ut_dulint_zero; 01552 block->oldest_modification = ut_dulint_zero; 01553 01554 block->accessed = FALSE; 01555 block->buf_fix_count = 0; 01556 block->io_fix = 0; 01557 01558 block->n_hash_helps = 0; 01559 block->is_hashed = FALSE; 01560 block->n_fields = 1; 01561 block->n_bytes = 0; 01562 block->side = BTR_SEARCH_LEFT_SIDE; 01563 01564 block->file_page_was_freed = FALSE; 01565 }
Here is the caller graph for this function:

| buf_block_t* buf_page_init_for_read | ( | ulint * | err, | |
| ulint | mode, | |||
| ulint | space, | |||
| ib_longlong | tablespace_version, | |||
| ulint | offset | |||
| ) |
Definition at line 1646 of file buf0buf.c.
References yaSSL::block, buf_block_alloc(), buf_block_free(), BUF_IO_READ, buf_LRU_add_block(), buf_page_hash_get(), buf_page_init(), buf_pool, BUF_READ_ANY_PAGE, BUF_READ_IBUF_PAGES_ONLY, DB_SUCCESS, DB_TABLESPACE_DELETED, fil_tablespace_deleted_or_being_deleted_in_mem(), ibuf_bitmap_page(), ibuf_inside(), ibuf_page_low(), mtr_commit(), mtr_start(), buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_pend_reads, NULL, rw_lock_x_lock_gen, TRUE, ut_a, and ut_ad.
Referenced by buf_read_page_low().
01648 : pointer to the block or NULL */ 01649 ulint* err, /* out: DB_SUCCESS or DB_TABLESPACE_DELETED */ 01650 ulint mode, /* in: BUF_READ_IBUF_PAGES_ONLY, ... */ 01651 ulint space, /* in: space id */ 01652 ib_longlong tablespace_version,/* in: prevents reading from a wrong 01653 version of the tablespace in case we have done 01654 DISCARD + IMPORT */ 01655 ulint offset) /* in: page number */ 01656 { 01657 buf_block_t* block; 01658 mtr_t mtr; 01659 01660 ut_ad(buf_pool); 01661 01662 *err = DB_SUCCESS; 01663 01664 if (mode == BUF_READ_IBUF_PAGES_ONLY) { 01665 /* It is a read-ahead within an ibuf routine */ 01666 01667 ut_ad(!ibuf_bitmap_page(offset)); 01668 ut_ad(ibuf_inside()); 01669 01670 mtr_start(&mtr); 01671 01672 if (!ibuf_page_low(space, offset, &mtr)) { 01673 01674 mtr_commit(&mtr); 01675 01676 return(NULL); 01677 } 01678 } else { 01679 ut_ad(mode == BUF_READ_ANY_PAGE); 01680 } 01681 01682 block = buf_block_alloc(); 01683 01684 ut_a(block); 01685 01686 mutex_enter(&(buf_pool->mutex)); 01687 01688 if (fil_tablespace_deleted_or_being_deleted_in_mem(space, 01689 tablespace_version)) { 01690 *err = DB_TABLESPACE_DELETED; 01691 } 01692 01693 if (*err == DB_TABLESPACE_DELETED 01694 || NULL != buf_page_hash_get(space, offset)) { 01695 01696 /* The page belongs to a space which has been deleted or is 01697 being deleted, or the page is already in buf_pool, return */ 01698 01699 mutex_exit(&(buf_pool->mutex)); 01700 buf_block_free(block); 01701 01702 if (mode == BUF_READ_IBUF_PAGES_ONLY) { 01703 01704 mtr_commit(&mtr); 01705 } 01706 01707 return(NULL); 01708 } 01709 01710 ut_ad(block); 01711 01712 buf_page_init(space, offset, block); 01713 01714 /* The block must be put to the LRU list, to the old blocks */ 01715 01716 buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */ 01717 01718 block->io_fix = BUF_IO_READ; 01719 buf_pool->n_pend_reads++; 01720 01721 /* We set a pass-type x-lock on the frame because then the same 01722 thread which called for the read operation (and is running now at 01723 this point of code) can wait for the read to complete by waiting 01724 for the x-lock on the frame; if the x-lock were recursive, the 01725 same thread would illegally get the x-lock before the page read 01726 is completed. The x-lock is cleared by the io-handler thread. */ 01727 01728 rw_lock_x_lock_gen(&(block->lock), BUF_IO_READ); 01729 01730 mutex_exit(&(buf_pool->mutex)); 01731 01732 if (mode == BUF_READ_IBUF_PAGES_ONLY) { 01733 01734 mtr_commit(&mtr); 01735 } 01736 01737 return(block); 01738 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_page_io_complete | ( | buf_block_t * | block | ) |
Definition at line 1852 of file buf0buf.c.
References yaSSL::block, BUF_BLOCK_FILE_PAGE, buf_flush_write_complete(), BUF_IO_READ, BUF_IO_WRITE, buf_page_is_corrupted(), buf_page_print(), buf_pool, exit, FALSE, FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, FIL_PAGE_OFFSET, ibuf_merge_or_delete_for_page(), mach_read_from_4(), buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_pages_read, buf_pool_struct::n_pages_written, buf_pool_struct::n_pend_reads, recv_no_ibuf_operations, recv_recover_page(), recv_recovery_is_on(), rw_lock_s_unlock_gen, rw_lock_x_unlock_gen, SRV_FORCE_IGNORE_CORRUPT, srv_force_recovery, TRUE, trx_doublewrite_page_inside(), ut_a, ut_ad, and ut_print_timestamp().
Referenced by buf_read_page_low(), and fil_aio_wait().
01854 : pointer to the block in question */ 01855 { 01856 ulint io_type; 01857 01858 ut_ad(block); 01859 01860 ut_a(block->state == BUF_BLOCK_FILE_PAGE); 01861 01862 io_type = block->io_fix; 01863 01864 if (io_type == BUF_IO_READ) { 01865 /* If this page is not uninitialized and not in the 01866 doublewrite buffer, then the page number and space id 01867 should be the same as in block. */ 01868 ulint read_page_no = mach_read_from_4((block->frame) 01869 + FIL_PAGE_OFFSET); 01870 ulint read_space_id = mach_read_from_4((block->frame) 01871 + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); 01872 01873 if (!block->space && trx_doublewrite_page_inside( 01874 block->offset)) { 01875 01876 ut_print_timestamp(stderr); 01877 fprintf(stderr, 01878 " InnoDB: Error: reading page %lu\n" 01879 "InnoDB: which is in the doublewrite buffer!\n", 01880 (ulong) block->offset); 01881 } else if (!read_space_id && !read_page_no) { 01882 /* This is likely an uninitialized page. */ 01883 } else if ((block->space && block->space != read_space_id) 01884 || block->offset != read_page_no) { 01885 /* We did not compare space_id to read_space_id 01886 if block->space == 0, because the field on the 01887 page may contain garbage in MySQL < 4.1.1, 01888 which only supported block->space == 0. */ 01889 01890 ut_print_timestamp(stderr); 01891 fprintf(stderr, 01892 " InnoDB: Error: space id and page n:o stored in the page\n" 01893 "InnoDB: read in are %lu:%lu, should be %lu:%lu!\n", 01894 (ulong) read_space_id, (ulong) read_page_no, 01895 (ulong) block->space, (ulong) block->offset); 01896 } 01897 /* From version 3.23.38 up we store the page checksum 01898 to the 4 first bytes of the page end lsn field */ 01899 01900 if (buf_page_is_corrupted(block->frame)) { 01901 fprintf(stderr, 01902 "InnoDB: Database page corruption on disk or a failed\n" 01903 "InnoDB: file read of page %lu.\n", (ulong) block->offset); 01904 01905 fputs( 01906 "InnoDB: You may have to recover from a backup.\n", stderr); 01907 01908 buf_page_print(block->frame); 01909 01910 fprintf(stderr, 01911 "InnoDB: Database page corruption on disk or a failed\n" 01912 "InnoDB: file read of page %lu.\n", (ulong) block->offset); 01913 fputs( 01914 "InnoDB: You may have to recover from a backup.\n", stderr); 01915 fputs( 01916 "InnoDB: It is also possible that your operating\n" 01917 "InnoDB: system has corrupted its own file cache\n" 01918 "InnoDB: and rebooting your computer removes the\n" 01919 "InnoDB: error.\n" 01920 "InnoDB: If the corrupt page is an index page\n" 01921 "InnoDB: you can also try to fix the corruption\n" 01922 "InnoDB: by dumping, dropping, and reimporting\n" 01923 "InnoDB: the corrupt table. You can use CHECK\n" 01924 "InnoDB: TABLE to scan your table for corruption.\n" 01925 "InnoDB: See also " 01926 "http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html\n" 01927 "InnoDB: about forcing recovery.\n", stderr); 01928 01929 if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) { 01930 fputs( 01931 "InnoDB: Ending processing because of a corrupt database page.\n", 01932 stderr); 01933 exit(1); 01934 } 01935 } 01936 01937 if (recv_recovery_is_on()) { 01938 recv_recover_page(FALSE, TRUE, block->frame, 01939 block->space, block->offset); 01940 } 01941 01942 if (!recv_no_ibuf_operations) { 01943 ibuf_merge_or_delete_for_page(block->frame, 01944 block->space, block->offset, TRUE); 01945 } 01946 } 01947 01948 #ifdef UNIV_IBUF_DEBUG 01949 ut_a(ibuf_count_get(block->space, block->offset) == 0); 01950 #endif 01951 mutex_enter(&(buf_pool->mutex)); 01952 01953 /* Because this thread which does the unlocking is not the same that 01954 did the locking, we use a pass value != 0 in unlock, which simply 01955 removes the newest lock debug record, without checking the thread 01956 id. */ 01957 01958 block->io_fix = 0; 01959 01960 if (io_type == BUF_IO_READ) { 01961 /* NOTE that the call to ibuf may have moved the ownership of 01962 the x-latch to this OS thread: do not let this confuse you in 01963 debugging! */ 01964 01965 ut_ad(buf_pool->n_pend_reads > 0); 01966 buf_pool->n_pend_reads--; 01967 buf_pool->n_pages_read++; 01968 01969 rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ); 01970 01971 #ifdef UNIV_DEBUG 01972 if (buf_debug_prints) { 01973 fputs("Has read ", stderr); 01974 } 01975 #endif /* UNIV_DEBUG */ 01976 } else { 01977 ut_ad(io_type == BUF_IO_WRITE); 01978 01979 /* Write means a flush operation: call the completion 01980 routine in the flush system */ 01981 01982 buf_flush_write_complete(block); 01983 01984 rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE); 01985 01986 buf_pool->n_pages_written++; 01987 01988 #ifdef UNIV_DEBUG 01989 if (buf_debug_prints) { 01990 fputs("Has written ", stderr); 01991 } 01992 #endif /* UNIV_DEBUG */ 01993 } 01994 01995 mutex_exit(&(buf_pool->mutex)); 01996 01997 #ifdef UNIV_DEBUG 01998 if (buf_debug_prints) { 01999 fprintf(stderr, "page space %lu page no %lu\n", 02000 (ulong) block->space, (ulong) block->offset); 02001 } 02002 #endif /* UNIV_DEBUG */ 02003 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ibool buf_page_is_corrupted | ( | byte * | read_buf | ) |
Definition at line 292 of file buf0buf.c.
References buf_calc_page_new_checksum(), buf_calc_page_old_checksum(), BUF_NO_CHECKSUM_MAGIC, FALSE, FIL_PAGE_END_LSN_OLD_CHKSUM, FIL_PAGE_LSN, FIL_PAGE_OFFSET, FIL_PAGE_SPACE_OR_CHKSUM, log_peek_lsn(), mach_read_from_4(), mach_read_from_8(), recv_lsn_checks_on, srv_use_checksums, TRUE, UNIV_PAGE_SIZE, ut_dulint_cmp(), ut_dulint_get_high(), ut_dulint_get_low(), and ut_print_timestamp().
Referenced by buf_page_io_complete(), and trx_sys_doublewrite_init_or_restore_pages().
00294 : TRUE if corrupted */ 00295 byte* read_buf) /* in: a database page */ 00296 { 00297 ulint checksum; 00298 ulint old_checksum; 00299 ulint checksum_field; 00300 ulint old_checksum_field; 00301 #ifndef UNIV_HOTBACKUP 00302 dulint current_lsn; 00303 #endif 00304 if (mach_read_from_4(read_buf + FIL_PAGE_LSN + 4) 00305 != mach_read_from_4(read_buf + UNIV_PAGE_SIZE 00306 - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { 00307 00308 /* Stored log sequence numbers at the start and the end 00309 of page do not match */ 00310 00311 return(TRUE); 00312 } 00313 00314 #ifndef UNIV_HOTBACKUP 00315 if (recv_lsn_checks_on && log_peek_lsn(¤t_lsn)) { 00316 if (ut_dulint_cmp(current_lsn, 00317 mach_read_from_8(read_buf + FIL_PAGE_LSN)) 00318 < 0) { 00319 ut_print_timestamp(stderr); 00320 00321 fprintf(stderr, 00322 " InnoDB: Error: page %lu log sequence number %lu %lu\n" 00323 "InnoDB: is in the future! Current system log sequence number %lu %lu.\n" 00324 "InnoDB: Your database may be corrupt or you may have copied the InnoDB\n" 00325 "InnoDB: tablespace but not the InnoDB log files. See\n" 00326 "http://dev.mysql.com/doc/mysql/en/backing-up.html for more information.\n", 00327 (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), 00328 (ulong) ut_dulint_get_high( 00329 mach_read_from_8(read_buf + FIL_PAGE_LSN)), 00330 (ulong) ut_dulint_get_low( 00331 mach_read_from_8(read_buf + FIL_PAGE_LSN)), 00332 (ulong) ut_dulint_get_high(current_lsn), 00333 (ulong) ut_dulint_get_low(current_lsn)); 00334 } 00335 } 00336 #endif 00337 00338 /* If we use checksums validation, make additional check before 00339 returning TRUE to ensure that the checksum is not equal to 00340 BUF_NO_CHECKSUM_MAGIC which might be stored by InnoDB with checksums 00341 disabled. Otherwise, skip checksum calculation and return FALSE */ 00342 00343 if (srv_use_checksums) { 00344 old_checksum = buf_calc_page_old_checksum(read_buf); 00345 00346 old_checksum_field = mach_read_from_4(read_buf + UNIV_PAGE_SIZE 00347 - FIL_PAGE_END_LSN_OLD_CHKSUM); 00348 00349 /* There are 2 valid formulas for old_checksum_field: 00350 00351 1. Very old versions of InnoDB only stored 8 byte lsn to the 00352 start and the end of the page. 00353 00354 2. Newer InnoDB versions store the old formula checksum 00355 there. */ 00356 00357 if (old_checksum_field != mach_read_from_4(read_buf 00358 + FIL_PAGE_LSN) 00359 && old_checksum_field != old_checksum 00360 && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) { 00361 00362 return(TRUE); 00363 } 00364 00365 checksum = buf_calc_page_new_checksum(read_buf); 00366 checksum_field = mach_read_from_4(read_buf + 00367 FIL_PAGE_SPACE_OR_CHKSUM); 00368 00369 /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id 00370 (always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */ 00371 00372 if (checksum_field != 0 && checksum_field != checksum 00373 && checksum_field != BUF_NO_CHECKSUM_MAGIC) { 00374 00375 return(TRUE); 00376 } 00377 } 00378 00379 return(FALSE); 00380 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_page_make_young | ( | buf_frame_t * | frame | ) |
Definition at line 881 of file buf0buf.c.
References yaSSL::block, buf_block_align(), BUF_BLOCK_FILE_PAGE, buf_LRU_make_block_young(), buf_pool, buf_pool_struct::mutex, mutex_enter, mutex_exit(), and ut_a.
Referenced by btr_search_guess_on_hash().
00883 : buffer frame of a file page */ 00884 { 00885 buf_block_t* block; 00886 00887 mutex_enter(&(buf_pool->mutex)); 00888 00889 block = buf_block_align(frame); 00890 00891 ut_a(block->state == BUF_BLOCK_FILE_PAGE); 00892 00893 buf_LRU_make_block_young(block); 00894 00895 mutex_exit(&(buf_pool->mutex)); 00896 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ibool buf_page_optimistic_get_func | ( | ulint | rw_latch, | |
| buf_block_t * | block, | |||
| buf_frame_t * | guess, | |||
| dulint | modify_clock, | |||
| const char * | file, | |||
| ulint | line, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 1308 of file buf0buf.c.
References yaSSL::block, BUF_BLOCK_FILE_PAGE, buf_block_make_young(), buf_frame_get_page_no(), buf_frame_get_space_id(), buf_pool, buf_read_ahead_linear(), FALSE, ibuf_inside(), ibuf_page(), MTR_MEMO_PAGE_S_FIX, MTR_MEMO_PAGE_X_FIX, mtr_memo_push(), buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_page_gets, rw_lock_s_lock_func_nowait(), rw_lock_s_unlock, rw_lock_x_lock_func_nowait(), rw_lock_x_unlock, RW_S_LATCH, RW_X_LATCH, SYNC_NO_ORDER_CHECK, TRUE, ut_a, ut_ad, and UT_DULINT_EQ.
01310 : TRUE if success */ 01311 ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */ 01312 buf_block_t* block, /* in: guessed buffer block */ 01313 buf_frame_t* guess, /* in: guessed frame; note that AWE may move 01314 frames */ 01315 dulint modify_clock,/* in: modify clock value if mode is 01316 ..._GUESS_ON_CLOCK */ 01317 const char* file, /* in: file name */ 01318 ulint line, /* in: line where called */ 01319 mtr_t* mtr) /* in: mini-transaction */ 01320 { 01321 ibool accessed; 01322 ibool success; 01323 ulint fix_type; 01324 01325 ut_ad(mtr && block); 01326 ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH)); 01327 01328 mutex_enter(&(buf_pool->mutex)); 01329 01330 /* If AWE is used, block may have a different frame now, e.g., NULL */ 01331 01332 if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE) 01333 || UNIV_UNLIKELY(block->frame != guess)) { 01334 exit_func: 01335 mutex_exit(&(buf_pool->mutex)); 01336 01337 return(FALSE); 01338 } 01339 01340 #ifdef UNIV_SYNC_DEBUG 01341 buf_block_buf_fix_inc_debug(block, file, line); 01342 #else 01343 buf_block_buf_fix_inc(block); 01344 #endif 01345 buf_block_make_young(block); 01346 01347 /* Check if this is the first access to the page */ 01348 01349 accessed = block->accessed; 01350 01351 block->accessed = TRUE; 01352 01353 mutex_exit(&(buf_pool->mutex)); 01354 01355 ut_ad(!ibuf_inside() || ibuf_page(block->space, block->offset)); 01356 01357 if (rw_latch == RW_S_LATCH) { 01358 success = rw_lock_s_lock_func_nowait(&(block->lock), 01359 file, line); 01360 fix_type = MTR_MEMO_PAGE_S_FIX; 01361 } else { 01362 success = rw_lock_x_lock_func_nowait(&(block->lock), 01363 file, line); 01364 fix_type = MTR_MEMO_PAGE_X_FIX; 01365 } 01366 01367 if (UNIV_UNLIKELY(!success)) { 01368 mutex_enter(&(buf_pool->mutex)); 01369 01370 block->buf_fix_count--; 01371 #ifdef UNIV_SYNC_DEBUG 01372 rw_lock_s_unlock(&(block->debug_latch)); 01373 #endif 01374 goto exit_func; 01375 } 01376 01377 if (UNIV_UNLIKELY(!UT_DULINT_EQ(modify_clock, block->modify_clock))) { 01378 #ifdef UNIV_SYNC_DEBUG 01379 buf_page_dbg_add_level(block->frame, SYNC_NO_ORDER_CHECK); 01380 #endif /* UNIV_SYNC_DEBUG */ 01381 if (rw_latch == RW_S_LATCH) { 01382 rw_lock_s_unlock(&(block->lock)); 01383 } else { 01384 rw_lock_x_unlock(&(block->lock)); 01385 } 01386 01387 mutex_enter(&(buf_pool->mutex)); 01388 01389 block->buf_fix_count--; 01390 #ifdef UNIV_SYNC_DEBUG 01391 rw_lock_s_unlock(&(block->debug_latch)); 01392 #endif 01393 goto exit_func; 01394 } 01395 01396 mtr_memo_push(mtr, block, fix_type); 01397 01398 #ifdef UNIV_DEBUG 01399 buf_dbg_counter++; 01400 01401 if (buf_dbg_counter % 5771 == 0) { 01402 ut_ad(buf_validate()); 01403 } 01404 #endif 01405 ut_ad(block->buf_fix_count > 0); 01406 ut_ad(block->state == BUF_BLOCK_FILE_PAGE); 01407 01408 #ifdef UNIV_DEBUG_FILE_ACCESSES 01409 ut_a(block->file_page_was_freed == FALSE); 01410 #endif 01411 if (UNIV_UNLIKELY(!accessed)) { 01412 /* In the case of a first access, try to apply linear 01413 read-ahead */ 01414 01415 buf_read_ahead_linear(buf_frame_get_space_id(guess), 01416 buf_frame_get_page_no(guess)); 01417 } 01418 01419 #ifdef UNIV_IBUF_DEBUG 01420 ut_a(ibuf_count_get(block->space, block->offset) == 0); 01421 #endif 01422 buf_pool->n_page_gets++; 01423 01424 return(TRUE); 01425 }
Here is the call graph for this function:

Definition at line 1021 of file buf0buf.c.
References buf_page_peek_block(), FALSE, and TRUE.
Referenced by ibuf_insert_low(), recv_apply_hashed_log_recs(), and recv_read_in_area().
01023 : TRUE if found from page hash table, 01024 NOTE that the page is not necessarily yet read 01025 from disk! */ 01026 ulint space, /* in: space id */ 01027 ulint offset) /* in: page number */ 01028 { 01029 if (buf_page_peek_block(space, offset)) { 01030 01031 return(TRUE); 01032 } 01033 01034 return(FALSE); 01035 }
Here is the call graph for this function:

Here is the caller graph for this function:

| buf_block_t* buf_page_peek_block | ( | ulint | space, | |
| ulint | offset | |||
| ) |
Definition at line 943 of file buf0buf.c.
References yaSSL::block, buf_page_hash_get(), buf_pool, buf_pool_struct::mutex, mutex_enter_fast, and mutex_exit().
Referenced by buf_page_peek().
00945 : control block if found from page hash table, 00946 otherwise NULL; NOTE that the page is not necessarily 00947 yet read from disk! */ 00948 ulint space, /* in: space id */ 00949 ulint offset) /* in: page number */ 00950 { 00951 buf_block_t* block; 00952 00953 mutex_enter_fast(&(buf_pool->mutex)); 00954 00955 block = buf_page_hash_get(space, offset); 00956 00957 mutex_exit(&(buf_pool->mutex)); 00958 00959 return(block); 00960 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 991 of file buf0buf.c.
References yaSSL::block, buf_page_hash_get(), buf_pool, FALSE, buf_pool_struct::mutex, mutex_enter_fast, and mutex_exit().
Referenced by btr_search_drop_page_hash_when_freed().
00993 : TRUE if page hash index is built in search 00994 system */ 00995 ulint space, /* in: space id */ 00996 ulint offset) /* in: page number */ 00997 { 00998 buf_block_t* block; 00999 ibool is_hashed; 01000 01001 mutex_enter_fast(&(buf_pool->mutex)); 01002 01003 block = buf_page_hash_get(space, offset); 01004 01005 if (!block) { 01006 is_hashed = FALSE; 01007 } else { 01008 is_hashed = block->is_hashed; 01009 } 01010 01011 mutex_exit(&(buf_pool->mutex)); 01012 01013 return(is_hashed); 01014 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_page_print | ( | byte * | read_buf | ) |
Definition at line 386 of file buf0buf.c.
References btr_page_get_index_id(), buf_calc_page_new_checksum(), buf_calc_page_old_checksum(), BUF_NO_CHECKSUM_MAGIC, dict_index_find_on_id_low(), dict_index_name_print(), dict_sys, FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, FIL_PAGE_END_LSN_OLD_CHKSUM, fil_page_get_type(), FIL_PAGE_IBUF_BITMAP, FIL_PAGE_IBUF_FREE_LIST, FIL_PAGE_INDEX, FIL_PAGE_INODE, FIL_PAGE_LSN, FIL_PAGE_OFFSET, FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_TYPE_ALLOCATED, FIL_PAGE_TYPE_BLOB, FIL_PAGE_TYPE_FSP_HDR, FIL_PAGE_TYPE_SYS, FIL_PAGE_TYPE_TRX_SYS, FIL_PAGE_TYPE_XDES, index(), mach_read_from_2(), mach_read_from_4(), NULL, srv_use_checksums, TRX_UNDO_INSERT, TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_TYPE, TRX_UNDO_UPDATE, UNIV_PAGE_SIZE, ut_dulint_get_high(), ut_dulint_get_low(), ut_print_buf(), and ut_print_timestamp().
Referenced by btr_index_rec_validate(), btr_page_get_father_for_rec(), btr_page_reorganize_low(), btr_search_validate(), btr_validate_level(), buf_flush_buffered_writes(), buf_page_io_complete(), ibuf_insert_to_index_page(), ibuf_merge_or_delete_for_page(), lock_sec_rec_some_has_impl_off_kernel(), os_file_check_page_trailers(), page_check_dir(), page_copy_rec_list_end_no_locks(), page_cur_parse_insert_rec(), page_dir_find_owner_slot(), page_validate(), row_search_for_mysql(), and trx_sys_doublewrite_init_or_restore_pages().
00388 : a database page */ 00389 { 00390 dict_index_t* index; 00391 ulint checksum; 00392 ulint old_checksum; 00393 00394 ut_print_timestamp(stderr); 00395 fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", 00396 (ulint)UNIV_PAGE_SIZE); 00397 ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE); 00398 fputs("InnoDB: End of page dump\n", stderr); 00399 00400 checksum = srv_use_checksums ? 00401 buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; 00402 old_checksum = srv_use_checksums ? 00403 buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; 00404 00405 ut_print_timestamp(stderr); 00406 fprintf(stderr, 00407 " InnoDB: Page checksum %lu, prior-to-4.0.14-form checksum %lu\n" 00408 "InnoDB: stored checksum %lu, prior-to-4.0.14-form stored checksum %lu\n", 00409 (ulong) checksum, (ulong) old_checksum, 00410 (ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM), 00411 (ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE 00412 - FIL_PAGE_END_LSN_OLD_CHKSUM)); 00413 fprintf(stderr, 00414 "InnoDB: Page lsn %lu %lu, low 4 bytes of lsn at page end %lu\n" 00415 "InnoDB: Page number (if stored to page already) %lu,\n" 00416 "InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) %lu\n", 00417 (ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN), 00418 (ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN + 4), 00419 (ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE 00420 - FIL_PAGE_END_LSN_OLD_CHKSUM + 4), 00421 (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), 00422 (ulong) mach_read_from_4(read_buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)); 00423 00424 if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE) 00425 == TRX_UNDO_INSERT) { 00426 fprintf(stderr, 00427 "InnoDB: Page may be an insert undo log page\n"); 00428 } else if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR 00429 + TRX_UNDO_PAGE_TYPE) 00430 == TRX_UNDO_UPDATE) { 00431 fprintf(stderr, 00432 "InnoDB: Page may be an update undo log page\n"); 00433 } 00434 00435 switch (fil_page_get_type(read_buf)) { 00436 case FIL_PAGE_INDEX: 00437 fprintf(stderr, 00438 "InnoDB: Page may be an index page where index id is %lu %lu\n", 00439 (ulong) ut_dulint_get_high(btr_page_get_index_id(read_buf)), 00440 (ulong) ut_dulint_get_low(btr_page_get_index_id(read_buf))); 00441 00442 /* If the code is in ibbackup, dict_sys may be uninitialized, 00443 i.e., NULL */ 00444 00445 if (dict_sys != NULL) { 00446 00447 index = dict_index_find_on_id_low( 00448 btr_page_get_index_id(read_buf)); 00449 if (index) { 00450 fputs("InnoDB: (", stderr); 00451 dict_index_name_print(stderr, NULL, index); 00452 fputs(")\n", stderr); 00453 } 00454 } 00455 break; 00456 case FIL_PAGE_INODE: 00457 fputs("InnoDB: Page may be an 'inode' page\n", stderr); 00458 break; 00459 case FIL_PAGE_IBUF_FREE_LIST: 00460 fputs("InnoDB: Page may be an insert buffer free list page\n", 00461 stderr); 00462 break; 00463 case FIL_PAGE_TYPE_ALLOCATED: 00464 fputs("InnoDB: Page may be a freshly allocated page\n", 00465 stderr); 00466 break; 00467 case FIL_PAGE_IBUF_BITMAP: 00468 fputs("InnoDB: Page may be an insert buffer bitmap page\n", 00469 stderr); 00470 break; 00471 case FIL_PAGE_TYPE_SYS: 00472 fputs("InnoDB: Page may be a system page\n", 00473 stderr); 00474 break; 00475 case FIL_PAGE_TYPE_TRX_SYS: 00476 fputs("InnoDB: Page may be a transaction system page\n", 00477 stderr); 00478 break; 00479 case FIL_PAGE_TYPE_FSP_HDR: 00480 fputs("InnoDB: Page may be a file space header page\n", 00481 stderr); 00482 break; 00483 case FIL_PAGE_TYPE_XDES: 00484 fputs("InnoDB: Page may be an extent descriptor page\n", 00485 stderr); 00486 break; 00487 case FIL_PAGE_TYPE_BLOB: 00488 fputs("InnoDB: Page may be a BLOB page\n", 00489 stderr); 00490 break; 00491 } 00492 }
Here is the call graph for this function:

Here is the caller graph for this function:

| buf_block_t* buf_page_reset_file_page_was_freed | ( | ulint | space, | |
| ulint | offset | |||
| ) |
Definition at line 1073 of file buf0buf.c.
References yaSSL::block, buf_page_hash_get(), buf_pool, FALSE, buf_pool_struct::mutex, mutex_enter_fast, and mutex_exit().
Referenced by ibuf_remove_free_page().
01075 : control block if found from page hash table, 01076 otherwise NULL */ 01077 ulint space, /* in: space id */ 01078 ulint offset) /* in: page number */ 01079 { 01080 buf_block_t* block; 01081 01082 mutex_enter_fast(&(buf_pool->mutex)); 01083 01084 block = buf_page_hash_get(space, offset); 01085 01086 if (block) { 01087 block->file_page_was_freed = FALSE; 01088 } 01089 01090 mutex_exit(&(buf_pool->mutex)); 01091 01092 return(block); 01093 }
Here is the call graph for this function:

Here is the caller graph for this function:

| buf_block_t* buf_page_set_file_page_was_freed | ( | ulint | space, | |
| ulint | offset | |||
| ) |
Definition at line 1044 of file buf0buf.c.
References yaSSL::block, buf_page_hash_get(), buf_pool, buf_pool_struct::mutex, mutex_enter_fast, mutex_exit(), and TRUE.
Referenced by fseg_free_extent(), fseg_free_page(), and ibuf_remove_free_page().
01046 : control block if found from page hash table, 01047 otherwise NULL */ 01048 ulint space, /* in: space id */ 01049 ulint offset) /* in: page number */ 01050 { 01051 buf_block_t* block; 01052 01053 mutex_enter_fast(&(buf_pool->mutex)); 01054 01055 block = buf_page_hash_get(space, offset); 01056 01057 if (block) { 01058 block->file_page_was_freed = TRUE; 01059 } 01060 01061 mutex_exit(&(buf_pool->mutex)); 01062 01063 return(block); 01064 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ibool buf_pool_check_no_pending_io | ( | void | ) |
Definition at line 2434 of file buf0buf.c.
References BUF_FLUSH_LIST, BUF_FLUSH_LRU, BUF_FLUSH_SINGLE_PAGE, buf_pool, FALSE, buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_flush, buf_pool_struct::n_pend_reads, and TRUE.
Referenced by logs_empty_and_mark_files_at_shutdown().
02436 : TRUE if there is no pending i/o */ 02437 { 02438 ibool ret; 02439 02440 mutex_enter(&(buf_pool->mutex)); 02441 02442 if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU] 02443 + buf_pool->n_flush[BUF_FLUSH_LIST] 02444 + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) { 02445 ret = FALSE; 02446 } else { 02447 ret = TRUE; 02448 } 02449 02450 mutex_exit(&(buf_pool->mutex)); 02451 02452 return(ret); 02453 }
Here is the call graph for this function:

Here is the caller graph for this function:

| buf_pool_t* buf_pool_init | ( | ulint | max_size, | |
| ulint | curr_size, | |||
| ulint | n_frames | |||
| ) |
Definition at line 539 of file buf0buf.c.
References buf_pool_struct::awe_info, yaSSL::block, buf_pool_struct::blocks, buf_pool_struct::blocks_of_frames, buf_block_init(), BUF_FLUSH_LIST, BUF_FLUSH_LRU, buf_pool, buf_pool_get_nth_block(), buf_pool_struct::curr_size, FALSE, buf_pool_struct::frame_mem, buf_pool_struct::frame_zero, free, buf_pool_struct::freed_page_clock, hash_create(), buf_pool_struct::high_end, buf_pool_struct::init_flush, buf_pool_struct::last_printout_time, buf_pool_struct::LRU_flush_ended, buf_pool_struct::LRU_old, buf_pool_struct::max_size, mem_alloc, memset, buf_pool_struct::mutex, mutex_create, mutex_enter, buf_pool_struct::n_flush, buf_pool_struct::n_frames, buf_pool_struct::n_page_gets, buf_pool_struct::n_page_gets_old, buf_pool_struct::n_pages_awe_remapped, buf_pool_struct::n_pages_awe_remapped_old, buf_pool_struct::n_pages_created, buf_pool_struct::n_pages_created_old, buf_pool_struct::n_pages_read, buf_pool_struct::n_pages_read_old, buf_pool_struct::n_pages_written, buf_pool_struct::n_pages_written_old, buf_pool_struct::n_pend_reads, buf_pool_struct::no_flush, NULL, os_awe_allocate_physical_mem(), os_awe_allocate_virtual_mem_window(), os_awe_map_physical_mem_to_window(), OS_AWE_X86_PAGE_SIZE, os_event_create(), os_mem_alloc_large(), buf_pool_struct::page_hash, srv_use_awe, SYNC_BUF_POOL, TRUE, buf_pool_struct::ulint_clock, UNIV_PAGE_SIZE, ut_a, ut_align(), UT_LIST_ADD_LAST, UT_LIST_INIT, and ut_malloc().
Referenced by innobase_start_or_create_for_mysql().
00541 : buf_pool object, NULL if not 00542 enough memory or error */ 00543 ulint max_size, /* in: maximum size of the buf_pool in 00544 blocks */ 00545 ulint curr_size, /* in: current size to use, must be <= 00546 max_size, currently must be equal to 00547 max_size */ 00548 ulint n_frames) /* in: number of frames; if AWE is used, 00549 this is the size of the address space window 00550 where physical memory pages are mapped; if 00551 AWE is not used then this must be the same 00552 as max_size */ 00553 { 00554 byte* frame; 00555 ulint i; 00556 buf_block_t* block; 00557 00558 ut_a(max_size == curr_size); 00559 ut_a(srv_use_awe || n_frames == max_size); 00560 00561 if (n_frames > curr_size) { 00562 fprintf(stderr, 00563 "InnoDB: AWE: Error: you must specify in my.cnf .._awe_mem_mb larger\n" 00564 "InnoDB: than .._buffer_pool_size. Now the former is %lu pages,\n" 00565 "InnoDB: the latter %lu pages.\n", (ulong) curr_size, (ulong) n_frames); 00566 00567 return(NULL); 00568 } 00569 00570 buf_pool = mem_alloc(sizeof(buf_pool_t)); 00571 00572 /* 1. Initialize general fields 00573 ---------------------------- */ 00574 mutex_create(&buf_pool->mutex, SYNC_BUF_POOL); 00575 00576 mutex_enter(&(buf_pool->mutex)); 00577 00578 if (srv_use_awe) { 00579 /*----------------------------------------*/ 00580 /* Allocate the virtual address space window, i.e., the 00581 buffer pool frames */ 00582 00583 buf_pool->frame_mem = os_awe_allocate_virtual_mem_window( 00584 UNIV_PAGE_SIZE * (n_frames + 1)); 00585 00586 /* Allocate the physical memory for AWE and the AWE info array 00587 for buf_pool */ 00588 00589 if ((curr_size % ((1024 * 1024) / UNIV_PAGE_SIZE)) != 0) { 00590 00591 fprintf(stderr, 00592 "InnoDB: AWE: Error: physical memory must be allocated in full megabytes.\n" 00593 "InnoDB: Trying to allocate %lu database pages.\n", 00594 (ulong) curr_size); 00595 00596 return(NULL); 00597 } 00598 00599 if (!os_awe_allocate_physical_mem(&(buf_pool->awe_info), 00600 curr_size / ((1024 * 1024) / UNIV_PAGE_SIZE))) { 00601 00602 return(NULL); 00603 } 00604 /*----------------------------------------*/ 00605 } else { 00606 buf_pool->frame_mem = os_mem_alloc_large( 00607 UNIV_PAGE_SIZE * (n_frames + 1), 00608 TRUE, FALSE); 00609 } 00610 00611 if (buf_pool->frame_mem == NULL) { 00612 00613 return(NULL); 00614 } 00615 00616 buf_pool->blocks = ut_malloc(sizeof(buf_block_t) * max_size); 00617 00618 if (buf_pool->blocks == NULL) { 00619 00620 return(NULL); 00621 } 00622 00623 buf_pool->max_size = max_size; 00624 buf_pool->curr_size = curr_size; 00625 00626 buf_pool->n_frames = n_frames; 00627 00628 /* Align pointer to the first frame */ 00629 00630 frame = ut_align(buf_pool->frame_mem, UNIV_PAGE_SIZE); 00631 00632 buf_pool->frame_zero = frame; 00633 buf_pool->high_end = frame + UNIV_PAGE_SIZE * n_frames; 00634 00635 if (srv_use_awe) { 00636 /*----------------------------------------*/ 00637 /* Map an initial part of the allocated physical memory to 00638 the window */ 00639 00640 os_awe_map_physical_mem_to_window(buf_pool->frame_zero, 00641 n_frames * 00642 (UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE), 00643 buf_pool->awe_info); 00644 /*----------------------------------------*/ 00645 } 00646 00647 buf_pool->blocks_of_frames = ut_malloc(sizeof(void*) * n_frames); 00648 00649 if (buf_pool->blocks_of_frames == NULL) { 00650 00651 return(NULL); 00652 } 00653 00654 /* Init block structs and assign frames for them; in the case of 00655 AWE there are less frames than blocks. Then we assign the frames 00656 to the first blocks (we already mapped the memory above). We also 00657 init the awe_info for every block. */ 00658 00659 for (i = 0; i < max_size; i++) { 00660 00661 block = buf_pool_get_nth_block(buf_pool, i); 00662 00663 if (i < n_frames) { 00664 frame = buf_pool->frame_zero + i * UNIV_PAGE_SIZE; 00665 *(buf_pool->blocks_of_frames + i) = block; 00666 } else { 00667 frame = NULL; 00668 } 00669 00670 buf_block_init(block, frame); 00671 00672 if (srv_use_awe) { 00673 /*----------------------------------------*/ 00674 block->awe_info = buf_pool->awe_info 00675 + i * (UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE); 00676 /*----------------------------------------*/ 00677 } 00678 } 00679 00680 buf_pool->page_hash = hash_create(2 * max_size); 00681 00682 buf_pool->n_pend_reads = 0; 00683 00684 buf_pool->last_printout_time = time(NULL); 00685 00686 buf_pool->n_pages_read = 0; 00687 buf_pool->n_pages_written = 0; 00688 buf_pool->n_pages_created = 0; 00689 buf_pool->n_pages_awe_remapped = 0; 00690 00691 buf_pool->n_page_gets = 0; 00692 buf_pool->n_page_gets_old = 0; 00693 buf_pool->n_pages_read_old = 0; 00694 buf_pool->n_pages_written_old = 0; 00695 buf_pool->n_pages_created_old = 0; 00696 buf_pool->n_pages_awe_remapped_old = 0; 00697 00698 /* 2. Initialize flushing fields 00699 ---------------------------- */ 00700 UT_LIST_INIT(buf_pool->flush_list); 00701 00702 for (i = BUF_FLUSH_LRU; i <= BUF_FLUSH_LIST; i++) { 00703 buf_pool->n_flush[i] = 0; 00704 buf_pool->init_flush[i] = FALSE; 00705 buf_pool->no_flush[i] = os_event_create(NULL); 00706 } 00707 00708 buf_pool->LRU_flush_ended = 0; 00709 00710 buf_pool->ulint_clock = 1; 00711 buf_pool->freed_page_clock = 0; 00712 00713 /* 3. Initialize LRU fields 00714 ---------------------------- */ 00715 UT_LIST_INIT(buf_pool->LRU); 00716 00717 buf_pool->LRU_old = NULL; 00718 00719 UT_LIST_INIT(buf_pool->awe_LRU_free_mapped); 00720 00721 /* Add control blocks to the free list */ 00722 UT_LIST_INIT(buf_pool->free); 00723 00724 for (i = 0; i < curr_size; i++) { 00725 00726 block = buf_pool_get_nth_block(buf_pool, i); 00727 00728 if (block->frame) { 00729 /* Wipe contents of frame to eliminate a Purify 00730 warning */ 00731 00732 #ifdef HAVE_purify 00733 memset(block->frame, '\0', UNIV_PAGE_SIZE); 00734 #endif 00735 if (srv_use_awe) { 00736 /* Add to the list of blocks mapped to 00737 frames */ 00738 00739 UT_LIST_ADD_LAST(awe_LRU_free_mapped, 00740 buf_pool->awe_LRU_free_mapped, block); 00741 } 00742 } 00743 00744 UT_LIST_ADD_LAST(free, buf_pool->free, block); 00745 block->in_free_list = TRUE; 00746 } 00747 00748 mutex_exit(&(buf_pool->mutex)); 00749 00750 if (srv_use_adaptive_hash_indexes) { 00751 btr_search_sys_create( 00752 curr_size * UNIV_PAGE_SIZE / sizeof(void*) / 64); 00753 } else { 00754 /* Create only a small dummy system */ 00755 btr_search_sys_create(1000); 00756 } 00757 00758 return(buf_pool); 00759 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_pool_invalidate | ( | void | ) |
Definition at line 2011 of file buf0buf.c.
References buf_all_freed(), buf_LRU_search_and_free_block(), buf_pool, buf_pool_struct::mutex, mutex_enter, mutex_exit(), TRUE, ut_ad, and UT_LIST_GET_LEN.
Referenced by recv_apply_hashed_log_recs().
02013 { 02014 ibool freed; 02015 02016 ut_ad(buf_all_freed()); 02017 02018 freed = TRUE; 02019 02020 while (freed) { 02021 freed = buf_LRU_search_and_free_block(100); 02022 } 02023 02024 mutex_enter(&(buf_pool->mutex)); 02025 02026 ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0); 02027 02028 mutex_exit(&(buf_pool->mutex)); 02029 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_print_io | ( | FILE * | file | ) |
Definition at line 2295 of file buf0buf.c.
References BUF_FLUSH_LIST, BUF_FLUSH_LRU, BUF_FLUSH_SINGLE_PAGE, buf_pool, buf_pool_struct::curr_size, current_time(), buf_pool_struct::init_flush, buf_pool_struct::last_printout_time, buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_flush, buf_pool_struct::n_frames, buf_pool_struct::n_page_gets, buf_pool_struct::n_page_gets_old, buf_pool_struct::n_pages_awe_remapped, buf_pool_struct::n_pages_awe_remapped_old, buf_pool_struct::n_pages_created, buf_pool_struct::n_pages_created_old, buf_pool_struct::n_pages_read, buf_pool_struct::n_pages_read_old, buf_pool_struct::n_pages_written, buf_pool_struct::n_pages_written_old, buf_pool_struct::n_pend_reads, NULL, srv_use_awe, ut_ad, and UT_LIST_GET_LEN.
Referenced by srv_printf_innodb_monitor().
02297 : buffer where to print */ 02298 { 02299 time_t current_time; 02300 double time_elapsed; 02301 ulint size; 02302 02303 ut_ad(buf_pool); 02304 size = buf_pool->curr_size; 02305 02306 mutex_enter(&(buf_pool->mutex)); 02307 02308 if (srv_use_awe) { 02309 fprintf(stderr, 02310 "AWE: Buffer pool memory frames %lu\n", 02311 (ulong) buf_pool->n_frames); 02312 02313 fprintf(stderr, 02314 "AWE: Database pages and free buffers mapped in frames %lu\n", 02315 (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); 02316 } 02317 fprintf(file, 02318 "Buffer pool size %lu\n" 02319 "Free buffers %lu\n" 02320 "Database pages %lu\n" 02321 "Modified db pages %lu\n" 02322 "Pending reads %lu\n" 02323 "Pending writes: LRU %lu, flush list %lu, single page %lu\n", 02324 (ulong) size, 02325 (ulong) UT_LIST_GET_LEN(buf_pool->free), 02326 (ulong) UT_LIST_GET_LEN(buf_pool->LRU), 02327 (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), 02328 (ulong) buf_pool->n_pend_reads, 02329 (ulong) buf_pool->n_flush[BUF_FLUSH_LRU] 02330 + buf_pool->init_flush[BUF_FLUSH_LRU], 02331 (ulong) buf_pool->n_flush[BUF_FLUSH_LIST] 02332 + buf_pool->init_flush[BUF_FLUSH_LIST], 02333 (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); 02334 02335 current_time = time(NULL); 02336 time_elapsed = 0.001 + difftime(current_time, 02337 buf_pool->last_printout_time); 02338 buf_pool->last_printout_time = current_time; 02339 02340 fprintf(file, 02341 "Pages read %lu, created %lu, written %lu\n" 02342 "%.2f reads/s, %.2f creates/s, %.2f writes/s\n", 02343 (ulong) buf_pool->n_pages_read, 02344 (ulong) buf_pool->n_pages_created, 02345 (ulong) buf_pool->n_pages_written, 02346 (buf_pool->n_pages_read - buf_pool->n_pages_read_old) 02347 / time_elapsed, 02348 (buf_pool->n_pages_created - buf_pool->n_pages_created_old) 02349 / time_elapsed, 02350 (buf_pool->n_pages_written - buf_pool->n_pages_written_old) 02351 / time_elapsed); 02352 02353 if (srv_use_awe) { 02354 fprintf(file, "AWE: %.2f page remaps/s\n", 02355 (buf_pool->n_pages_awe_remapped 02356 - buf_pool->n_pages_awe_remapped_old) 02357 / time_elapsed); 02358 } 02359 02360 if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) { 02361 fprintf(file, "Buffer pool hit rate %lu / 1000\n", 02362 (ulong) (1000 - 02363 ((1000 * (buf_pool->n_pages_read - buf_pool->n_pages_read_old)) 02364 / (buf_pool->n_page_gets - buf_pool->n_page_gets_old)))); 02365 } else { 02366 fputs("No buffer pool page gets since the last printout\n", 02367 file); 02368 } 02369 02370 buf_pool->n_page_gets_old = buf_pool->n_page_gets; 02371 buf_pool->n_pages_read_old = buf_pool->n_pages_read; 02372 buf_pool->n_pages_created_old = buf_pool->n_pages_created; 02373 buf_pool->n_pages_written_old = buf_pool->n_pages_written; 02374 buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped; 02375 02376 mutex_exit(&(buf_pool->mutex)); 02377 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_refresh_io_stats | ( | void | ) |
Definition at line 2383 of file buf0buf.c.
References buf_pool, buf_pool_struct::last_printout_time, buf_pool_struct::n_page_gets, buf_pool_struct::n_page_gets_old, buf_pool_struct::n_pages_awe_remapped, buf_pool_struct::n_pages_awe_remapped_old, buf_pool_struct::n_pages_created, buf_pool_struct::n_pages_created_old, buf_pool_struct::n_pages_read, buf_pool_struct::n_pages_read_old, buf_pool_struct::n_pages_written, buf_pool_struct::n_pages_written_old, and NULL.
Referenced by srv_refresh_innodb_monitor_stats().
02385 { 02386 buf_pool->last_printout_time = time(NULL); 02387 buf_pool->n_page_gets_old = buf_pool->n_page_gets; 02388 buf_pool->n_pages_read_old = buf_pool->n_pages_read; 02389 buf_pool->n_pages_created_old = buf_pool->n_pages_created; 02390 buf_pool->n_pages_written_old = buf_pool->n_pages_written; 02391 buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped; 02392 }
Here is the caller graph for this function:

Definition at line 967 of file buf0buf.c.
References yaSSL::block, buf_page_hash_get(), buf_pool, FALSE, buf_pool_struct::mutex, mutex_enter_fast, and mutex_exit().
Referenced by fseg_alloc_free_page_low().
00969 : space id */ 00970 ulint offset) /* in: page number */ 00971 { 00972 buf_block_t* block; 00973 00974 mutex_enter_fast(&(buf_pool->mutex)); 00975 00976 block = buf_page_hash_get(space, offset); 00977 00978 if (block) { 00979 block->check_index_page_at_flush = FALSE; 00980 } 00981 00982 mutex_exit(&(buf_pool->mutex)); 00983 }
Here is the call graph for this function:

Here is the caller graph for this function:

| buf_pool_t* buf_pool = NULL |
Definition at line 224 of file buf0buf.c.
Referenced by btr_search_guess_on_hash(), buf_all_freed(), buf_awe_map_page_to_frame(), buf_block_free(), buf_block_make_young(), buf_flush_batch(), buf_flush_insert_into_flush_list(), buf_flush_insert_sorted_into_flush_list(), buf_flush_LRU_recommendation(), buf_flush_ready_for_flush(), buf_flush_ready_for_replace(), buf_flush_try_neighbors(), buf_flush_try_page(), buf_flush_validate(), buf_flush_validate_low(), buf_flush_wait_batch_end(), buf_flush_write_complete(), buf_get_free_list_len(), buf_get_latched_pages_number(), buf_get_modified_ratio_pct(), buf_get_n_pending_ios(), buf_LRU_add_block_low(), buf_LRU_add_block_to_end_low(), buf_LRU_block_free_hashed_page(), buf_LRU_block_free_non_file_page(), buf_LRU_block_remove_hashed_page(), buf_LRU_buf_pool_running_out(), buf_LRU_get_free_block(), buf_LRU_get_recent_limit(), buf_LRU_invalidate_tablespace(), buf_LRU_old_adjust_len(), buf_LRU_old_init(), buf_LRU_remove_block(), buf_LRU_search_and_free_block(), buf_LRU_try_free_flushed_blocks(), buf_page_create(), buf_page_get_gen(), buf_page_get_known_nowait(), buf_page_init(), buf_page_init_for_read(), buf_page_io_complete(), buf_page_make_young(), buf_page_optimistic_get_func(), buf_page_peek_block(), buf_page_peek_if_search_hashed(), buf_page_reset_file_page_was_freed(), buf_page_set_file_page_was_freed(), buf_pool_check_no_pending_io(), buf_pool_init(), buf_pool_invalidate(), buf_print_io(), buf_read_ahead_linear(), buf_read_ahead_random(), buf_read_ibuf_merge_pages(), buf_read_recv_pages(), buf_refresh_io_stats(), buf_reset_check_index_page_at_flush(), ibuf_get_merge_page_nos(), log_check_log_recs(), mlog_write_dulint(), mlog_write_initial_log_record(), mlog_write_string(), mlog_write_ulint(), recv_group_scan_log_recs(), row_search_for_mysql(), srv_export_innodb_status(), and srv_master_thread().
1.4.7

