Skip to content

Commit 7d2c338

Browse files
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
1 parent be243ed commit 7d2c338

File tree

3 files changed

+46
-34
lines changed

3 files changed

+46
-34
lines changed

storage/innobase/fil/fil0crypt.cc

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,52 +1380,65 @@ fil_crypt_return_iops(
13801380
fil_crypt_update_total_stat(state);
13811381
}
13821382

1383-
/** Return the next tablespace from rotation_list.
1383+
/** Return the next tablespace from default_encrypt_tables.
13841384
@param space previous tablespace (NULL to start from the start)
13851385
@param recheck whether the removal condition needs to be rechecked after
13861386
the encryption parameters were changed
13871387
@param encrypt expected state of innodb_encrypt_tables
13881388
@return the next tablespace to process (n_pending_ops incremented)
13891389
@retval NULL if this was the last */
1390-
inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space,
1391-
bool recheck, bool encrypt)
1390+
inline fil_space_t *fil_system_t::default_encrypt_next(
1391+
fil_space_t *space, bool recheck, bool encrypt)
13921392
{
13931393
ut_ad(mutex_own(&mutex));
13941394

13951395
sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it=
1396-
space && space->is_in_rotation_list ? space : rotation_list.begin();
1396+
space && space->is_in_default_encrypt
1397+
? space
1398+
: default_encrypt_tables.begin();
13971399
const sized_ilist<fil_space_t, rotation_list_tag_t>::iterator end=
1398-
rotation_list.end();
1400+
default_encrypt_tables.end();
13991401

14001402
if (space)
14011403
{
14021404
const bool released= !--space->n_pending_ops;
14031405

1404-
if (space->is_in_rotation_list)
1406+
if (space->is_in_default_encrypt)
14051407
{
14061408
while (++it != end &&
14071409
(!UT_LIST_GET_LEN(it->chain) || it->is_stopping()));
14081410

1409-
/* If one of the encryption threads already started the encryption
1410-
of the table then don't remove the unencrypted spaces from rotation list
1411+
/* If one of the encryption threads already started
1412+
the encryption of the table then don't remove the
1413+
unencrypted spaces from default encrypt list.
14111414
1412-
If there is a change in innodb_encrypt_tables variables value then
1413-
don't remove the last processed tablespace from the rotation list. */
1415+
If there is a change in innodb_encrypt_tables variables
1416+
value then don't remove the last processed tablespace
1417+
from the default encrypt list. */
14141418
if (released && (!recheck || space->crypt_data) &&
14151419
!encrypt == !srv_encrypt_tables)
14161420
{
1417-
ut_a(!rotation_list.empty());
1418-
rotation_list.remove(*space);
1419-
space->is_in_rotation_list= false;
1421+
ut_a(!default_encrypt_tables.empty());
1422+
default_encrypt_tables.remove(*space);
1423+
space->is_in_default_encrypt= false;
14201424
}
14211425
}
14221426
}
1427+
else while (it != end &&
1428+
(!UT_LIST_GET_LEN(it->chain) || it->is_stopping()))
1429+
{
1430+
/* Find the next suitable default encrypt table if
1431+
beginning of default_encrypt_tables list has been scheduled
1432+
to be deleted */
1433+
it++;
1434+
}
14231435

14241436
if (it == end)
14251437
return NULL;
14261438

14271439
space= &*it;
14281440
space->n_pending_ops++;
1441+
ut_ad(!space->is_stopping());
14291442
return space;
14301443
}
14311444

@@ -1443,7 +1456,7 @@ static fil_space_t *fil_space_next(fil_space_t *space, bool recheck,
14431456
ut_ad(!space || space->n_pending_ops);
14441457

14451458
if (!srv_fil_crypt_rotate_key_age)
1446-
space= fil_system->keyrotate_next(space, recheck, encrypt);
1459+
space= fil_system->default_encrypt_next(space, recheck, encrypt);
14471460
else if (!space)
14481461
{
14491462
space= UT_LIST_GET_FIRST(fil_system->space_list);
@@ -2335,17 +2348,17 @@ fil_crypt_set_thread_cnt(
23352348
}
23362349
}
23372350

2338-
/** Initialize the tablespace rotation_list
2351+
/** Initialize the tablespace default_encrypt_tables
23392352
if innodb_encryption_rotate_key_age=0. */
2340-
static void fil_crypt_rotation_list_fill()
2353+
static void fil_crypt_default_encrypt_tables_fill()
23412354
{
23422355
ut_ad(mutex_own(&fil_system->mutex));
23432356

23442357
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system->space_list);
23452358
space != NULL;
23462359
space = UT_LIST_GET_NEXT(space_list, space)) {
23472360
if (space->purpose != FIL_TYPE_TABLESPACE
2348-
|| space->is_in_rotation_list
2361+
|| space->is_in_default_encrypt
23492362
|| space->is_stopping()
23502363
|| UT_LIST_GET_LEN(space->chain) == 0) {
23512364
continue;
@@ -2389,8 +2402,8 @@ static void fil_crypt_rotation_list_fill()
23892402
}
23902403
}
23912404

