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