diff options
Diffstat (limited to 'storage/innobase/buf/buf0dblwr.cc')
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 099a3752f7f..785ec21a7bf 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 @@ -335,6 +335,20 @@ too_small: goto start_again; } +/** Check if a page is all zeroes. +@param[in] read_buf database page +@param[in] page_size page frame size +@return whether the page is all zeroes */ +static bool buf_page_is_zeroes(const byte* read_buf, size_t page_size) +{ + for (ulint i = 0; i < page_size; i++) { + if (read_buf[i] != 0) { + return false; + } + } + return true; +} + /** At database startup initializes the doublewrite buffer memory structure if we already have a doublewrite buffer created in the data files. If we are @@ -570,7 +584,7 @@ buf_dblwr_process() } const page_size_t page_size(space->flags); - ut_ad(!buf_page_is_zeroes(page, page_size)); + ut_ad(!buf_page_is_zeroes(page, page_size.physical())); /* We want to ensure that for partial reads the unread portion of the page is NUL. */ @@ -594,7 +608,9 @@ buf_dblwr_process() } const bool is_all_zero = buf_page_is_zeroes( - read_buf, page_size); + read_buf, page_size.physical()); + 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 @@ -610,10 +626,13 @@ buf_dblwr_process() goto bad; } - if (fil_space_verify_crypt_checksum( - read_buf, page_size, space_id, page_no) - || !buf_page_is_corrupted( - true, read_buf, page_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, + page_size) + : !buf_page_is_corrupted(true, read_buf, + page_size, space)) { /* The page is good; there is no need to consult the doublewrite buffer. */ continue; @@ -632,9 +651,11 @@ bad: && page_size.is_compressed())) { goto bad_doublewrite; } - if (!fil_space_verify_crypt_checksum(page, page_size, - space_id, page_no) - && buf_page_is_corrupted(true, page, page_size, space)) { + + if (expect_encrypted && mach_read_from_4( + page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) + ? !fil_space_verify_crypt_checksum(page, page_size) + : buf_page_is_corrupted(true, page, page_size, space)) { if (!is_all_zero) { bad_doublewrite: ib::warn() << "A doublewrite copy of page " |