[Commits] a4c1ed2ce8d: After review fixes to fil_space_verify_crypt_checksum

jan jan.lindstrom at mariadb.com
Wed Aug 2 13:30:53 EEST 2017


revision-id: a4c1ed2ce8d55654b08b36dffef9475bd4a263c3 (mariadb-10.1.25-16-ga4c1ed2ce8d)
parent(s): 164edee7005c4a0280d68e36c4a344061e7b0b80
author: Jan Lindström
committer: Jan Lindström
timestamp: 2017-08-02 13:30:41 +0300
message:

After review fixes to fil_space_verify_crypt_checksum

---
 storage/innobase/fil/fil0crypt.cc | 27 ++++++++++++--------------
 storage/xtradb/fil/fil0crypt.cc   | 41 ++++++++++++++++++++++++---------------
 2 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index 619407d9ad0..b5b762c2cd9 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -2610,18 +2610,16 @@ fil_space_verify_crypt_checksum(
 		cchecksum1 = page_zip_calc_checksum(
 			page, zip_size, SRV_CHECKSUM_ALGORITHM_CRC32);
 
-		if(cchecksum1 != checksum) {
-			cchecksum2 = page_zip_calc_checksum(
+		cchecksum2 = (cchecksum1 == checksum)
+			? 0
+			: page_zip_calc_checksum(
 				page, zip_size,
 				SRV_CHECKSUM_ALGORITHM_INNODB);
-		}
 	} else {
 		cchecksum1 = buf_calc_page_crc32(page);
-
-		if (cchecksum1 != checksum) {
-			cchecksum2 = (ib_uint32_t) buf_calc_page_new_checksum(
-				page);
-		}
+		cchecksum2 = (cchecksum1 == checksum)
+			? 0
+			: buf_calc_page_new_checksum(page);
 	}
 
 	/* If stored checksum matches one of the calculated checksums
@@ -2654,17 +2652,16 @@ fil_space_verify_crypt_checksum(
 	when FIL_PAGE_FILE_FLUSH_LSN does not contain 0.
 	*/
 
-	ulint checksum1 = mach_read_from_4(
-		page + FIL_PAGE_SPACE_OR_CHKSUM);
-
-	ulint checksum2 = checksum1;
+	uint32_t checksum1 = mach_read_from_4(page + FIL_PAGE_SPACE_OR_CHKSUM);
+	uint32_t checksum2;
 
 	bool valid;
 
 	if (zip_size) {
 		valid = (checksum1 == cchecksum1);
+		checksum2 = checksum1;
 	} else {
-		checksum1 = mach_read_from_4(
+		checksum2 = mach_read_from_4(
 			page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
 		valid = (buf_page_is_checksum_valid_crc32(page,checksum1,checksum2)
 		|| buf_page_is_checksum_valid_innodb(page,checksum1, checksum2));
@@ -2677,7 +2674,7 @@ fil_space_verify_crypt_checksum(
 #ifndef UNIV_INNOCHECKSUM
 		ib_logf(IB_LOG_LEVEL_ERROR,
 			" Page " ULINTPF " in space %s (" ULINTPF ") maybe corrupted."
-			" Post encryption checksum %u stored [" ULINTPF ":" ULINTPF "] key_version %u",
+			" Post encryption checksum %u stored [%u:%u] key_version %u",
 			pageno,
 			space ? space->name : "N/A",
 			mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID),
@@ -2687,7 +2684,7 @@ fil_space_verify_crypt_checksum(
 			fprintf(log_file,
 				"Page " ULINTPF ":" ULINTPF " may be corrupted."
 				" Post encryption checksum %u"
-				" stored [" ULINTPF ":" ULINTPF "] key_version %u\n",
+				" stored [%u:%u] key_version %u\n",
 				pageno,
 				mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID),
 				checksum, checksum1, checksum2,
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index fe79d2eefc1..b5b762c2cd9 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -2610,18 +2610,16 @@ fil_space_verify_crypt_checksum(
 		cchecksum1 = page_zip_calc_checksum(
 			page, zip_size, SRV_CHECKSUM_ALGORITHM_CRC32);
 
-		if(cchecksum1 != checksum) {
-			cchecksum2 = page_zip_calc_checksum(
+		cchecksum2 = (cchecksum1 == checksum)
+			? 0
+			: page_zip_calc_checksum(
 				page, zip_size,
 				SRV_CHECKSUM_ALGORITHM_INNODB);
-		}
 	} else {
 		cchecksum1 = buf_calc_page_crc32(page);
-
-		if (cchecksum1 != checksum) {
-			cchecksum2 = (ib_uint32_t) buf_calc_page_new_checksum(
-				page);
-		}
+		cchecksum2 = (cchecksum1 == checksum)
+			? 0
+			: buf_calc_page_new_checksum(page);
 	}
 
 	/* If stored checksum matches one of the calculated checksums
@@ -2654,17 +2652,16 @@ fil_space_verify_crypt_checksum(
 	when FIL_PAGE_FILE_FLUSH_LSN does not contain 0.
 	*/
 
-	ulint checksum1 = mach_read_from_4(
-		page + FIL_PAGE_SPACE_OR_CHKSUM);
-
-	ulint checksum2 = checksum1;
+	uint32_t checksum1 = mach_read_from_4(page + FIL_PAGE_SPACE_OR_CHKSUM);
+	uint32_t checksum2;
 
 	bool valid;
 
 	if (zip_size) {
 		valid = (checksum1 == cchecksum1);
+		checksum2 = checksum1;
 	} else {
-		checksum1 = mach_read_from_4(
+		checksum2 = mach_read_from_4(
 			page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
 		valid = (buf_page_is_checksum_valid_crc32(page,checksum1,checksum2)
 		|| buf_page_is_checksum_valid_innodb(page,checksum1, checksum2));
@@ -2676,13 +2673,25 @@ fil_space_verify_crypt_checksum(
 		corrupted. */
 #ifndef UNIV_INNOCHECKSUM
 		ib_logf(IB_LOG_LEVEL_ERROR,
-			" Page %lu in space %s (%lu) maybe corrupted."
-			" Post encryption checksum %u stored [%lu:%lu] key_version %u",
+			" Page " ULINTPF " in space %s (" ULINTPF ") maybe corrupted."
+			" Post encryption checksum %u stored [%u:%u] key_version %u",
 			pageno,
 			space ? space->name : "N/A",
 			mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID),
 			checksum, checksum1, checksum2, key_version);
-#endif
+#else
+		if (log_file) {
+			fprintf(log_file,
+				"Page " ULINTPF ":" ULINTPF " may be corrupted."
+				" Post encryption checksum %u"
+				" stored [%u:%u] key_version %u\n",
+				pageno,
+				mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID),
+				checksum, checksum1, checksum2,
+				key_version);
+		}
+#endif /* UNIV_INNOCHECKSUM */
+
 		encrypted = false;
 	}
 


More information about the commits mailing list