#include "univ.i"#include "buf0types.h"#include "ut0byte.h"#include "mtr0types.h"Include dependency graph for buf0flu.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | BUF_FLUSH_FREE_BLOCK_MARGIN (5 + BUF_READ_AHEAD_AREA) |
| #define | BUF_FLUSH_EXTRA_MARGIN (BUF_FLUSH_FREE_BLOCK_MARGIN / 4 + 100) |
Functions | |
| void | buf_flush_write_complete (buf_block_t *block) |
| void | buf_flush_free_margin (void) |
| void | buf_flush_init_for_writing (byte *page, dulint newest_lsn, ulint space, ulint page_no) |
| ulint | buf_flush_batch (ulint flush_type, ulint min_n, dulint lsn_limit) |
| void | buf_flush_wait_batch_end (ulint type) |
| UNIV_INLINE void | buf_flush_note_modification (buf_block_t *block, mtr_t *mtr) |
| UNIV_INLINE void | buf_flush_recv_note_modification (buf_block_t *block, dulint start_lsn, dulint end_lsn) |
| ibool | buf_flush_ready_for_replace (buf_block_t *block) |
| ibool | buf_flush_validate (void) |
| #define BUF_FLUSH_EXTRA_MARGIN (BUF_FLUSH_FREE_BLOCK_MARGIN / 4 + 100) |
| #define BUF_FLUSH_FREE_BLOCK_MARGIN (5 + BUF_READ_AHEAD_AREA) |
Definition at line 785 of file buf0flu.c.
References yaSSL::block, BUF_BLOCK_FILE_PAGE, buf_flush_buffered_writes(), BUF_FLUSH_LIST, BUF_FLUSH_LRU, buf_flush_ready_for_flush(), buf_flush_try_neighbors(), buf_pool, FALSE, buf_pool_struct::init_flush, buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_flush, buf_pool_struct::no_flush, NULL, offset, os_event_set(), srv_buf_pool_flushed, sync_thread_levels_empty_gen(), TRUE, ut_a, ut_ad, ut_dulint_cmp(), UT_LIST_GET_LAST, and UT_LIST_GET_PREV.
Referenced by buf_flush_free_margin(), log_preflush_pool_modified_pages(), recv_apply_hashed_log_recs(), and srv_master_thread().
00787 : number of blocks for which the write 00788 request was queued; ULINT_UNDEFINED if there 00789 was a flush of the same type already running */ 00790 ulint flush_type, /* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST; if 00791 BUF_FLUSH_LIST, then the caller must not own 00792 any latches on pages */ 00793 ulint min_n, /* in: wished minimum mumber of blocks flushed 00794 (it is not guaranteed that the actual number 00795 is that big, though) */ 00796 dulint lsn_limit) /* in the case BUF_FLUSH_LIST all blocks whose 00797 oldest_modification is smaller than this 00798 should be flushed (if their number does not 00799 exceed min_n), otherwise ignored */ 00800 { 00801 buf_block_t* block; 00802 ulint page_count = 0; 00803 ulint old_page_count; 00804 ulint space; 00805 ulint offset; 00806 ibool found; 00807 00808 ut_ad((flush_type == BUF_FLUSH_LRU) 00809 || (flush_type == BUF_FLUSH_LIST)); 00810 ut_ad((flush_type != BUF_FLUSH_LIST) 00811 || sync_thread_levels_empty_gen(TRUE)); 00812 mutex_enter(&(buf_pool->mutex)); 00813 00814 if ((buf_pool->n_flush[flush_type] > 0) 00815 || (buf_pool->init_flush[flush_type] == TRUE)) { 00816 00817 /* There is already a flush batch of the same type running */ 00818 00819 mutex_exit(&(buf_pool->mutex)); 00820 00821 return(ULINT_UNDEFINED); 00822 } 00823 00824 (buf_pool->init_flush)[flush_type] = TRUE; 00825 00826 for (;;) { 00827 /* If we have flushed enough, leave the loop */ 00828 if (page_count >= min_n) { 00829 00830 break; 00831 } 00832 00833 /* Start from the end of the list looking for a suitable 00834 block to be flushed. */ 00835 00836 if (flush_type == BUF_FLUSH_LRU) { 00837 block = UT_LIST_GET_LAST(buf_pool->LRU); 00838 } else { 00839 ut_ad(flush_type == BUF_FLUSH_LIST); 00840 00841 block = UT_LIST_GET_LAST(buf_pool->flush_list); 00842 if (!block 00843 || (ut_dulint_cmp(block->oldest_modification, 00844 lsn_limit) >= 0)) { 00845 /* We have flushed enough */ 00846 00847 break; 00848 } 00849 } 00850 00851 found = FALSE; 00852 00853 /* Note that after finding a single flushable page, we try to 00854 flush also all its neighbors, and after that start from the 00855 END of the LRU list or flush list again: the list may change 00856 during the flushing and we cannot safely preserve within this 00857 function a pointer to a block in the list! */ 00858 00859 while ((block != NULL) && !found) { 00860 ut_a(block->state == BUF_BLOCK_FILE_PAGE); 00861 00862 if (buf_flush_ready_for_flush(block, flush_type)) { 00863 00864 found = TRUE; 00865 space = block->space; 00866 offset = block->offset; 00867 00868 mutex_exit(&(buf_pool->mutex)); 00869 00870 old_page_count = page_count; 00871 00872 /* Try to flush also all the neighbors */ 00873 page_count += 00874 buf_flush_try_neighbors(space, offset, 00875 flush_type); 00876 /* fprintf(stderr, 00877 "Flush type %lu, page no %lu, neighb %lu\n", 00878 flush_type, offset, 00879 page_count - old_page_count); */ 00880 00881 mutex_enter(&(buf_pool->mutex)); 00882 00883 } else if (flush_type == BUF_FLUSH_LRU) { 00884 00885 block = UT_LIST_GET_PREV(LRU, block); 00886 } else { 00887 ut_ad(flush_type == BUF_FLUSH_LIST); 00888 00889 block = UT_LIST_GET_PREV(flush_list, block); 00890 } 00891 } 00892 00893 /* If we could not find anything to flush, leave the loop */ 00894 00895 if (!found) { 00896 break; 00897 } 00898 } 00899 00900 (buf_pool->init_flush)[flush_type] = FALSE; 00901 00902 if ((buf_pool->n_flush[flush_type] == 0) 00903 && (buf_pool->init_flush[flush_type] == FALSE)) { 00904 00905 /* The running flush batch has ended */ 00906 00907 os_event_set(buf_pool->no_flush[flush_type]); 00908 } 00909 00910 mutex_exit(&(buf_pool->mutex)); 00911 00912 buf_flush_buffered_writes(); 00913 00914 #ifdef UNIV_DEBUG 00915 if (buf_debug_prints && page_count > 0) { 00916 ut_a(flush_type == BUF_FLUSH_LRU 00917 || flush_type == BUF_FLUSH_LIST); 00918 fprintf(stderr, flush_type == BUF_FLUSH_LRU 00919 ? "Flushed %lu pages in LRU flush\n" 00920 : "Flushed %lu pages in flush list flush\n", 00921 (ulong) page_count); 00922 } 00923 #endif /* UNIV_DEBUG */ 00924 00925 if (page_count != ULINT_UNDEFINED) 00926 srv_buf_pool_flushed+= page_count; 00927 00928 return(page_count); 00929 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_flush_free_margin | ( | void | ) |
Definition at line 998 of file buf0flu.c.
References buf_flush_batch(), BUF_FLUSH_LRU, buf_flush_LRU_recommendation(), buf_flush_wait_batch_end(), and ut_dulint_zero.
Referenced by buf_LRU_get_free_block(), buf_page_create(), buf_read_ibuf_merge_pages(), and buf_read_page().
01000 { 01001 ulint n_to_flush; 01002 ulint n_flushed; 01003 01004 n_to_flush = buf_flush_LRU_recommendation(); 01005 01006 if (n_to_flush > 0) { 01007 n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush, 01008 ut_dulint_zero); 01009 if (n_flushed == ULINT_UNDEFINED) { 01010 /* There was an LRU type flush batch already running; 01011 let us wait for it to end */ 01012 01013 buf_flush_wait_batch_end(BUF_FLUSH_LRU); 01014 } 01015 } 01016 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 440 of file buf0flu.c.
References buf_calc_page_new_checksum(), buf_calc_page_old_checksum(), BUF_NO_CHECKSUM_MAGIC, FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, FIL_PAGE_END_LSN_OLD_CHKSUM, FIL_PAGE_LSN, FIL_PAGE_OFFSET, FIL_PAGE_SPACE_OR_CHKSUM, mach_write_to_4(), mach_write_to_8(), and srv_use_checksums.
Referenced by buf_flush_write_block_low(), fil_create_new_single_table_tablespace(), fil_reset_too_high_lsns(), and recv_apply_log_recs_for_backup().
00442 : page */ 00443 dulint newest_lsn, /* in: newest modification lsn to the page */ 00444 ulint space, /* in: space id */ 00445 ulint page_no) /* in: page number */ 00446 { 00447 /* Write the newest modification lsn to the page header and trailer */ 00448 mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); 00449 00450 mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, 00451 newest_lsn); 00452 /* Write the page number and the space id */ 00453 00454 mach_write_to_4(page + FIL_PAGE_OFFSET, page_no); 00455 mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space); 00456 00457 /* Store the new formula checksum */ 00458 00459 mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, 00460 srv_use_checksums ? 00461 buf_calc_page_new_checksum(page) : BUF_NO_CHECKSUM_MAGIC); 00462 00463 /* We overwrite the first 4 bytes of the end lsn field to store 00464 the old formula checksum. Since it depends also on the field 00465 FIL_PAGE_SPACE_OR_CHKSUM, it has to be calculated after storing the 00466 new formula checksum. */ 00467 00468 mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, 00469 srv_use_checksums ? 00470 buf_calc_page_old_checksum(page) : BUF_NO_CHECKSUM_MAGIC); 00471 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE void buf_flush_note_modification | ( | buf_block_t * | block, | |
| mtr_t * | mtr | |||
| ) |
| ibool buf_flush_ready_for_replace | ( | buf_block_t * | block | ) |
Definition at line 109 of file buf0flu.c.
References yaSSL::block, BUF_BLOCK_FILE_PAGE, buf_pool, FALSE, buf_pool_struct::mutex, TRUE, ut_ad, ut_dulint_cmp(), ut_dulint_zero, ut_print_buf(), and ut_print_timestamp().
Referenced by buf_all_freed(), buf_flush_LRU_recommendation(), and buf_LRU_search_and_free_block().
00111 : TRUE if can replace immediately */ 00112 buf_block_t* block) /* in: buffer control block, must be in state 00113 BUF_BLOCK_FILE_PAGE and in the LRU list */ 00114 { 00115 #ifdef UNIV_SYNC_DEBUG 00116 ut_ad(mutex_own(&(buf_pool->mutex))); 00117 #endif /* UNIV_SYNC_DEBUG */ 00118 if (block->state != BUF_BLOCK_FILE_PAGE) { 00119 ut_print_timestamp(stderr); 00120 fprintf(stderr, 00121 " InnoDB: Error: buffer block state %lu in the LRU list!\n", 00122 (ulong)block->state); 00123 ut_print_buf(stderr, block, sizeof(buf_block_t)); 00124 00125 return(FALSE); 00126 } 00127 00128 if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0) 00129 || (block->buf_fix_count != 0) 00130 || (block->io_fix != 0)) { 00131 00132 return(FALSE); 00133 } 00134 00135 return(TRUE); 00136 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE void buf_flush_recv_note_modification | ( | buf_block_t * | block, | |
| dulint | start_lsn, | |||
| dulint | end_lsn | |||
| ) |
| ibool buf_flush_validate | ( | void | ) |
Definition at line 1053 of file buf0flu.c.
References buf_flush_validate_low(), buf_pool, buf_pool_struct::mutex, mutex_enter, and mutex_exit().
01055 : TRUE if ok */ 01056 { 01057 ibool ret; 01058 01059 mutex_enter(&(buf_pool->mutex)); 01060 01061 ret = buf_flush_validate_low(); 01062 01063 mutex_exit(&(buf_pool->mutex)); 01064 01065 return(ret); 01066 }
Here is the call graph for this function:

