Skip to content

Commit

Permalink
MySQL 8.0.33 merge Fixed compliation error on fil_cur.cc & redo_log.cc
Browse files Browse the repository at this point in the history
commit be86cea  Bug#34836519 Unneeded IORequest argument in encryption methods
removed IORequestLogRead, IORequestLogWrite
also changed definition of some encryption function.
  • Loading branch information
rahulmalik87 authored and altmannmarcelo committed May 4, 2023
1 parent 37c7ac6 commit 019b882
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
9 changes: 6 additions & 3 deletions storage/innobase/xtrabackup/src/fil_cur.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,13 @@ xb_fil_cur_result_t xb_fil_cur_read_from_offset(xb_fil_cur_t *cursor,
}
return (XB_FIL_CUR_ERROR);
}
Encryption_metadata encryption_metadata;

Encryption::set_or_generate(Encryption::AES, cursor->encryption_key,
cursor->encryption_iv, encryption_metadata);

read_request.get_encryption_info().set(encryption_metadata);

read_request.encryption_algorithm(Encryption::AES);
read_request.encryption_key(cursor->encryption_key, cursor->encryption_klen,
cursor->encryption_iv);
read_request.block_size(cursor->block_size);

npages = n_read >> cursor->page_size_shift;
Expand Down
43 changes: 17 additions & 26 deletions storage/innobase/xtrabackup/src/redo_log.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************
Copyright (c) 2019,2022 Percona LLC and/or its affiliates.
Copyright (c) 2019,2023 Percona LLC and/or its affiliates.
Redo log handling.
Expand Down Expand Up @@ -731,29 +731,23 @@ bool Redo_Log_Writer::close_logfile() {
return (true);
}

/* set encryption info of redo log on io request */
static void set_encryption_info(IORequest &req_type) {
auto& encryption_metadata = log_sys->m_encryption_metadata;
ut_ad(encryption_metadata.m_type != Encryption::NONE);
req_type.encryption_algorithm(encryption_metadata.m_type);
req_type.encryption_key(encryption_metadata.m_key,
encryption_metadata.m_key_len,
encryption_metadata.m_iv);
}

bool Redo_Log_Writer::write_buffer(byte *buf, size_t len) {
byte *write_buf = buf;

if (srv_redo_log_encrypt) {
IORequest req_type(IORequestLogWrite);
set_encryption_info(req_type);
IORequest req_type(IORequest::WRITE);
req_type.get_encryption_info().set(log_sys->m_encryption_metadata);
ut_ad(req_type.is_encrypted());

Encryption encryption(req_type.encryption_algorithm());
ulint dst_len = len;
write_buf =
encryption.encrypt_log(req_type, buf, len, scratch_buf, &dst_len);
ut_a(len == dst_len);
}

if (!encryption.encrypt_log(buf, len, scratch_buf)) {
xb::error() << "Failed to encrypt redo log";
return false;
}
write_buf = scratch_buf;
}
if (ds_write(log_file, write_buf, len)) {
xb::error() << "write to logfile failed";
return (false);
Expand Down Expand Up @@ -789,10 +783,10 @@ ssize_t Archived_Redo_Log_Reader::read_logfile(bool *finished) {
}

if (srv_redo_log_encrypt) {
IORequest req_type(IORequestLogRead);
set_encryption_info(req_type);
IORequest req_type(IORequest::READ);
req_type.get_encryption_info().set(log_sys->m_encryption_metadata);
Encryption encryption(req_type.encryption_algorithm());
auto err = encryption.decrypt_log(req_type, log_buf, len, scratch_buf);
auto err = encryption.decrypt_log(log_buf, len);
ut_a(err == DB_SUCCESS);
}

Expand Down Expand Up @@ -1108,13 +1102,10 @@ void Archived_Redo_Log_Monitor::thread_func() {
hdr_len -= n_read;
}
if (srv_redo_log_encrypt) {
ut::aligned_array_pointer<byte, OS_FILE_LOG_BLOCK_SIZE> scratch_buf;
scratch_buf.alloc_withkey(UT_NEW_THIS_FILE_PSI_KEY,
ut::Count{OS_FILE_LOG_BLOCK_SIZE});
IORequest req_type(IORequestLogRead);
set_encryption_info(req_type);
IORequest req_type(IORequest::READ);
req_type.get_encryption_info().set(log_sys->m_encryption_metadata);
Encryption encryption(req_type.encryption_algorithm());
auto err = encryption.decrypt_log(req_type, buf, hdr_len, scratch_buf);
auto err = encryption.decrypt_log(buf, hdr_len);
ut_a(err == DB_SUCCESS);
}
}
Expand Down

0 comments on commit 019b882

Please sign in to comment.