diff options
author | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2018-12-11 16:16:11 +0530 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-12-13 12:06:14 +0200 |
commit | 5f5e73f1fe4f34b806b94cf9443348ed6cf14c1e (patch) | |
tree | e377f7f5077db72b60e59fcb4e80ad0e475a37b0 | |
parent | ce1669af121f705f85c64daf8e40bf0eac9f7887 (diff) | |
download | mariadb-git-5f5e73f1fe4f34b806b94cf9443348ed6cf14c1e.tar.gz |
MDEV-17957 Make Innodb_checksum_algorithm stricter for strict_* values
Problem:
Innodb_checksum_algorithm checks for all checksum algorithm to
validate the page checksum even though the algorithm is specified as
strict_crc32, strict_innodb, strict_none.
Fix:
Remove the checks for all checksum algorithm to validate the page
checksum if the algo is specified as strict_* values.
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 172 | ||||
-rw-r--r-- | storage/innobase/include/page0page.h | 15 | ||||
-rw-r--r-- | storage/innobase/include/page0zip.h | 15 | ||||
-rw-r--r-- | storage/innobase/page/page0page.cc | 42 | ||||
-rw-r--r-- | storage/innobase/page/page0zip.cc | 95 | ||||
-rw-r--r-- | storage/xtradb/buf/buf0buf.cc | 174 | ||||
-rw-r--r-- | storage/xtradb/include/page0page.h | 18 | ||||
-rw-r--r-- | storage/xtradb/page/page0page.cc | 46 | ||||
-rw-r--r-- | storage/xtradb/page/page0zip.cc | 87 |
9 files changed, 199 insertions, 465 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 11dceacf592..eb29d46daff 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -581,6 +581,8 @@ buf_page_is_corrupted( ulint checksum_field1; ulint checksum_field2; + ib_uint32_t crc32 = ULINT32_UNDEFINED; + bool crc32_inited = false; if (!zip_size && memcmp(read_buf + FIL_PAGE_LSN + 4, @@ -660,120 +662,124 @@ buf_page_is_corrupted( return(FALSE); } - ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET); - ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID); const srv_checksum_algorithm_t curr_algo = static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); switch (curr_algo) { - case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); + if (buf_page_is_checksum_valid_crc32(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; } - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } + return TRUE; + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + if (buf_page_is_checksum_valid_innodb(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; + } - return(FALSE); + return TRUE; + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + if (buf_page_is_checksum_valid_none(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; } - if (buf_page_is_checksum_valid_innodb(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - } + return TRUE; + case SRV_CHECKSUM_ALGORITHM_CRC32: + case SRV_CHECKSUM_ALGORITHM_INNODB: + /* Verify old versions of InnoDB only stored 8 byte lsn to the + start and end of the page. */ - return(FALSE); - } + /* Since innodb_checksum_algorithm is not strict_* allow + any of the algos to match for the old field. */ - return(TRUE); + if (checksum_field2 + != mach_read_from_4(read_buf + FIL_PAGE_LSN) + && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) { - case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + if (srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_CRC32) { - if (buf_page_is_checksum_valid_innodb(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); - } + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = true; - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } + if (checksum_field2 != crc32 + && checksum_field2 + != buf_calc_page_old_checksum(read_buf)) { + return TRUE; + } + } else { + ut_ad(srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_INNODB); - return(FALSE); - } + if (checksum_field2 + != buf_calc_page_old_checksum(read_buf)) { - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - } + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = TRUE; - return(FALSE); + if (checksum_field2 != crc32) { + return TRUE; + } + } + } } - return(TRUE); + /* Old field is fine, check the new field */ - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + if (checksum_field1 != 0 + && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) { - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); - } + if (srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_CRC32) { - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - return(FALSE); + if (!crc32_inited) { + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = TRUE; + } + + if (checksum_field1 != crc32 + && checksum_field1 + != buf_calc_page_new_checksum(read_buf)) { + return TRUE; + } + } else { + ut_ad(srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_INNODB); + + if (checksum_field1 + != buf_calc_page_new_checksum(read_buf)) { + + if (!crc32_inited) { + crc32 = buf_calc_page_crc32( + read_buf); + crc32_inited = TRUE; + } + + if (checksum_field1 != crc32) { + return TRUE; + } + } + } } - if (buf_page_is_checksum_valid_innodb(read_buf, - checksum_field1, checksum_field2)) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - return(FALSE); + if (crc32_inited + && ((checksum_field1 == crc32 + && checksum_field2 != crc32) + || (checksum_field1 != crc32 + && checksum_field2 == crc32))) { + return TRUE; } - return(TRUE); + break; case SRV_CHECKSUM_ALGORITHM_NONE: - /* should have returned FALSE earlier */ - break; - /* no default so the compiler will emit a warning if new enum - is added and not handled here */ + ut_error; } - ut_error; - return(FALSE); + return FALSE; } /** Dump a page to stderr. diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index 5cbbe30401f..5a572b1f314 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2016, 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 @@ -1123,19 +1123,6 @@ const rec_t* page_find_rec_max_not_deleted( const page_t* page); -/** Issue a warning when the checksum that is stored in the page is valid, -but different than the global setting innodb_checksum_algorithm. -@param[in] current_algo current checksum algorithm -@param[in] page_checksum page valid checksum -@param[in] space_id tablespace id -@param[in] page_no page number */ -void -page_warn_strict_checksum( - srv_checksum_algorithm_t curr_algo, - srv_checksum_algorithm_t page_checksum, - ulint space_id, - ulint page_no); - #ifdef UNIV_MATERIALIZE #undef UNIV_INLINE #define UNIV_INLINE UNIV_INLINE_ORIGINAL diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 4e362cec641..0bf77e2fcf3 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -546,21 +546,6 @@ from outside the buffer pool. # define UNIV_INLINE UNIV_INLINE_ORIGINAL #endif -#ifdef UNIV_INNOCHECKSUM -/** Issue a warning when the checksum that is stored in the page is valid, -but different than the global setting innodb_checksum_algorithm. -@param[in] current_algo current checksum algorithm -@param[in] page_checksum page valid checksum -@param[in] space_id tablespace id -@param[in] page_no page number */ -void -page_warn_strict_checksum( - srv_checksum_algorithm_t curr_algo, - srv_checksum_algorithm_t page_checksum, - ulint space_id, - ulint page_no); -#endif /* UNIV_INNOCHECKSUM */ - #ifndef UNIV_INNOCHECKSUM #ifndef UNIV_NONINL # include "page0zip.ic" diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index fcd722f3492..dd1136eb23a 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2807,45 +2807,3 @@ page_find_rec_max_not_deleted( } return(prev_rec); } - -/** Issue a warning when the checksum that is stored in the page is valid, -but different than the global setting innodb_checksum_algorithm. -@param[in] current_algo current checksum algorithm -@param[in] page_checksum page valid checksum -@param[in] space_id tablespace id -@param[in] page_no page number */ -void -page_warn_strict_checksum( - srv_checksum_algorithm_t curr_algo, - srv_checksum_algorithm_t page_checksum, - ulint space_id, - ulint page_no) -{ - srv_checksum_algorithm_t curr_algo_nonstrict; - switch (curr_algo) { - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_CRC32; - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_INNODB; - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_NONE; - break; - default: - ut_error; - } - - ib_logf(IB_LOG_LEVEL_WARN, - "innodb_checksum_algorithm is set to \"%s\"" - " but the page [page id: space=" ULINTPF "," - " page number=" ULINTPF "] contains a valid checksum \"%s\"." - " Accepting the page as valid. Change innodb_checksum_algorithm" - " to \"%s\" to silently accept such pages or rewrite all pages" - " so that they contain \"%s\" checksum.", - buf_checksum_algorithm_name(curr_algo), - space_id, page_no, - buf_checksum_algorithm_name(page_checksum), - buf_checksum_algorithm_name(curr_algo_nonstrict), - buf_checksum_algorithm_name(curr_algo_nonstrict)); -} diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 878a0b8728f..f9a4e38064c 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -2,7 +2,7 @@ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2014, 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 @@ -48,8 +48,6 @@ using namespace std; #include "btr0cur.h" #include "page0types.h" #include "log0recv.h" -#else -#define page_warn_strict_checksum(A,B,C,D) #endif /* !UNIV_INNOCHECKSUM */ #include "zlib.h" #ifndef UNIV_HOTBACKUP @@ -4926,13 +4924,6 @@ page_zip_verify_checksum( stored = static_cast<ib_uint32_t>(mach_read_from_4( static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - ulint page_no MY_ATTRIBUTE((unused)) = - mach_read_from_4(static_cast<const unsigned char*> - (data) + FIL_PAGE_OFFSET); - ulint space_id MY_ATTRIBUTE((unused)) = - mach_read_from_4(static_cast<const unsigned char*> - (data) + FIL_PAGE_SPACE_ID); - #if FIL_PAGE_LSN % 8 #error "FIL_PAGE_LSN must be 64 bit aligned" #endif @@ -4974,97 +4965,31 @@ page_zip_verify_checksum( switch (curr_algo) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + return stored == calc; + case SRV_CHECKSUM_ALGORITHM_CRC32: if (stored == BUF_NO_CHECKSUM_MAGIC) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } - return(TRUE); } + crc32 = calc; innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); - - if (stored == innodb) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - } - - return(TRUE); - } - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: case SRV_CHECKSUM_ALGORITHM_INNODB: - if (stored == BUF_NO_CHECKSUM_MAGIC) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } - - return(TRUE); + return TRUE; } crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); - - if (stored == crc32) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - } - - return(TRUE); - } - - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - - crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); - - if (stored == crc32) { - page_warn_strict_checksum( - curr_algo, SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - - return(TRUE); - } - - innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); - - if (stored == innodb) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - return(TRUE); - } - + innodb = calc; break; case SRV_CHECKSUM_ALGORITHM_NONE: - ut_error; - /* no default so the compiler will emit a warning if new enum - is added and not handled here */ + return TRUE; } - return(FALSE); + return (stored == crc32 || stored == innodb); } diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 2d9c47e7ad8..aaaf486dddb 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -653,6 +653,8 @@ buf_page_is_corrupted( ulint checksum_field1; ulint checksum_field2; + ib_uint32_t crc32 = ULINT32_UNDEFINED; + bool crc32_inited = false; if (!zip_size && memcmp(read_buf + FIL_PAGE_LSN + 4, @@ -732,120 +734,124 @@ buf_page_is_corrupted( return(FALSE); } - ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET); - ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID); const srv_checksum_algorithm_t curr_algo = static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); switch (curr_algo) { - case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); + if (buf_page_is_checksum_valid_crc32(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; } - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } + return TRUE; - return(FALSE); + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + if (buf_page_is_checksum_valid_innodb(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; } - if (buf_page_is_checksum_valid_innodb(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - } - - return(FALSE); + return TRUE; + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + if (buf_page_is_checksum_valid_none(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; } - return(TRUE); - + return TRUE; + case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + /* Verify old versions of InnoDB only stored 8 byte lsn to the + start and end of the page. */ - if (buf_page_is_checksum_valid_innodb(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); - } + /* Since innodb_checksum_algorithm is not strict_* allow + any of the algos to match for the old field. */ - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } + if (checksum_field2 + != mach_read_from_4(read_buf + FIL_PAGE_LSN) + && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) { - return(FALSE); - } + if (srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_CRC32) { - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - } + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = true; - return(FALSE); - } + if (checksum_field2 != crc32 + && checksum_field2 + != buf_calc_page_old_checksum(read_buf)) { + return TRUE; + } + } else { + ut_ad(srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_INNODB); - return(TRUE); + if (checksum_field2 + != buf_calc_page_old_checksum(read_buf)) { - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = TRUE; - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); + if (checksum_field2 != crc32) { + return TRUE; + } + } + } } - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - return(FALSE); - } + /* Old field is fine, check the new field */ - if (buf_page_is_checksum_valid_innodb(read_buf, - checksum_field1, checksum_field2)) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - return(FALSE); + if (checksum_field1 != 0 + && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) { + + if (srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_CRC32) { + + if (!crc32_inited) { + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = TRUE; + } + + if (checksum_field1 != crc32 + && checksum_field1 + != buf_calc_page_new_checksum(read_buf)) { + return TRUE; + } + } else { + ut_ad(srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_INNODB); + + if (checksum_field1 + != buf_calc_page_new_checksum(read_buf)) { + + if (!crc32_inited) { + crc32 = buf_calc_page_crc32( + read_buf); + crc32_inited = TRUE; + } + + if (checksum_field1 != crc32) { + return TRUE; + } + } + } } - return(TRUE); + if (crc32_inited + && ((checksum_field1 == crc32 + && checksum_field2 != crc32) + || (checksum_field1 != crc32 + && checksum_field2 == crc32))) { + return TRUE; + } - case SRV_CHECKSUM_ALGORITHM_NONE: - /* should have returned FALSE earlier */ break; - /* no default so the compiler will emit a warning if new enum - is added and not handled here */ + case SRV_CHECKSUM_ALGORITHM_NONE: + ut_error; } - ut_error; - return(FALSE); + return FALSE; } /** Dump a page to stderr. diff --git a/storage/xtradb/include/page0page.h b/storage/xtradb/include/page0page.h index eefa0fa4c5b..26e71ff8081 100644 --- a/storage/xtradb/include/page0page.h +++ b/storage/xtradb/include/page0page.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +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 @@ -1109,23 +1110,6 @@ const rec_t* page_find_rec_max_not_deleted( const page_t* page); -#endif /* #ifndef UNIV_INNOCHECKSUM */ - -/** Issue a warning when the checksum that is stored in the page is valid, -but different than the global setting innodb_checksum_algorithm. -@param[in] current_algo current checksum algorithm -@param[in] page_checksum page valid checksum -@param[in] space_id tablespace id -@param[in] page_no page number */ -void -page_warn_strict_checksum( - srv_checksum_algorithm_t curr_algo, - srv_checksum_algorithm_t page_checksum, - ulint space_id, - ulint page_no); - -#ifndef UNIV_INNOCHECKSUM - #ifdef UNIV_MATERIALIZE #undef UNIV_INLINE #define UNIV_INLINE UNIV_INLINE_ORIGINAL diff --git a/storage/xtradb/page/page0page.cc b/storage/xtradb/page/page0page.cc index 518400a9bf0..76c41941b08 100644 --- a/storage/xtradb/page/page0page.cc +++ b/storage/xtradb/page/page0page.cc @@ -2814,49 +2814,3 @@ page_find_rec_max_not_deleted( } #endif /* #ifndef UNIV_INNOCHECKSUM */ - -/** Issue a warning when the checksum that is stored in the page is valid, -but different than the global setting innodb_checksum_algorithm. -@param[in] current_algo current checksum algorithm -@param[in] page_checksum page valid checksum -@param[in] space_id tablespace id -@param[in] page_no page number */ -void -page_warn_strict_checksum( - srv_checksum_algorithm_t curr_algo, - srv_checksum_algorithm_t page_checksum, - ulint space_id, - ulint page_no) -{ - srv_checksum_algorithm_t curr_algo_nonstrict = srv_checksum_algorithm_t(); - switch (curr_algo) { - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_CRC32; - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_INNODB; - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_NONE; - break; - default: - ut_error; - } - -#ifdef UNIV_INNOCHECKSUM - fprintf(stderr, -#else - ib_logf(IB_LOG_LEVEL_WARN, -#endif - "innodb_checksum_algorithm is set to \"%s\"" - " but the page [page id: space=" ULINTPF "," - " page number=" ULINTPF "] contains a valid checksum \"%s\"." - " Accepting the page as valid. Change innodb_checksum_algorithm" - " to \"%s\" to silently accept such pages or rewrite all pages" - " so that they contain \"%s\" checksum.", - buf_checksum_algorithm_name(curr_algo), - space_id, page_no, - buf_checksum_algorithm_name(page_checksum), - buf_checksum_algorithm_name(curr_algo_nonstrict), - buf_checksum_algorithm_name(curr_algo_nonstrict)); -} diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc index 0d2bb7fb986..b9b05db24cc 100644 --- a/storage/xtradb/page/page0zip.cc +++ b/storage/xtradb/page/page0zip.cc @@ -2,7 +2,7 @@ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2014, SkySQL Ab. All Rights Reserved. +Copyright (c) 2014, 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 @@ -4934,10 +4934,6 @@ page_zip_verify_checksum( stored = static_cast<ib_uint32_t>(mach_read_from_4( static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - ulint page_no = mach_read_from_4(static_cast<const unsigned char*> (data) + FIL_PAGE_OFFSET); - ulint space_id = mach_read_from_4(static_cast<const unsigned char*> - (data) + FIL_PAGE_SPACE_ID); - #if FIL_PAGE_LSN % 8 #error "FIL_PAGE_LSN must be 64 bit aligned" #endif @@ -4974,97 +4970,30 @@ page_zip_verify_checksum( switch (curr_algo) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + return stored == calc; case SRV_CHECKSUM_ALGORITHM_CRC32: - if (stored == BUF_NO_CHECKSUM_MAGIC) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } - return(TRUE); } + crc32 = calc; innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); - - if (stored == innodb) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - } - - return(TRUE); - } - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: case SRV_CHECKSUM_ALGORITHM_INNODB: - if (stored == BUF_NO_CHECKSUM_MAGIC) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } - return(TRUE); } crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); - - if (stored == crc32) { - if (curr_algo - == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - } - - return(TRUE); - } - - break; - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - - crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); - - if (stored == crc32) { - page_warn_strict_checksum( - curr_algo, SRV_CHECKSUM_ALGORITHM_CRC32, - space_id, page_no); - - return(TRUE); - } - - innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); - - if (stored == innodb) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_INNODB, - space_id, page_no); - return(TRUE); - } - + innodb = calc; break; case SRV_CHECKSUM_ALGORITHM_NONE: - ut_error; - /* no default so the compiler will emit a warning if new enum - is added and not handled here */ + return TRUE; } - return(FALSE); + return (stored == crc32 || stored == innodb); } |