2392-
fil_system->rotation_list.push_back(*space);
2393-
space->is_in_rotation_list = true;
2405+
fil_system->default_encrypt_tables.push_back(*space);
2406+
space->is_in_default_encrypt = true;
23942407
}
23952408
}
23962409

@@ -2405,7 +2418,7 @@ fil_crypt_set_rotate_key_age(
24052418
mutex_enter(&fil_system->mutex);
24062419
srv_fil_crypt_rotate_key_age = val;
24072420
if (val == 0) {
2408-
fil_crypt_rotation_list_fill();
2421+
fil_crypt_default_encrypt_tables_fill();
24092422
}
24102423
mutex_exit(&fil_system->mutex);
24112424
os_event_set(fil_crypt_threads_event);
@@ -2436,7 +2449,7 @@ fil_crypt_set_encrypt_tables(
24362449
srv_encrypt_tables = val;
24372450

24382451
if (srv_fil_crypt_rotate_key_age == 0) {
2439-
fil_crypt_rotation_list_fill();
2452+
fil_crypt_default_encrypt_tables_fill();
24402453
}
24412454

24422455
mutex_exit(&fil_system->mutex);

storage/innobase/fil/fil0fil.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,9 @@ fil_space_detach(
12441244
space->is_in_unflushed_spaces = false;
12451245
}
12461246

1247-
if (space->is_in_rotation_list) {
1248-
1249-
fil_system->rotation_list.remove(*space);
1250-
space->is_in_rotation_list = false;
1247+
if (space->is_in_default_encrypt) {
1248+
fil_system->default_encrypt_tables.remove(*space);
1249+
space->is_in_default_encrypt = false;
12511250
}
12521251

12531252
UT_LIST_REMOVE(fil_system->space_list, space);
@@ -1473,8 +1472,8 @@ fil_space_create(
14731472
srv_encrypt_tables)) {
14741473
/* Key rotation is not enabled, need to inform background
14751474
encryption threads. */
1476-
fil_system->rotation_list.push_back(*space);
1477-
space->is_in_rotation_list = true;
1475+
fil_system->default_encrypt_tables.push_back(*space);
1476+
space->is_in_default_encrypt = true;
14781477
mutex_exit(&fil_system->mutex);
14791478
mutex_enter(&fil_crypt_threads_mutex);
14801479
os_event_set(fil_crypt_threads_event);

storage/innobase/include/fil0fil.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ struct fil_space_t : ilist_node<unflushed_spaces_tag_t>,
177177
bool is_in_unflushed_spaces;
178178

179179
/** Checks that this tablespace needs key rotation. */
180-
bool is_in_rotation_list;
180+
bool is_in_default_encrypt;
181181

182182
/** True if the device this filespace is on supports atomic writes */
183183
bool atomic_write_supported;
@@ -541,9 +541,9 @@ struct fil_system_t {
541541
record has been written since
542542
the latest redo log checkpoint.
543543
Protected only by log_sys->mutex. */
544-
ilist<fil_space_t, rotation_list_tag_t> rotation_list;
545-
/*!< list of all file spaces needing
546-
key rotation.*/
544+
545+
/** List of all file spaces need key rotation */
546+
ilist<fil_space_t, rotation_list_tag_t> default_encrypt_tables;
547547

548548
bool space_id_reuse_warned;
549549
/* !< TRUE if fil_space_create()
@@ -556,15 +556,15 @@ struct fil_system_t {
556556
@retval NULL if the tablespace does not exist or cannot be read */
557557
fil_space_t* read_page0(ulint id);
558558

559-
/** Return the next tablespace from rotation_list.
559+
/** Return the next tablespace from default_encrypt_tables list.
560560
@param space previous tablespace (NULL to start from the start)
561561
@param recheck whether the removal condition needs to be rechecked after
562562
the encryption parameters were changed
563563
@param encrypt expected state of innodb_encrypt_tables
564564
@return the next tablespace to process (n_pending_ops incremented)
565565
@retval NULL if this was the last */
566-
inline fil_space_t* keyrotate_next(fil_space_t *space, bool recheck,
567-
bool encrypt);
566+
inline fil_space_t* default_encrypt_next(
567+
fil_space_t *space, bool recheck, bool encrypt);
568568
};
569569

570570
/** The tablespace memory cache. This variable is NULL before the module is

0 commit comments

Comments
 (0)