Commit c65cb244 authored by Thirunarayanan Balathandayuthapani's avatar Thirunarayanan Balathandayuthapani Committed by Marko Mäkelä

MDEV-19335 Remove buf_page_t::encrypted

The field buf_page_t::encrypted was added in MDEV-8588.
It was made mostly redundant in MDEV-12699. Remove the field.
parent 24232ec1
...@@ -339,11 +339,9 @@ static bool page_is_corrupted(const byte *page, ulint page_no, ...@@ -339,11 +339,9 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
memcpy(tmp_page, page, page_size); memcpy(tmp_page, page, page_size);
bool decrypted = false;
if (!space->crypt_data if (!space->crypt_data
|| space->crypt_data->type == CRYPT_SCHEME_UNENCRYPTED || space->crypt_data->type == CRYPT_SCHEME_UNENCRYPTED
|| !fil_space_decrypt(space, tmp_frame, tmp_page, || !fil_space_decrypt(space, tmp_frame, tmp_page)) {
&decrypted)) {
return true; return true;
} }
......
...@@ -589,12 +589,6 @@ static bool buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) ...@@ -589,12 +589,6 @@ static bool buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space)
<< mach_read_from_4( << mach_read_from_4(
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
+ dst_frame); + dst_frame);
/* Mark page encrypted in case it should be. */
if (space->crypt_data->type
!= CRYPT_SCHEME_UNENCRYPTED) {
bpage->encrypted = true;
}
return false; return false;
} }
...@@ -605,8 +599,7 @@ static bool buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) ...@@ -605,8 +599,7 @@ static bool buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space)
ut_d(fil_page_type_validate(dst_frame)); ut_d(fil_page_type_validate(dst_frame));
/* decrypt using crypt_buf to dst_frame */ /* decrypt using crypt_buf to dst_frame */
if (!fil_space_decrypt(space, slot->crypt_buf, if (!fil_space_decrypt(space, slot->crypt_buf, dst_frame)) {
dst_frame, &bpage->encrypted)) {
slot->release(); slot->release();
goto decrypt_failed; goto decrypt_failed;
} }
...@@ -1534,7 +1527,6 @@ buf_block_init( ...@@ -1534,7 +1527,6 @@ buf_block_init(
block->page.buf_fix_count = 0; block->page.buf_fix_count = 0;
block->page.io_fix = BUF_IO_NONE; block->page.io_fix = BUF_IO_NONE;
block->page.flush_observer = NULL; block->page.flush_observer = NULL;
block->page.encrypted = false;
block->page.real_size = 0; block->page.real_size = 0;
block->page.write_size = 0; block->page.write_size = 0;
block->modify_clock = 0; block->modify_clock = 0;
...@@ -4044,7 +4036,6 @@ buf_zip_decompress( ...@@ -4044,7 +4036,6 @@ buf_zip_decompress(
if (encrypted) { if (encrypted) {
ib::info() << "Row compressed page could be encrypted" ib::info() << "Row compressed page could be encrypted"
" with key_version " << key_version; " with key_version " << key_version;
block->page.encrypted = true;
dict_set_encrypted_by_space(block->page.id.space()); dict_set_encrypted_by_space(block->page.id.space());
} else { } else {
dict_set_corrupted_by_space(block->page.id.space()); dict_set_corrupted_by_space(block->page.id.space());
...@@ -5248,7 +5239,6 @@ buf_page_init_low( ...@@ -5248,7 +5239,6 @@ buf_page_init_low(
bpage->newest_modification = 0; bpage->newest_modification = 0;
bpage->oldest_modification = 0; bpage->oldest_modification = 0;
bpage->write_size = 0; bpage->write_size = 0;
bpage->encrypted = false;
bpage->real_size = 0; bpage->real_size = 0;
bpage->slot = NULL; bpage->slot = NULL;
...@@ -5841,15 +5831,16 @@ buf_page_monitor( ...@@ -5841,15 +5831,16 @@ buf_page_monitor(
} }
/** Mark a table corrupted. /** Mark a table corrupted.
@param[in] bpage Corrupted page. */ @param[in] bpage corrupted page
static @param[in] space tablespace of the corrupted page */
void ATTRIBUTE_COLD
buf_mark_space_corrupt(buf_page_t* bpage) static void buf_mark_space_corrupt(buf_page_t* bpage, const fil_space_t& space)
{ {
/* If block is not encrypted find the table with specified /* If block is not encrypted find the table with specified
space id, and mark it corrupted. Encrypted tables space id, and mark it corrupted. Encrypted tables
are marked unusable later e.g. in ::open(). */ are marked unusable later e.g. in ::open(). */
if (!bpage->encrypted) { if (!space.crypt_data
|| space.crypt_data->type == CRYPT_SCHEME_UNENCRYPTED) {
dict_set_corrupted_by_space(bpage->id.space()); dict_set_corrupted_by_space(bpage->id.space());
} else { } else {
dict_set_encrypted_by_space(bpage->id.space()); dict_set_encrypted_by_space(bpage->id.space());
...@@ -5891,7 +5882,7 @@ buf_corrupt_page_release(buf_page_t* bpage, const fil_space_t* space) ...@@ -5891,7 +5882,7 @@ buf_corrupt_page_release(buf_page_t* bpage, const fil_space_t* space)
mutex_exit(buf_page_get_mutex(bpage)); mutex_exit(buf_page_get_mutex(bpage));
if (!srv_force_recovery) { if (!srv_force_recovery) {
buf_mark_space_corrupt(bpage); buf_mark_space_corrupt(bpage, *space);
} }
/* After this point bpage can't be referenced. */ /* After this point bpage can't be referenced. */
...@@ -5921,7 +5912,6 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) ...@@ -5921,7 +5912,6 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space)
byte* dst_frame = (bpage->zip.data) ? bpage->zip.data : byte* dst_frame = (bpage->zip.data) ? bpage->zip.data :
((buf_block_t*) bpage)->frame; ((buf_block_t*) bpage)->frame;
dberr_t err = DB_SUCCESS; dberr_t err = DB_SUCCESS;
bool corrupted = false;
/* In buf_decrypt_after_read we have either decrypted the page if /* In buf_decrypt_after_read we have either decrypted the page if
page post encryption checksum matches and used key_id is found page post encryption checksum matches and used key_id is found
...@@ -5929,33 +5919,20 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) ...@@ -5929,33 +5919,20 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space)
not decrypted and it could be either encrypted and corrupted not decrypted and it could be either encrypted and corrupted
or corrupted or good page. If we decrypted, there page could or corrupted or good page. If we decrypted, there page could
still be corrupted if used key does not match. */ still be corrupted if used key does not match. */
const bool still_encrypted = mach_read_from_4( const bool seems_encrypted = mach_read_from_4(
dst_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) dst_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
&& space->crypt_data && space->crypt_data
&& space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED && space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED;
&& !bpage->encrypted
&& fil_space_verify_crypt_checksum(dst_frame, bpage->size); /* If traditional checksums match, we assume that page is
not anymore encrypted. */
if (!still_encrypted) { if (buf_page_is_corrupted(
/* If traditional checksums match, we assume that page is true, dst_frame, bpage->size, space)) {
not anymore encrypted. */ err = DB_PAGE_CORRUPTED;
corrupted = buf_page_is_corrupted(
true, dst_frame, bpage->size, space);
if (!corrupted) {
bpage->encrypted = false;
} else {
err = DB_PAGE_CORRUPTED;
}
} }
/* Pages that we think are unencrypted but do not match the checksum if (seems_encrypted && err == DB_PAGE_CORRUPTED
checks could be corrupted or encrypted or both. */ && bpage->id.page_no() != 0) {
if (corrupted && !bpage->encrypted) {
/* An error will be reported by
buf_page_io_complete(). */
} else if (still_encrypted || (bpage->encrypted && corrupted)) {
bpage->encrypted = true;
err = DB_DECRYPTION_FAILED; err = DB_DECRYPTION_FAILED;
ib::error() ib::error()
...@@ -6017,7 +5994,6 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict) ...@@ -6017,7 +5994,6 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
if (io_type == BUF_IO_READ) { if (io_type == BUF_IO_READ) {
ulint read_page_no = 0; ulint read_page_no = 0;
ulint read_space_id = 0; ulint read_space_id = 0;
uint key_version = 0;
byte* frame = bpage->zip.data byte* frame = bpage->zip.data
? bpage->zip.data ? bpage->zip.data
: reinterpret_cast<buf_block_t*>(bpage)->frame; : reinterpret_cast<buf_block_t*>(bpage)->frame;
...@@ -6057,8 +6033,6 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict) ...@@ -6057,8 +6033,6 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
read_page_no = mach_read_from_4(frame + FIL_PAGE_OFFSET); read_page_no = mach_read_from_4(frame + FIL_PAGE_OFFSET);
read_space_id = mach_read_from_4( read_space_id = mach_read_from_4(
frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
key_version = mach_read_from_4(
frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
if (bpage->id.space() == TRX_SYS_SPACE if (bpage->id.space() == TRX_SYS_SPACE
&& buf_dblwr_page_inside(bpage->id.page_no())) { && buf_dblwr_page_inside(bpage->id.page_no())) {
...@@ -6174,23 +6148,9 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict) ...@@ -6174,23 +6148,9 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
&& fil_page_get_type(frame) == FIL_PAGE_INDEX && fil_page_get_type(frame) == FIL_PAGE_INDEX
&& page_is_leaf(frame)) { && page_is_leaf(frame)) {
if (bpage->encrypted) { ibuf_merge_or_delete_for_page(
ib::warn() (buf_block_t*) bpage, bpage->id,
<< "Table in tablespace " &bpage->size, TRUE);
<< bpage->id.space()
<< " encrypted. However key "
"management plugin or used "
<< "key_version " << key_version
<< " is not found or"
" used encryption algorithm or method does not match."
" Can't continue opening the table.";
} else {
ibuf_merge_or_delete_for_page(
(buf_block_t*) bpage, bpage->id,
&bpage->size, TRUE);
}
} }
fil_space_release_for_io(space); fil_space_release_for_io(space);
......
...@@ -793,7 +793,6 @@ Decrypt a page. ...@@ -793,7 +793,6 @@ Decrypt a page.
@param[in] space Tablespace @param[in] space Tablespace
@param[in] tmp_frame Temporary buffer used for decrypting @param[in] tmp_frame Temporary buffer used for decrypting
@param[in,out] src_frame Page to decrypt @param[in,out] src_frame Page to decrypt
@param[out] decrypted true if page was decrypted
@return decrypted page, or original not encrypted page if decryption is @return decrypted page, or original not encrypted page if decryption is
not needed.*/ not needed.*/
UNIV_INTERN UNIV_INTERN
...@@ -801,13 +800,11 @@ byte* ...@@ -801,13 +800,11 @@ byte*
fil_space_decrypt( fil_space_decrypt(
const fil_space_t* space, const fil_space_t* space,
byte* tmp_frame, byte* tmp_frame,
byte* src_frame, byte* src_frame)
bool* decrypted)
{ {
dberr_t err = DB_SUCCESS; dberr_t err = DB_SUCCESS;
byte* res = NULL; byte* res = NULL;
const page_size_t page_size(space->flags); const page_size_t page_size(space->flags);
*decrypted = false;
ut_ad(space->crypt_data != NULL && space->crypt_data->is_encrypted()); ut_ad(space->crypt_data != NULL && space->crypt_data->is_encrypted());
ut_ad(space->n_pending_ios > 0); ut_ad(space->n_pending_ios > 0);
...@@ -817,7 +814,6 @@ fil_space_decrypt( ...@@ -817,7 +814,6 @@ fil_space_decrypt(
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
if (encrypted) { if (encrypted) {
*decrypted = true;
/* Copy the decrypted page back to page buffer, not /* Copy the decrypted page back to page buffer, not
really any other options. */ really any other options. */
memcpy(src_frame, tmp_frame, page_size.physical()); memcpy(src_frame, tmp_frame, page_size.physical());
......
...@@ -342,10 +342,8 @@ ibuf_header_page_get( ...@@ -342,10 +342,8 @@ ibuf_header_page_get(
page_id_t(IBUF_SPACE_ID, FSP_IBUF_HEADER_PAGE_NO), page_id_t(IBUF_SPACE_ID, FSP_IBUF_HEADER_PAGE_NO),
univ_page_size, RW_X_LATCH, mtr); univ_page_size, RW_X_LATCH, mtr);
if (block) {
if (!block->page.encrypted) {
buf_block_dbg_add_level(block, SYNC_IBUF_HEADER); buf_block_dbg_add_level(block, SYNC_IBUF_HEADER);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
} }
......
...@@ -1468,8 +1468,6 @@ class buf_page_t { ...@@ -1468,8 +1468,6 @@ class buf_page_t {
if written again we check is TRIM if written again we check is TRIM
operation needed. */ operation needed. */
bool encrypted; /*!< page is still encrypted */
ulint real_size; /*!< Real size of the page ulint real_size; /*!< Real size of the page
Normal pages == UNIV_PAGE_SIZE Normal pages == UNIV_PAGE_SIZE
page compressed pages, payload page compressed pages, payload
......
...@@ -375,7 +375,6 @@ Decrypt a page ...@@ -375,7 +375,6 @@ Decrypt a page
@param[in] space Tablespace @param[in] space Tablespace
@param[in] tmp_frame Temporary buffer used for decrypting @param[in] tmp_frame Temporary buffer used for decrypting
@param[in,out] src_frame Page to decrypt @param[in,out] src_frame Page to decrypt
@param[out] decrypted true if page was decrypted
@return decrypted page, or original not encrypted page if decryption is @return decrypted page, or original not encrypted page if decryption is
not needed.*/ not needed.*/
UNIV_INTERN UNIV_INTERN
...@@ -383,8 +382,7 @@ byte* ...@@ -383,8 +382,7 @@ byte*
fil_space_decrypt( fil_space_decrypt(
const fil_space_t* space, const fil_space_t* space,
byte* tmp_frame, byte* tmp_frame,
byte* src_frame, byte* src_frame)
bool* decrypted)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/****************************************************************** /******************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment