diff --git a/storage/innobase/arch/arch0log.cc b/storage/innobase/arch/arch0log.cc index ce900643a82..5e0812d0f6f 100644 --- a/storage/innobase/arch/arch0log.cc +++ b/storage/innobase/arch/arch0log.cc @@ -246,7 +246,7 @@ void Arch_Log_Sys::update_header(byte *header, lsn_t checkpoint_lsn) { byte *iv = redo_space->encryption_iv; dest = header + LOG_ENCRYPTION; - log_file_header_fill_encryption(dest, key, iv, false, false); + log_file_header_fill_encryption(dest, key, iv, false); } /** Start redo log archiving. diff --git a/storage/innobase/clone/clone0snapshot.cc b/storage/innobase/clone/clone0snapshot.cc index 86dc306b1fa..fad97e4bc8d 100644 --- a/storage/innobase/clone/clone0snapshot.cc +++ b/storage/innobase/clone/clone0snapshot.cc @@ -750,7 +750,7 @@ bool Clone_Snapshot::encrypt_key_in_log_header(byte *log_header, if (success) { /* Encrypt with master key and fill encryption information. */ success = Encryption::fill_encryption_info( - &encryption_key[0], &encryption_iv[0], encryption_info, false, true); + &encryption_key[0], &encryption_iv[0], encryption_info, true); } return (success); } @@ -775,7 +775,7 @@ bool Clone_Snapshot::encrypt_key_in_header(const page_size_t &page_size, /* Encrypt with master key and fill encryption information. */ success = Encryption::fill_encryption_info( - &encryption_key[0], &encryption_iv[0], encryption_info, false, true); + &encryption_key[0], &encryption_iv[0], encryption_info, true); if (!success) { return (false); } @@ -796,7 +796,7 @@ void Clone_Snapshot::decrypt_key_in_header(fil_space_t *space, /* Get tablespace encryption information. */ Encryption::fill_encryption_info(space->encryption_key, space->encryption_iv, - encryption_info, false, false); + encryption_info, false); /* Set encryption information in page. */ auto offset = fsp_header_get_encryption_offset(page_size); diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 80d1b819513..856c2632a8c 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -160,7 +160,7 @@ dberr_t dict_build_tablespace(trx_t *trx, Tablespace *tablespace) { mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); */ ut_a(!FSP_FLAGS_GET_TEMPORARY(tablespace->flags())); - bool ret = fsp_header_init(space, size, &mtr, false); + bool ret = fsp_header_init(space, size, &mtr); mtr_commit(&mtr); DBUG_EXECUTE_IF("fil_ibd_create_log", @@ -277,7 +277,7 @@ dberr_t dict_build_tablespace_for_table(dict_table_t *table, mtr_start(&mtr); - bool ret = fsp_header_init(table->space, size, &mtr, false); + bool ret = fsp_header_init(table->space, size, &mtr); if (ret) { fil_set_autoextend_size( diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index c99a391a522..0d77bbc324d 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -977,9 +977,8 @@ bool fsp_header_rotate_encryption(fil_space_t *space, byte *encrypt_info, DBUG_EXECUTE_IF("fsp_header_rotate_encryption_failure", return (false);); /* Fill encryption info. */ - if (!Encryption::fill_encryption_info(space->encryption_key, - space->encryption_iv, encrypt_info, - false, true)) { + if (!Encryption::fill_encryption_info( + space->encryption_key, space->encryption_iv, encrypt_info, true)) { return (false); } @@ -1016,8 +1015,7 @@ bool fsp_header_dict_get_server_version(uint *version) { return (false); } -bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr, - bool is_boot) { +bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr) { auto space = fil_space_get(space_id); ut_ad(space != nullptr); @@ -1086,7 +1084,7 @@ bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr, if (!Encryption::fill_encryption_info(space->encryption_key, space->encryption_iv, encryption_info, - is_boot, true)) { + true)) { space->encryption_type = Encryption::NONE; memset(space->encryption_key, 0, Encryption::KEY_LEN); memset(space->encryption_iv, 0, Encryption::KEY_LEN); @@ -4250,8 +4248,7 @@ static dberr_t init_before_encrypt_processing(fil_space_t *space, Encryption::random_value(iv); /* Prepare encrypted encryption information to be written on page 0. */ - if (!Encryption::fill_encryption_info(key, iv, encryption_info, false, - true)) { + if (!Encryption::fill_encryption_info(key, iv, encryption_info, true)) { ut_ad(false); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e0416060df7..647b8f97dc7 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3888,7 +3888,7 @@ static void innobase_post_recover() { } else { /* Enable encryption for UNDO tablespaces */ mutex_enter(&undo::ddl_mutex); - if (srv_enable_undo_encryption(true)) { + if (srv_enable_undo_encryption()) { ut_ad(false); srv_undo_log_encrypt = false; } @@ -3911,7 +3911,7 @@ static void innobase_post_recover() { srv_redo_log_encrypt = false; } else { /* Enable encryption for REDO log */ - if (srv_enable_redo_encryption(true)) { + if (srv_enable_redo_encryption()) { ut_ad(false); srv_redo_log_encrypt = false; } @@ -5121,7 +5121,7 @@ static bool dd_create_hardcoded(space_id_t space_id, const char *filename) { mtr_t mtr; mtr.start(); - bool ret = fsp_header_init(space_id, pages, &mtr, true); + bool ret = fsp_header_init(space_id, pages, &mtr); mtr.commit(); @@ -20862,7 +20862,7 @@ static int validate_innodb_undo_log_encrypt(THD *thd, SYS_VAR *var, void *save, mutex_enter(&undo::ddl_mutex); /* Enable encryption for UNDO tablespaces */ - bool ret = srv_enable_undo_encryption(false); + bool ret = srv_enable_undo_encryption(); if (!ret) { /* At this point, all UNDO tablespaces have been encrypted. */ @@ -20923,7 +20923,7 @@ static int validate_innodb_redo_log_encrypt(THD *thd, SYS_VAR *var, void *save, } /* Enable encryption for REDO tablespaces */ - bool ret = srv_enable_redo_encryption(false); + bool ret = srv_enable_redo_encryption(); if (!ret) { /* At this point, REDO log is set to be encrypted. */ diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index f1771c53032..ad428a2e23e 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -493,10 +493,8 @@ insert buffer tree root if space == 0. @param[in] space_id Space id @param[in] size Current size in blocks @param[in,out] mtr Mini-transaction -@param[in] is_boot If it's for bootstrap @return true on success, otherwise false. */ -bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr, - bool is_boot); +bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr); /** Increases the space size field of a space. @param[in] space_id Space id diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 99c0b65a67a..0785838df5b 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -874,9 +874,8 @@ bool log_read_encryption(); It just need to flush the file header block with current master key. @param[in] key encryption key @param[in] iv encryption iv -@param[in] is_boot if it is for bootstrap @return true if success. */ -bool log_write_encryption(byte *key, byte *iv, bool is_boot); +bool log_write_encryption(byte *key, byte *iv); /** Rotate the redo log encryption It will re-encrypt the redo log encryption metadata and write it to @@ -1297,10 +1296,9 @@ inline bool log_checkpointer_is_active(); @param[in,out] buf log file header @param[in] key encryption key @param[in] iv encryption iv -@param[in] is_boot if it's for bootstrap @param[in] encrypt_key encrypt with master key */ bool log_file_header_fill_encryption(byte *buf, byte *key, byte *iv, - bool is_boot, bool encrypt_key); + bool encrypt_key); /** Disable redo logging and persist the information. @param[in,out] log redo log */ diff --git a/storage/innobase/include/os0enc.h b/storage/innobase/include/os0enc.h index acd80800eff..50e3a243993 100644 --- a/storage/innobase/include/os0enc.h +++ b/storage/innobase/include/os0enc.h @@ -217,11 +217,10 @@ class Encryption { @param[in] key encryption key @param[in] iv encryption iv @param[in,out] encrypt_info encryption information - @param[in] is_boot if it's for bootstrap @param[in] encrypt_key encrypt with master key @return true if success. */ static bool fill_encryption_info(byte *key, byte *iv, byte *encrypt_info, - bool is_boot, bool encrypt_key) noexcept; + bool encrypt_key) noexcept; /** Get master key from encryption information @param[in] encrypt_info encryption information diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index dcefa0a881d..93f29c4b449 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -1019,24 +1019,16 @@ void srv_worker_thread(); /** Set encryption for UNDO tablespace with given space id. @param[in] space_id Undo tablespace id @param[in] mtr Mini-transaction -@param[in] is_boot true if it is called during server start up. @return false for success, true otherwise */ -bool set_undo_tablespace_encryption(space_id_t space_id, mtr_t *mtr, - bool is_boot); +bool set_undo_tablespace_encryption(space_id_t space_id, mtr_t *mtr); /** Enable UNDO tablespaces encryption. -@param[in] is_boot true if it is called during server start up. In this - case, default master key will be used which will be - rotated later with actual master key from keyring. @return false for success, true otherwise. */ -bool srv_enable_undo_encryption(bool is_boot); +bool srv_enable_undo_encryption(); /** Enable REDO log encryption. -@param[in] is_boot true if it is called during server start up. In this - case, default master key will be used which will be - rotated later with actual master key from keyring. @return false for success, true otherwise. */ -bool srv_enable_redo_encryption(bool is_boot); +bool srv_enable_redo_encryption(); /** Get count of tasks in the queue. @return number of tasks in queue */ diff --git a/storage/innobase/log/log0write.cc b/storage/innobase/log/log0write.cc index c9a43bdd8cc..3c659922610 100644 --- a/storage/innobase/log/log0write.cc +++ b/storage/innobase/log/log0write.cc @@ -2868,10 +2868,10 @@ bool log_read_encryption() { } bool log_file_header_fill_encryption(byte *buf, byte *key, byte *iv, - bool is_boot, bool encrypt_key) { + bool encrypt_key) { byte encryption_info[Encryption::INFO_SIZE]; - if (!Encryption::fill_encryption_info(key, iv, encryption_info, is_boot, + if (!Encryption::fill_encryption_info(key, iv, encryption_info, encrypt_key)) { return (false); } @@ -2883,7 +2883,7 @@ bool log_file_header_fill_encryption(byte *buf, byte *key, byte *iv, return (true); } -bool log_write_encryption(byte *key, byte *iv, bool is_boot) { +bool log_write_encryption(byte *key, byte *iv) { const page_id_t page_id{dict_sys_t::s_log_space_first_id, 0}; byte *log_block_buf = static_cast( ut::aligned_zalloc(OS_FILE_LOG_BLOCK_SIZE, OS_FILE_LOG_BLOCK_SIZE)); @@ -2895,7 +2895,7 @@ bool log_write_encryption(byte *key, byte *iv, bool is_boot) { iv = space->encryption_iv; } - if (!log_file_header_fill_encryption(log_block_buf, key, iv, is_boot, true)) { + if (!log_file_header_fill_encryption(log_block_buf, key, iv, true)) { ut::aligned_free(log_block_buf); return (false); } @@ -2917,7 +2917,7 @@ bool log_rotate_encryption() { } /* Rotate log tablespace */ - return (log_write_encryption(nullptr, nullptr, false)); + return (log_write_encryption(nullptr, nullptr)); } /** @} */ diff --git a/storage/innobase/os/os0enc.cc b/storage/innobase/os/os0enc.cc index 9e196a6a070..27db098d96b 100644 --- a/storage/innobase/os/os0enc.cc +++ b/storage/innobase/os/os0enc.cc @@ -449,7 +449,7 @@ void Encryption::get_master_key(uint32_t *master_key_id, } bool Encryption::fill_encryption_info(byte *key, byte *iv, byte *encrypt_info, - bool is_boot, bool encrypt_key) noexcept { + bool encrypt_key) noexcept { byte *master_key = nullptr; uint32_t master_key_id = DEFAULT_MASTER_KEY_ID; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 44f878a3ea4..180a2d967b9 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -2467,7 +2467,7 @@ static bool srv_master_do_shutdown_tasks( } /* Enable REDO tablespace encryption */ -bool srv_enable_redo_encryption(bool is_boot) { +bool srv_enable_redo_encryption() { /* Start to encrypt the redo log block from now on. */ fil_space_t *space = fil_space_get(dict_sys_t::s_log_space_first_id); @@ -2484,7 +2484,7 @@ bool srv_enable_redo_encryption(bool is_boot) { Encryption::random_value(key); Encryption::random_value(iv); - if (!log_write_encryption(key, iv, is_boot)) { + if (!log_write_encryption(key, iv)) { ib::error(ER_IB_MSG_1243); return true; } @@ -2502,8 +2502,7 @@ bool srv_enable_redo_encryption(bool is_boot) { } /* Set encryption for UNDO tablespace with given space id. */ -bool set_undo_tablespace_encryption(space_id_t space_id, mtr_t *mtr, - bool is_boot) { +bool set_undo_tablespace_encryption(space_id_t space_id, mtr_t *mtr) { ut_ad(fsp_is_undo_tablespace(space_id)); fil_space_t *space = fil_space_get(space_id); @@ -2519,7 +2518,7 @@ bool set_undo_tablespace_encryption(space_id_t space_id, mtr_t *mtr, memset(encrypt_info, 0, Encryption::INFO_SIZE); /* Fill up encryption info to be set */ - if (!Encryption::fill_encryption_info(key, iv, encrypt_info, is_boot, true)) { + if (!Encryption::fill_encryption_info(key, iv, encrypt_info, true)) { ib::error(ER_IB_MSG_1052, space->name); return true; } @@ -2545,7 +2544,7 @@ bool set_undo_tablespace_encryption(space_id_t space_id, mtr_t *mtr, } /* Enable UNDO tablespace encryption */ -bool srv_enable_undo_encryption(bool is_boot) { +bool srv_enable_undo_encryption() { /* Make sure undo::ddl_mutex is owned. */ ut_ad(mutex_own(&undo::ddl_mutex)); @@ -2575,7 +2574,7 @@ bool srv_enable_undo_encryption(bool is_boot) { mtr_start(&mtr); mtr_x_lock_space(space, &mtr); - if (set_undo_tablespace_encryption(undo_space->id(), &mtr, is_boot)) { + if (set_undo_tablespace_encryption(undo_space->id(), &mtr)) { mtr_commit(&mtr); undo_space->rsegs()->s_unlock(); undo::spaces->s_unlock(); diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 96569770ae5..a69186e6140 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -465,8 +465,8 @@ static dberr_t create_log_files(char *logfilename, size_t dirnamelen, lsn_t lsn, /* Write encryption information into the first log file header if redo log is set with encryption. */ if (FSP_FLAGS_GET_ENCRYPTION(log_space->flags) && - !log_write_encryption(log_space->encryption_key, log_space->encryption_iv, - true)) { + !log_write_encryption(log_space->encryption_key, + log_space->encryption_iv)) { return (DB_ERROR); } @@ -1244,7 +1244,7 @@ static dberr_t srv_undo_tablespaces_create() { the construction list should be created and filled with zeros. @param[in] create_new_db whether to create a new database @return DB_SUCCESS or error code */ -static dberr_t srv_undo_tablespaces_construct(bool create_new_db) { +static dberr_t srv_undo_tablespaces_construct() { mtr_t mtr; if (undo::s_under_construction.empty()) { @@ -1277,8 +1277,7 @@ static dberr_t srv_undo_tablespaces_construct(bool create_new_db) { mtr_x_lock(fil_space_get_latch(space_id), &mtr); - if (!fsp_header_init(space_id, UNDO_INITIAL_SIZE_IN_PAGES, &mtr, - create_new_db)) { + if (!fsp_header_init(space_id, UNDO_INITIAL_SIZE_IN_PAGES, &mtr)) { ib::error(ER_IB_MSG_1093, ulong{undo::id2num(space_id)}); mtr_commit(&mtr); @@ -1295,7 +1294,7 @@ static dberr_t srv_undo_tablespaces_construct(bool create_new_db) { } if (srv_undo_log_encrypt) { - ut_d(bool ret =) srv_enable_undo_encryption(false); + ut_d(bool ret =) srv_enable_undo_encryption(); ut_ad(!ret); } @@ -1438,7 +1437,7 @@ dberr_t srv_undo_tablespace_create(const char *space_name, undo::spaces->x_unlock(); /* Write header and RSEG_ARRAY pages to this undo tablespace. */ - err = srv_undo_tablespaces_construct(false); + err = srv_undo_tablespaces_construct(); if (err != DB_SUCCESS) { goto cleanup_and_exit; } @@ -1530,7 +1529,7 @@ static dberr_t srv_undo_tablespaces_init(bool create_new_db) { header pages, rseg_array pages, and rollback segments. Then delete any undo truncation log files and clear the construction list. This list includes any tablespace newly created or fixed-up. */ - err = srv_undo_tablespaces_construct(create_new_db); + err = srv_undo_tablespaces_construct(); if (err != DB_SUCCESS) { mutex_exit(&undo::ddl_mutex); return (err); @@ -1619,7 +1618,7 @@ static dberr_t srv_open_tmp_tablespace(bool create_new_db, mtr_start(&mtr); mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); - fsp_header_init(tmp_space->space_id(), size, &mtr, false); + fsp_header_init(tmp_space->space_id(), size, &mtr); mtr_commit(&mtr); } else { @@ -2382,7 +2381,7 @@ files_checked: mtr_start(&mtr); - bool ret = fsp_header_init(0, sum_of_new_sizes, &mtr, false); + bool ret = fsp_header_init(0, sum_of_new_sizes, &mtr); mtr_commit(&mtr); diff --git a/storage/innobase/srv/srv0tmp.cc b/storage/innobase/srv/srv0tmp.cc index 6a94a60ed4a..056c6e9938c 100644 --- a/storage/innobase/srv/srv0tmp.cc +++ b/storage/innobase/srv/srv0tmp.cc @@ -115,8 +115,7 @@ dberr_t Tablespace::create() { mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); - bool ret = - fsp_header_init(m_space_id, FIL_IBT_FILE_INITIAL_SIZE, &mtr, false); + bool ret = fsp_header_init(m_space_id, FIL_IBT_FILE_INITIAL_SIZE, &mtr); mtr_commit(&mtr); if (!ret) { @@ -147,7 +146,7 @@ bool Tablespace::truncate() { mtr_start(&mtr); mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); - fsp_header_init(m_space_id, FIL_IBT_FILE_INITIAL_SIZE, &mtr, false); + fsp_header_init(m_space_id, FIL_IBT_FILE_INITIAL_SIZE, &mtr); mtr_commit(&mtr); return true; diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 80ff070f312..55c1dcaec5b 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -2096,11 +2096,11 @@ bool trx_undo_truncate_tablespace(undo::Tablespace *marked_space) { mtr.start(); - fsp_header_init(new_space_id, n_pages, &mtr, false); + fsp_header_init(new_space_id, n_pages, &mtr); /* If tablespace is to be encrypted, encrypt it now */ if (is_encrypted && srv_undo_log_encrypt) { - ut_d(bool ret =) set_undo_tablespace_encryption(new_space_id, &mtr, false); + ut_d(bool ret =) set_undo_tablespace_encryption(new_space_id, &mtr); /* Don't expect any error here (unless keyring plugin is uninstalled). In that case too, continue truncation processing of tablespace. */ ut_ad(!ret);