Skip to content

Commit 0b36c27

Browse files
committed
MDEV-20307: Remove a useless debug check to save stack space
fil_space_encrypt(): Remove the debug check that decrypts the just encrypted page. We are exercising the decryption of encrypted pages enough via --suite=encryption,mariabackup. It is a waste of computing resources to decrypt every page immediately after encrypting it. The redundant check had been added in commit 2bedc39 (MDEV-9931).
1 parent afe9caa commit 0b36c27

File tree

2 files changed

+6
-84
lines changed

2 files changed

+6
-84
lines changed

storage/innobase/fil/fil0crypt.cc

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
3-
Copyright (c) 2014, 2019, MariaDB Corporation.
3+
Copyright (c) 2014, 2020, MariaDB Corporation.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -706,47 +706,8 @@ fil_space_encrypt(
706706
fil_space_crypt_t* crypt_data = space->crypt_data;
707707
ut_ad(space->n_pending_ios > 0);
708708
ulint zip_size = fsp_flags_get_zip_size(space->flags);
709-
byte* tmp = fil_encrypt_buf(crypt_data, space->id, offset, lsn, src_frame, zip_size, dst_frame);
710-
711-
#ifdef UNIV_DEBUG
712-
if (tmp) {
713-
/* Verify that encrypted buffer is not corrupted */
714-
dberr_t err = DB_SUCCESS;
715-
byte* src = src_frame;
716-
bool page_compressed_encrypted = (mach_read_from_2(tmp+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
717-
byte uncomp_mem[UNIV_PAGE_SIZE_MAX];
718-
byte tmp_mem[UNIV_PAGE_SIZE_MAX];
719-
ulint size = (zip_size) ? zip_size : UNIV_PAGE_SIZE;
720-
721-
if (page_compressed_encrypted) {
722-
memcpy(uncomp_mem, src, srv_page_size);
723-
ulint unzipped1 = fil_page_decompress(
724-
tmp_mem, uncomp_mem);
725-
ut_ad(unzipped1);
726-
if (unzipped1 != srv_page_size) {
727-
src = uncomp_mem;
728-
}
729-
}
730-
731-
ut_ad(!buf_page_is_corrupted(true, src, zip_size, space));
732-
ut_ad(fil_space_decrypt(crypt_data, tmp_mem, size, tmp, &err));
733-
ut_ad(err == DB_SUCCESS);
734-
735-
/* Need to decompress the page if it was also compressed */
736-
if (page_compressed_encrypted) {
737-
byte buf[UNIV_PAGE_SIZE_MAX];
738-
memcpy(buf, tmp_mem, srv_page_size);
739-
ulint unzipped2 = fil_page_decompress(tmp_mem, buf);
740-
ut_ad(unzipped2);
741-
}
742-
743-
memcpy(tmp_mem + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
744-
src + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 8);
745-
ut_ad(!memcmp(src, tmp_mem, size));
746-
}
747-
#endif /* UNIV_DEBUG */
748-
749-
return tmp;
709+
return fil_encrypt_buf(crypt_data, space->id, offset, lsn,
710+
src_frame, zip_size, dst_frame);
750711
}
751712

752713
/******************************************************************

storage/xtradb/fil/fil0crypt.cc

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
3-
Copyright (c) 2014, 2019, MariaDB Corporation.
3+
Copyright (c) 2014, 2020, MariaDB Corporation.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -706,47 +706,8 @@ fil_space_encrypt(
706706
fil_space_crypt_t* crypt_data = space->crypt_data;
707707
ut_ad(space->n_pending_ios > 0);
708708
ulint zip_size = fsp_flags_get_zip_size(space->flags);
709-
byte* tmp = fil_encrypt_buf(crypt_data, space->id, offset, lsn, src_frame, zip_size, dst_frame);
710-
711-
#ifdef UNIV_DEBUG
712-
if (tmp) {
713-
/* Verify that encrypted buffer is not corrupted */
714-
dberr_t err = DB_SUCCESS;
715-
byte* src = src_frame;
716-
bool page_compressed_encrypted = (mach_read_from_2(tmp+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
717-
byte uncomp_mem[UNIV_PAGE_SIZE_MAX];
718-
byte tmp_mem[UNIV_PAGE_SIZE_MAX];
719-
ulint size = (zip_size) ? zip_size : UNIV_PAGE_SIZE;
720-
721-
if (page_compressed_encrypted) {
722-
memcpy(uncomp_mem, src, srv_page_size);
723-
ulint unzipped1 = fil_page_decompress(
724-
tmp_mem, uncomp_mem);
725-
ut_ad(unzipped1);
726-
if (unzipped1 != srv_page_size) {
727-
src = uncomp_mem;
728-
}
729-
}
730-
731-
ut_ad(!buf_page_is_corrupted(true, src, zip_size, space));
732-
ut_ad(fil_space_decrypt(crypt_data, tmp_mem, size, tmp, &err));
733-
ut_ad(err == DB_SUCCESS);
734-
735-
/* Need to decompress the page if it was also compressed */
736-
if (page_compressed_encrypted) {
737-
byte buf[UNIV_PAGE_SIZE_MAX];
738-
memcpy(buf, tmp_mem, srv_page_size);
739-
ulint unzipped2 = fil_page_decompress(tmp_mem, buf);
740-
ut_ad(unzipped2);
741-
}
742-
743-
memcpy(tmp_mem + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
744-
src + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 8);
745-
ut_ad(!memcmp(src, tmp_mem, size));
746-
}
747-
#endif /* UNIV_DEBUG */
748-
749-
return tmp;
709+
return fil_encrypt_buf(crypt_data, space->id, offset, lsn,
710+
src_frame, zip_size, dst_frame);
750711
}
751712

752713
/******************************************************************

0 commit comments

Comments
 (0)