MDEV-14180 preparation: Rename key_rotation_list

- Rename the rotation list to default_encrypt_tables in
fil_system_t. Because rotation list naming could be
misleading when it comes to key version rotation

- Rename is_in_rotation_list to is_in_default_encrypt
in fil_space_t

- Rename keyrotate_next function to default_encrypt_next

fil_system_t::default_encrypt_next(): Find the next
suitable default encrypt table if beginning of
default_encrypt_tables list has been scheduled
to be deleted
parent be243ed9
......@@ -1380,52 +1380,65 @@ fil_crypt_return_iops(
fil_crypt_update_total_stat(state);
}
/** Return the next tablespace from rotation_list.
/** Return the next tablespace from default_encrypt_tables.
@param space previous tablespace (NULL to start from the start)
@param recheck whether the removal condition needs to be rechecked after
the encryption parameters were changed
@param encrypt expected state of innodb_encrypt_tables
@return the next tablespace to process (n_pending_ops incremented)
@retval NULL if this was the last */
inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space,
bool recheck, bool encrypt)
inline fil_space_t *fil_system_t::default_encrypt_next(
fil_space_t *space, bool recheck, bool encrypt)
{
ut_ad(mutex_own(&mutex));
sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it=
space && space->is_in_rotation_list ? space : rotation_list.begin();
space && space->is_in_default_encrypt
? space
: default_encrypt_tables.begin();
const sized_ilist<fil_space_t, rotation_list_tag_t>::iterator end=
rotation_list.end();
default_encrypt_tables.end();
if (space)
{
const bool released= !--space->n_pending_ops;
if (space->is_in_rotation_list)
if (space->is_in_default_encrypt)
{
while (++it != end &&
(!UT_LIST_GET_LEN(it->chain) || it->is_stopping()));
/* If one of the encryption threads already started the encryption
of the table then don't remove the unencrypted spaces from rotation list
/* If one of the encryption threads already started
the encryption of the table then don't remove the
unencrypted spaces from default encrypt list.
If there is a change in innodb_encrypt_tables variables value then
don't remove the last processed tablespace from the rotation list. */
If there is a change in innodb_encrypt_tables variables
value then don't remove the last processed tablespace
from the default encrypt list. */
if (released && (!recheck || space->crypt_data) &&
!encrypt == !srv_encrypt_tables)
{
ut_a(!rotation_list.empty());
rotation_list.remove(*space);
space->is_in_rotation_list= false;
ut_a(!default_encrypt_tables.empty());
default_encrypt_tables.remove(*space);
space->is_in_default_encrypt= false;
}
}
}
else while (it != end &&
(!UT_LIST_GET_LEN(it->chain) || it->is_stopping()))
{
/* Find the next suitable default encrypt table if
beginning of default_encrypt_tables list has been scheduled
to be deleted */
it++;
}
if (it == end)
return NULL;
space= &*it;
space->n_pending_ops++;
ut_ad(!space->is_stopping());
return space;
}
......@@ -1443,7 +1456,7 @@ static fil_space_t *fil_space_next(fil_space_t *space, bool recheck,
ut_ad(!space || space->n_pending_ops);
if (!srv_fil_crypt_rotate_key_age)
space= fil_system->keyrotate_next(space, recheck, encrypt);
space= fil_system->default_encrypt_next(space, recheck, encrypt);
else if (!space)
{
space= UT_LIST_GET_FIRST(fil_system->space_list);
......@@ -2335,9 +2348,9 @@ fil_crypt_set_thread_cnt(
}
}
/** Initialize the tablespace rotation_list
/** Initialize the tablespace default_encrypt_tables
if innodb_encryption_rotate_key_age=0. */
static void fil_crypt_rotation_list_fill()
static void fil_crypt_default_encrypt_tables_fill()
{
ut_ad(mutex_own(&fil_system->mutex));
......@@ -2345,7 +2358,7 @@ static void fil_crypt_rotation_list_fill()
space != NULL;
space = UT_LIST_GET_NEXT(space_list, space)) {
if (space->purpose != FIL_TYPE_TABLESPACE
|| space->is_in_rotation_list
|| space->is_in_default_encrypt
|| space->is_stopping()
|| UT_LIST_GET_LEN(space->chain) == 0) {
continue;
......@@ -2389,8 +2402,8 @@ static void fil_crypt_rotation_list_fill()
}
}
fil_system->rotation_list.push_back(*space);
space->is_in_rotation_list = true;
fil_system->default_encrypt_tables.push_back(*space);
space->is_in_default_encrypt = true;
}
}
......@@ -2405,7 +2418,7 @@ fil_crypt_set_rotate_key_age(
mutex_enter(&fil_system->mutex);
srv_fil_crypt_rotate_key_age = val;
if (val == 0) {
fil_crypt_rotation_list_fill();
fil_crypt_default_encrypt_tables_fill();
}
mutex_exit(&fil_system->mutex);
os_event_set(fil_crypt_threads_event);
......@@ -2436,7 +2449,7 @@ fil_crypt_set_encrypt_tables(
srv_encrypt_tables = val;
if (srv_fil_crypt_rotate_key_age == 0) {
fil_crypt_rotation_list_fill();
fil_crypt_default_encrypt_tables_fill();
}
mutex_exit(&fil_system->mutex);
......
......@@ -1244,10 +1244,9 @@ fil_space_detach(
space->is_in_unflushed_spaces = false;
}
if (space->is_in_rotation_list) {
fil_system->rotation_list.remove(*space);
space->is_in_rotation_list = false;
if (space->is_in_default_encrypt) {
fil_system->default_encrypt_tables.remove(*space);
space->is_in_default_encrypt = false;
}
UT_LIST_REMOVE(fil_system->space_list, space);
......@@ -1473,8 +1472,8 @@ fil_space_create(
srv_encrypt_tables)) {
/* Key rotation is not enabled, need to inform background
encryption threads. */
fil_system->rotation_list.push_back(*space);
space->is_in_rotation_list = true;
fil_system->default_encrypt_tables.push_back(*space);
space->is_in_default_encrypt = true;
mutex_exit(&fil_system->mutex);
mutex_enter(&fil_crypt_threads_mutex);
os_event_set(fil_crypt_threads_event);
......
......@@ -177,7 +177,7 @@ struct fil_space_t : ilist_node<unflushed_spaces_tag_t>,
bool is_in_unflushed_spaces;
/** Checks that this tablespace needs key rotation. */
bool is_in_rotation_list;
bool is_in_default_encrypt;
/** True if the device this filespace is on supports atomic writes */
bool atomic_write_supported;
......@@ -541,9 +541,9 @@ struct fil_system_t {
record has been written since
the latest redo log checkpoint.
Protected only by log_sys->mutex. */
ilist<fil_space_t, rotation_list_tag_t> rotation_list;
/*!< list of all file spaces needing
key rotation.*/
/** List of all file spaces need key rotation */
ilist<fil_space_t, rotation_list_tag_t> default_encrypt_tables;
bool space_id_reuse_warned;
/* !< TRUE if fil_space_create()
......@@ -556,15 +556,15 @@ struct fil_system_t {
@retval NULL if the tablespace does not exist or cannot be read */
fil_space_t* read_page0(ulint id);
/** Return the next tablespace from rotation_list.
/** Return the next tablespace from default_encrypt_tables list.
@param space previous tablespace (NULL to start from the start)
@param recheck whether the removal condition needs to be rechecked after
the encryption parameters were changed
@param encrypt expected state of innodb_encrypt_tables
@return the next tablespace to process (n_pending_ops incremented)
@retval NULL if this was the last */
inline fil_space_t* keyrotate_next(fil_space_t *space, bool recheck,
bool encrypt);
inline fil_space_t* default_encrypt_next(
fil_space_t *space, bool recheck, bool encrypt);
};
/** The tablespace memory cache. This variable is NULL before the module is
......
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