diff options
Diffstat (limited to 'storage/innobase/buf')
-rw-r--r-- | storage/innobase/buf/buf0buddy.cc | 2 | ||||
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 37 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 54 | ||||
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 10 | ||||
-rw-r--r-- | storage/innobase/buf/buf0lru.cc | 14 |
5 files changed, 80 insertions, 37 deletions
diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc index fcf45b7fa1a..958b3b5cfad 100644 --- a/storage/innobase/buf/buf0buddy.cc +++ b/storage/innobase/buf/buf0buddy.cc @@ -131,7 +131,7 @@ buf_buddy_stamp_free( buf_buddy_free_t* buf, /*!< in/out: block to stamp */ ulint i) /*!< in: block size */ { - ut_d(memset(buf, i, BUF_BUDDY_LOW << i)); + ut_d(memset(buf, static_cast<int>(i), BUF_BUDDY_LOW << i)); buf_buddy_mem_invalid(buf, i); mach_write_to_4(buf->stamp.bytes + BUF_BUDDY_STAMP_OFFSET, BUF_BUDDY_STAMP_FREE); diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 697b3f203b3..4bae962e7d3 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -467,6 +467,26 @@ buf_block_alloc( #endif /* !UNIV_HOTBACKUP */ /********************************************************************//** +Checks if a page is all zeroes. +@return TRUE if the page is all zeroes */ +bool +buf_page_is_zeroes( +/*===============*/ + const byte* read_buf, /*!< in: a database page */ + const ulint zip_size) /*!< in: size of compressed page; + 0 for uncompressed pages */ +{ + const ulint page_size = zip_size ? zip_size : UNIV_PAGE_SIZE; + + for (ulint i = 0; i < page_size; i++) { + if (read_buf[i] != 0) { + return(false); + } + } + return(true); +} + +/********************************************************************//** Checks if a page is corrupt. @return TRUE if corrupted */ UNIV_INTERN @@ -1272,8 +1292,8 @@ buf_pool_init_instance( /* Number of locks protecting page_hash must be a power of two */ - srv_n_page_hash_locks = - ut_2_power_up(srv_n_page_hash_locks); + srv_n_page_hash_locks = static_cast<ulong>( + ut_2_power_up(srv_n_page_hash_locks)); ut_a(srv_n_page_hash_locks != 0); ut_a(srv_n_page_hash_locks <= MAX_PAGE_HASH_LOCKS); @@ -1668,8 +1688,8 @@ page_found: buf_block_t::mutex or buf_pool->zip_mutex or both. */ bpage->state = BUF_BLOCK_ZIP_PAGE; - bpage->space = space; - bpage->offset = offset; + bpage->space = static_cast<ib_uint32_t>(space); + bpage->offset = static_cast<ib_uint32_t>(offset); bpage->buf_fix_count = 1; ut_d(bpage->in_page_hash = TRUE); @@ -2795,14 +2815,13 @@ got_block: ++buf_pool->n_pend_unzip; + mutex_exit(&buf_pool->zip_mutex); buf_pool_mutex_exit(buf_pool); access_time = buf_page_is_accessed(&block->page); buf_block_mutex_exit(block); - mutex_exit(&buf_pool->zip_mutex); - buf_page_free_descriptor(bpage); /* Decompress the page while not holding @@ -3655,8 +3674,8 @@ err_exit: buf_page_init_low(bpage); bpage->state = BUF_BLOCK_ZIP_PAGE; - bpage->space = space; - bpage->offset = offset; + bpage->space = static_cast<ib_uint32_t>(space); + bpage->offset = static_cast<ib_uint32_t>(offset); #ifdef UNIV_DEBUG bpage->in_page_hash = FALSE; diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index e1018c89e9b..62222993622 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -352,11 +352,12 @@ we already have a doublewrite buffer created in the data files. If we are upgrading to an InnoDB version which supports multiple tablespaces, then this function performs the necessary update operations. If we are in a crash recovery, this function loads the pages from double write buffer into memory. */ -UNIV_INTERN void buf_dblwr_init_or_load_pages( -/*==========================*/ - bool load_corrupt_pages) +/*=========================*/ + os_file_t file, + char* path, + bool load_corrupt_pages) { byte* buf; byte* read_buf; @@ -368,6 +369,7 @@ buf_dblwr_init_or_load_pages( byte* doublewrite; ulint space_id; ulint i; + ulint block_bytes = 0; recv_dblwr_t& recv_dblwr = recv_sys->dblwr; /* We do the file i/o past the buffer pool */ @@ -379,9 +381,9 @@ buf_dblwr_init_or_load_pages( /* Read the trx sys header to check if we are using the doublewrite buffer */ + off_t trx_sys_page = TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE; + os_file_read(file, read_buf, trx_sys_page, UNIV_PAGE_SIZE); - fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, 0, - UNIV_PAGE_SIZE, read_buf, NULL); doublewrite = read_buf + TRX_SYS_DOUBLEWRITE; if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC) @@ -415,13 +417,12 @@ buf_dblwr_init_or_load_pages( /* Read the pages from the doublewrite buffer to memory */ - fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, block1, 0, - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, - buf, NULL); - fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, block2, 0, - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, - buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, - NULL); + block_bytes = TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; + + os_file_read(file, buf, block1 * UNIV_PAGE_SIZE, block_bytes); + os_file_read(file, buf + block_bytes, block2 * UNIV_PAGE_SIZE, + block_bytes); + /* Check if any of these pages is half-written in data files, in the intended position */ @@ -447,8 +448,9 @@ buf_dblwr_init_or_load_pages( + i - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE; } - fil_io(OS_FILE_WRITE, true, space_id, 0, source_page_no, 0, - UNIV_PAGE_SIZE, page, NULL); + os_file_write(path, file, page, + source_page_no * UNIV_PAGE_SIZE, + UNIV_PAGE_SIZE); } else if (load_corrupt_pages) { @@ -458,7 +460,9 @@ buf_dblwr_init_or_load_pages( page += UNIV_PAGE_SIZE; } - fil_flush_file_spaces(FIL_TABLESPACE); + if (reset_space_ids) { + os_file_flush(file); + } leave_func: ut_free(unaligned_read_buf); @@ -567,13 +571,29 @@ buf_dblwr_process() ib_logf(IB_LOG_LEVEL_INFO, "Recovered the page from" " the doublewrite buffer."); + + } else if (buf_page_is_zeroes(read_buf, zip_size)) { + + if (!buf_page_is_zeroes(page, zip_size) + && !buf_page_is_corrupted(true, page, + zip_size)) { + + /* Database page contained only + zeroes, while a valid copy is + available in dblwr buffer. */ + + fil_io(OS_FILE_WRITE, true, space_id, + zip_size, page_no, 0, + zip_size ? zip_size + : UNIV_PAGE_SIZE, + page, NULL); + } } } } fil_flush_file_spaces(FIL_TABLESPACE); ut_free(unaligned_read_buf); - recv_dblwr.pages.clear(); } /****************************************************************//** diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 0fa5c744e51..3cce75abe74 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -750,9 +750,11 @@ buf_flush_update_zip_checksum( { ut_a(zip_size > 0); - ib_uint32_t checksum = page_zip_calc_checksum( - page, zip_size, - static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm)); + ib_uint32_t checksum = static_cast<ib_uint32_t>( + page_zip_calc_checksum( + page, zip_size, + static_cast<srv_checksum_algorithm_t>( + srv_checksum_algorithm))); mach_write_to_8(page + FIL_PAGE_LSN, lsn); memset(page + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); @@ -2322,7 +2324,7 @@ page_cleaner_flush_pages_if_needed(void) } if (last_pages && cur_lsn - last_lsn > lsn_avg_rate / 2) { - age_factor = prev_pages / last_pages; + age_factor = static_cast<int>(prev_pages / last_pages); } MONITOR_SET(MONITOR_FLUSH_N_TO_FLUSH_REQUESTED, n_pages); diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 98d0ec2d2ec..ec30c063a72 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -1262,7 +1262,8 @@ loop: memset(&block->page.zip, 0, sizeof block->page.zip); if (started_monitor) { - srv_print_innodb_monitor = mon_value_was; + srv_print_innodb_monitor = + static_cast<my_bool>(mon_value_was); } return(block); @@ -2046,11 +2047,12 @@ func_exit: buf_pool->page_hash, thus inaccessible by any other thread. */ - checksum = page_zip_calc_checksum( - b->zip.data, - page_zip_get_size(&b->zip), - static_cast<srv_checksum_algorithm_t>( - srv_checksum_algorithm)); + checksum = static_cast<ib_uint32_t>( + page_zip_calc_checksum( + b->zip.data, + page_zip_get_size(&b->zip), + static_cast<srv_checksum_algorithm_t>( + srv_checksum_algorithm))); mach_write_to_4(b->zip.data + FIL_PAGE_SPACE_OR_CHKSUM, checksum); |