| void buf_flush_wait_batch_end | ( | ulint | type | ) |
Definition at line 935 of file buf0flu.c.
References BUF_FLUSH_LIST, BUF_FLUSH_LRU, buf_pool, buf_pool_struct::no_flush, os_event_wait(), and ut_ad.
Referenced by buf_flush_free_margin(), log_preflush_pool_modified_pages(), recv_apply_hashed_log_recs(), and srv_master_thread().
00937 : BUF_FLUSH_LRU or BUF_FLUSH_LIST */ 00938 { 00939 ut_ad((type == BUF_FLUSH_LRU) || (type == BUF_FLUSH_LIST)); 00940 00941 os_event_wait(buf_pool->no_flush[type]); 00942 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_flush_write_complete | ( | buf_block_t * | block | ) |
Definition at line 177 of file buf0flu.c.
References yaSSL::block, BUF_BLOCK_FILE_PAGE, BUF_FLUSH_LRU, buf_LRU_make_block_old(), buf_pool, FALSE, buf_pool_struct::init_flush, buf_pool_struct::LRU_flush_ended, buf_pool_struct::mutex, buf_pool_struct::n_flush, buf_pool_struct::no_flush, os_event_set(), ut_a, ut_ad, ut_d, ut_dulint_zero, UT_LIST_REMOVE, and UT_LIST_VALIDATE.
Referenced by buf_page_io_complete().
00179 : pointer to the block in question */ 00180 { 00181 ut_ad(block); 00182 #ifdef UNIV_SYNC_DEBUG 00183 ut_ad(mutex_own(&(buf_pool->mutex))); 00184 #endif /* UNIV_SYNC_DEBUG */ 00185 ut_a(block->state == BUF_BLOCK_FILE_PAGE); 00186 00187 block->oldest_modification = ut_dulint_zero; 00188 00189 UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block); 00190 00191 ut_d(UT_LIST_VALIDATE(flush_list, buf_block_t, buf_pool->flush_list)); 00192 00193 (buf_pool->n_flush[block->flush_type])--; 00194 00195 if (block->flush_type == BUF_FLUSH_LRU) { 00196 /* Put the block to the end of the LRU list to wait to be 00197 moved to the free list */ 00198 00199 buf_LRU_make_block_old(block); 00200 00201 buf_pool->LRU_flush_ended++; 00202 } 00203 00204 /* fprintf(stderr, "n pending flush %lu\n", 00205 buf_pool->n_flush[block->flush_type]); */ 00206 00207 if ((buf_pool->n_flush[block->flush_type] == 0) 00208 && (buf_pool->init_flush[block->flush_type] == FALSE)) { 00209 00210 /* The running flush batch has ended */ 00211 00212 os_event_set(buf_pool->no_flush[block->flush_type]); 00213 } 00214 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

