summaryrefslogtreecommitdiff
path: root/storage/innobase/buf/buf0dblwr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/buf/buf0dblwr.cc')
-rw-r--r--storage/innobase/buf/buf0dblwr.cc54
1 files changed, 37 insertions, 17 deletions
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();
}
/****************************************************************//**