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.cc40
1 files changed, 32 insertions, 8 deletions
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc
index 5f126ebb2a9..2046d8736c6 100644
--- a/storage/innobase/buf/buf0dblwr.cc
+++ b/storage/innobase/buf/buf0dblwr.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2017, MariaDB Corporation.
+Copyright (c) 2013, 2018, MariaDB Corporation.
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
@@ -362,6 +362,22 @@ too_small:
goto start_again;
}
+/** Check if a page is all zeroes.
+@param[in] read_buf database page
+@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
+@return whether the page is all zeroes */
+static bool buf_page_is_zeroes(const byte* read_buf, ulint zip_size)
+{
+ 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;
+}
+
/****************************************************************//**
At a database startup initializes the doublewrite buffer memory structure if
we already have a doublewrite buffer created in the data files. If we are
@@ -556,6 +572,9 @@ buf_dblwr_process()
const bool is_all_zero = buf_page_is_zeroes(
read_buf, zip_size);
+ const bool expect_encrypted = space()->crypt_data
+ && space()->crypt_data->type
+ != CRYPT_SCHEME_UNENCRYPTED;
if (is_all_zero) {
/* We will check if the copy in the
@@ -570,10 +589,13 @@ buf_dblwr_process()
goto bad;
}
- if (fil_space_verify_crypt_checksum(
- read_buf, zip_size, NULL, page_no)
- || !buf_page_is_corrupted(
- true, read_buf, zip_size, space())) {
+ if (expect_encrypted && mach_read_from_4(
+ read_buf
+ + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
+ ? fil_space_verify_crypt_checksum(read_buf,
+ zip_size)
+ : !buf_page_is_corrupted(true, read_buf,
+ zip_size, space())) {
/* The page is good; there is no need
to consult the doublewrite buffer. */
continue;
@@ -592,9 +614,11 @@ bad:
if (!decomp || (decomp != srv_page_size && zip_size)) {
goto bad_doublewrite;
}
- if (!fil_space_verify_crypt_checksum(page, zip_size, NULL,
- page_no)
- && buf_page_is_corrupted(true, page, zip_size, space)) {
+
+ if (expect_encrypted && mach_read_from_4(
+ page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
+ ? !fil_space_verify_crypt_checksum(page, zip_size)
+ : buf_page_is_corrupted(true, page, zip_size, space())) {
if (!is_all_zero) {
bad_doublewrite:
ib_logf(IB_LOG_LEVEL_WARN,