Commit 1274bb77 authored by Eugene Kosov's avatar Eugene Kosov

MDEV-25223 change fil_system_t::space_list and fil_system_t::named_spaces from UT_LIST to ilist

Mostly a refactoring. Also, debug functions were added for ease of life while debugging
parent cb545f11
...@@ -588,36 +588,20 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback); ...@@ -588,36 +588,20 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback);
/* ======== Datafiles iterator ======== */ /* ======== Datafiles iterator ======== */
struct datafiles_iter_t { struct datafiles_iter_t {
fil_space_t *space; space_list_t::iterator space = fil_system.space_list.end();
fil_node_t *node; fil_node_t *node = nullptr;
ibool started; bool started = false;
pthread_mutex_t mutex; std::mutex mutex;
}; };
/* ======== Datafiles iterator ======== */ /* ======== Datafiles iterator ======== */
static
datafiles_iter_t *
datafiles_iter_new()
{
datafiles_iter_t *it;
it = static_cast<datafiles_iter_t *>(malloc(sizeof(datafiles_iter_t)));
pthread_mutex_init(&it->mutex, NULL);
it->space = NULL;
it->node = NULL;
it->started = FALSE;
return it;
}
static static
fil_node_t * fil_node_t *
datafiles_iter_next(datafiles_iter_t *it) datafiles_iter_next(datafiles_iter_t *it)
{ {
fil_node_t *new_node; fil_node_t *new_node;
pthread_mutex_lock(&it->mutex); std::lock_guard<std::mutex> _(it->mutex);
if (it->node == NULL) { if (it->node == NULL) {
if (it->started) if (it->started)
...@@ -629,34 +613,25 @@ datafiles_iter_next(datafiles_iter_t *it) ...@@ -629,34 +613,25 @@ datafiles_iter_next(datafiles_iter_t *it)
goto end; goto end;
} }
it->space = (it->space == NULL) ? it->space = (it->space == fil_system.space_list.end()) ?
UT_LIST_GET_FIRST(fil_system.space_list) : fil_system.space_list.begin() :
UT_LIST_GET_NEXT(space_list, it->space); std::next(it->space);
while (it->space != NULL && while (it->space != fil_system.space_list.end() &&
(it->space->purpose != FIL_TYPE_TABLESPACE || (it->space->purpose != FIL_TYPE_TABLESPACE ||
UT_LIST_GET_LEN(it->space->chain) == 0)) UT_LIST_GET_LEN(it->space->chain) == 0))
it->space = UT_LIST_GET_NEXT(space_list, it->space); ++it->space;
if (it->space == NULL) if (it->space == fil_system.space_list.end())
goto end; goto end;
it->node = UT_LIST_GET_FIRST(it->space->chain); it->node = UT_LIST_GET_FIRST(it->space->chain);
end: end:
new_node = it->node; new_node = it->node;
pthread_mutex_unlock(&it->mutex);
return new_node; return new_node;
} }
static
void
datafiles_iter_free(datafiles_iter_t *it)
{
pthread_mutex_destroy(&it->mutex);
free(it);
}
#ifndef DBUG_OFF #ifndef DBUG_OFF
struct dbug_thread_param_t struct dbug_thread_param_t
{ {
...@@ -750,18 +725,15 @@ static void dbug_start_query_thread( ...@@ -750,18 +725,15 @@ static void dbug_start_query_thread(
void mdl_lock_all() void mdl_lock_all()
{ {
mdl_lock_init(); mdl_lock_init();
datafiles_iter_t *it = datafiles_iter_new(); datafiles_iter_t it;
if (!it)
return;
while (fil_node_t *node = datafiles_iter_next(it)){ while (fil_node_t *node = datafiles_iter_next(&it)) {
if (fil_is_user_tablespace_id(node->space->id) if (fil_is_user_tablespace_id(node->space->id)
&& check_if_skip_table(node->space->name)) && check_if_skip_table(node->space->name))
continue; continue;
mdl_lock_table(node->space->id); mdl_lock_table(node->space->id);
} }
datafiles_iter_free(it);
} }
...@@ -4441,11 +4413,7 @@ static bool xtrabackup_backup_func() ...@@ -4441,11 +4413,7 @@ static bool xtrabackup_backup_func()
"Waiting for table metadata lock", 0, 0);); "Waiting for table metadata lock", 0, 0););
} }
datafiles_iter_t *it = datafiles_iter_new(); datafiles_iter_t it;
if (it == NULL) {
msg("mariabackup: Error: datafiles_iter_new() failed.");
goto fail;
}
/* Create data copying threads */ /* Create data copying threads */
data_threads = (data_thread_ctxt_t *) data_threads = (data_thread_ctxt_t *)
...@@ -4454,7 +4422,7 @@ static bool xtrabackup_backup_func() ...@@ -4454,7 +4422,7 @@ static bool xtrabackup_backup_func()
pthread_mutex_init(&count_mutex, NULL); pthread_mutex_init(&count_mutex, NULL);
for (i = 0; i < (uint) xtrabackup_parallel; i++) { for (i = 0; i < (uint) xtrabackup_parallel; i++) {
data_threads[i].it = it; data_threads[i].it = &it;
data_threads[i].num = i+1; data_threads[i].num = i+1;
data_threads[i].count = &count; data_threads[i].count = &count;
data_threads[i].count_mutex = &count_mutex; data_threads[i].count_mutex = &count_mutex;
...@@ -4475,7 +4443,6 @@ static bool xtrabackup_backup_func() ...@@ -4475,7 +4443,6 @@ static bool xtrabackup_backup_func()
pthread_mutex_destroy(&count_mutex); pthread_mutex_destroy(&count_mutex);
free(data_threads); free(data_threads);
datafiles_iter_free(it);
} }
bool ok = backup_start(corrupted_pages); bool ok = backup_start(corrupted_pages);
...@@ -4629,10 +4596,8 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages) ...@@ -4629,10 +4596,8 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
// Load and copy new tables. // Load and copy new tables.
// Close all datanodes first, reload only new tables. // Close all datanodes first, reload only new tables.
std::vector<fil_node_t *> all_nodes; std::vector<fil_node_t *> all_nodes;
datafiles_iter_t *it = datafiles_iter_new(); datafiles_iter_t it;
if (!it) while (fil_node_t *node = datafiles_iter_next(&it)) {
return;
while (fil_node_t *node = datafiles_iter_next(it)) {
all_nodes.push_back(node); all_nodes.push_back(node);
} }
for (size_t i = 0; i < all_nodes.size(); i++) { for (size_t i = 0; i < all_nodes.size(); i++) {
...@@ -4646,7 +4611,6 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages) ...@@ -4646,7 +4611,6 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
} }
fil_space_free(n->space->id, false); fil_space_free(n->space->id, false);
} }
datafiles_iter_free(it);
DBUG_EXECUTE_IF("check_mdl_lock_works", DBUG_ASSERT(new_tables.size() == 0);); DBUG_EXECUTE_IF("check_mdl_lock_works", DBUG_ASSERT(new_tables.size() == 0););
for (std::set<std::string>::iterator iter = new_tables.begin(); for (std::set<std::string>::iterator iter = new_tables.begin();
...@@ -4657,11 +4621,9 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages) ...@@ -4657,11 +4621,9 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
xb_load_single_table_tablespace(*iter, false); xb_load_single_table_tablespace(*iter, false);
} }
it = datafiles_iter_new(); datafiles_iter_t it2;
if (!it)
return;
while (fil_node_t *node = datafiles_iter_next(it)) { while (fil_node_t *node = datafiles_iter_next(&it2)) {
fil_space_t * space = node->space; fil_space_t * space = node->space;
if (!fil_is_user_tablespace_id(space->id)) if (!fil_is_user_tablespace_id(space->id))
continue; continue;
...@@ -4670,8 +4632,6 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages) ...@@ -4670,8 +4632,6 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
xtrabackup_copy_datafile(node, 0, dest_name.c_str(), wf_write_through, xtrabackup_copy_datafile(node, 0, dest_name.c_str(), wf_write_through,
corrupted_pages); corrupted_pages);
} }
datafiles_iter_free(it);
} }
/* ================= prepare ================= */ /* ================= prepare ================= */
...@@ -4787,10 +4747,8 @@ xb_space_create_file( ...@@ -4787,10 +4747,8 @@ xb_space_create_file(
static fil_space_t* fil_space_get_by_name(const char* name) static fil_space_t* fil_space_get_by_name(const char* name)
{ {
mysql_mutex_assert_owner(&fil_system.mutex); mysql_mutex_assert_owner(&fil_system.mutex);
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t& space :fil_system.space_list)
space != NULL; if (!strcmp(space.name, name)) return &space;
space = UT_LIST_GET_NEXT(space_list, space))
if (!strcmp(space->name, name)) return space;
return NULL; return NULL;
} }
......
...@@ -75,8 +75,10 @@ template <class T, class Tag= void> class ilist ...@@ -75,8 +75,10 @@ template <class T, class Tag= void> class ilist
typedef T *pointer; typedef T *pointer;
typedef T &reference; typedef T &reference;
Iterator(ListNode *node) noexcept : node_(node) explicit Iterator(ListNode *node) noexcept : node_(node)
{ DBUG_ASSERT(node_ != nullptr); } {
DBUG_ASSERT(node_ != nullptr);
}
Iterator &operator++() noexcept Iterator &operator++() noexcept
{ {
...@@ -193,7 +195,7 @@ template <class T, class Tag= void> class ilist ...@@ -193,7 +195,7 @@ template <class T, class Tag= void> class ilist
curr->next= nullptr; curr->next= nullptr;
#endif #endif
return next; return Iterator(next);
} }
void push_back(reference value) noexcept { insert(end(), value); } void push_back(reference value) noexcept { insert(end(), value); }
......
...@@ -114,7 +114,6 @@ void fil_space_crypt_init() ...@@ -114,7 +114,6 @@ void fil_space_crypt_init()
{ {
pthread_cond_init(&fil_crypt_throttle_sleep_cond, nullptr); pthread_cond_init(&fil_crypt_throttle_sleep_cond, nullptr);
mysql_mutex_init(0, &crypt_stat_mutex, nullptr); mysql_mutex_init(0, &crypt_stat_mutex, nullptr);
memset(&crypt_stat, 0, sizeof crypt_stat);
} }
/********************************************************************* /*********************************************************************
...@@ -1121,25 +1120,21 @@ static bool fil_crypt_start_encrypting_space(fil_space_t* space) ...@@ -1121,25 +1120,21 @@ static bool fil_crypt_start_encrypting_space(fil_space_t* space)
/** State of a rotation thread */ /** State of a rotation thread */
struct rotate_thread_t { struct rotate_thread_t {
explicit rotate_thread_t(uint no) { explicit rotate_thread_t(uint no) : thread_no(no) {}
memset(this, 0, sizeof(* this));
thread_no = no;
first = true;
estimated_max_iops = 20;
}
uint thread_no; uint thread_no;
bool first; /*!< is position before first space */ bool first = true; /*!< is position before first space */
fil_space_t* space; /*!< current space or NULL */ space_list_t::iterator space
uint32_t offset; /*!< current page number */ = fil_system.space_list.end();/*!< current space or .end() */
ulint batch; /*!< #pages to rotate */ uint32_t offset = 0; /*!< current page number */
uint min_key_version_found;/*!< min key version found but not rotated */ ulint batch = 0; /*!< #pages to rotate */
lsn_t end_lsn; /*!< max lsn when rotating this space */ uint min_key_version_found = 0; /*!< min key version found but not rotated */
lsn_t end_lsn = 0; /*!< max lsn when rotating this space */
uint estimated_max_iops; /*!< estimation of max iops */
uint allocated_iops; /*!< allocated iops */ uint estimated_max_iops = 20;/*!< estimation of max iops */
ulint cnt_waited; /*!< #times waited during this slot */ uint allocated_iops = 0; /*!< allocated iops */
uintmax_t sum_waited_us; /*!< wait time during this slot */ ulint cnt_waited = 0; /*!< #times waited during this slot */
uintmax_t sum_waited_us = 0; /*!< wait time during this slot */
fil_crypt_stat_t crypt_stat; // statistics fil_crypt_stat_t crypt_stat; // statistics
...@@ -1177,7 +1172,7 @@ fil_crypt_space_needs_rotation( ...@@ -1177,7 +1172,7 @@ fil_crypt_space_needs_rotation(
{ {
mysql_mutex_assert_not_owner(&fil_crypt_threads_mutex); mysql_mutex_assert_not_owner(&fil_crypt_threads_mutex);
fil_space_t* space = state->space; fil_space_t* space = &*state->space;
ut_ad(space->referenced()); ut_ad(space->referenced());
ut_ad(space->purpose == FIL_TYPE_TABLESPACE); ut_ad(space->purpose == FIL_TYPE_TABLESPACE);
...@@ -1268,7 +1263,10 @@ fil_crypt_update_total_stat( ...@@ -1268,7 +1263,10 @@ fil_crypt_update_total_stat(
mysql_mutex_unlock(&crypt_stat_mutex); mysql_mutex_unlock(&crypt_stat_mutex);
// make new estimate "current" estimate // make new estimate "current" estimate
memset(&state->crypt_stat, 0, sizeof(state->crypt_stat)); state->crypt_stat.pages_read_from_cache = 0;
state->crypt_stat.pages_read_from_disk = 0;
state->crypt_stat.pages_modified = 0;
state->crypt_stat.pages_flushed = 0;
// record our old (current) estimate // record our old (current) estimate
state->crypt_stat.estimated_iops = state->estimated_max_iops; state->crypt_stat.estimated_iops = state->estimated_max_iops;
} }
...@@ -1432,10 +1430,10 @@ inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space, ...@@ -1432,10 +1430,10 @@ inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space,
{ {
mysql_mutex_assert_owner(&mutex); mysql_mutex_assert_owner(&mutex);
sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it= auto it= space && space->is_in_rotation_list
space && space->is_in_rotation_list ? space : rotation_list.begin(); ? sized_ilist<fil_space_t, rotation_list_tag_t>::iterator(space)
const sized_ilist<fil_space_t, rotation_list_tag_t>::iterator end= : rotation_list.begin();
rotation_list.end(); const auto end= rotation_list.end();
if (space) if (space)
{ {
...@@ -1485,25 +1483,29 @@ encryption parameters were changed ...@@ -1485,25 +1483,29 @@ encryption parameters were changed
@return the next tablespace @return the next tablespace
@retval fil_system.temp_space if there is no work to do @retval fil_system.temp_space if there is no work to do
@retval nullptr upon reaching the end of the iteration */ @retval nullptr upon reaching the end of the iteration */
inline fil_space_t *fil_space_t::next(fil_space_t *space, bool recheck, space_list_t::iterator fil_space_t::next(space_list_t::iterator space,
bool encrypt) bool recheck, bool encrypt)
{ {
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
if (!srv_fil_crypt_rotate_key_age) if (!srv_fil_crypt_rotate_key_age)
space= fil_system.keyrotate_next(space, recheck, encrypt); {
space= space_list_t::iterator(fil_system.keyrotate_next(
space != fil_system.space_list.end() ? &*space : nullptr, recheck,
encrypt));
}
else else
{ {
if (!space) if (space == fil_system.space_list.end())
space= UT_LIST_GET_FIRST(fil_system.space_list); space= fil_system.space_list.begin();
else else
{ {
/* Move on to the next fil_space_t */ /* Move on to the next fil_space_t */
space->release(); space->release();
space= UT_LIST_GET_NEXT(space_list, space); ++space;
} }
for (; space; space= UT_LIST_GET_NEXT(space_list, space)) for (; space != fil_system.space_list.end(); ++space)
{ {
if (space->purpose != FIL_TYPE_TABLESPACE) if (space->purpose != FIL_TYPE_TABLESPACE)
continue; continue;
...@@ -1533,9 +1535,9 @@ static bool fil_crypt_find_space_to_rotate( ...@@ -1533,9 +1535,9 @@ static bool fil_crypt_find_space_to_rotate(
/* we need iops to start rotating */ /* we need iops to start rotating */
do { do {
if (state->should_shutdown()) { if (state->should_shutdown()) {
if (state->space) { if (state->space != fil_system.space_list.end()) {
state->space->release(); state->space->release();
state->space = NULL; state->space = fil_system.space_list.end();
} }
return false; return false;
} }
...@@ -1543,18 +1545,19 @@ static bool fil_crypt_find_space_to_rotate( ...@@ -1543,18 +1545,19 @@ static bool fil_crypt_find_space_to_rotate(
if (state->first) { if (state->first) {
state->first = false; state->first = false;
if (state->space) { if (state->space != fil_system.space_list.end()) {
state->space->release(); state->space->release();
} }
state->space = NULL; state->space = fil_system.space_list.end();
} }
state->space = fil_space_t::next(state->space, *recheck, state->space = fil_space_t::next(state->space, *recheck,
key_state->key_version != 0); key_state->key_version != 0);
bool wake = true; bool wake = true;
while (state->space) { while (state->space != fil_system.space_list.end()) {
if (state->space == fil_system.temp_space) { if (state->space
== space_list_t::iterator(fil_system.temp_space)) {
wake = false; wake = false;
goto done; goto done;
} }
...@@ -1562,7 +1565,7 @@ static bool fil_crypt_find_space_to_rotate( ...@@ -1562,7 +1565,7 @@ static bool fil_crypt_find_space_to_rotate(
if (state->should_shutdown()) { if (state->should_shutdown()) {
state->space->release(); state->space->release();
done: done:
state->space = nullptr; state->space = fil_system.space_list.end();
break; break;
} }
...@@ -1571,7 +1574,7 @@ static bool fil_crypt_find_space_to_rotate( ...@@ -1571,7 +1574,7 @@ static bool fil_crypt_find_space_to_rotate(
page 0 for this tablespace, we need to read it before page 0 for this tablespace, we need to read it before
we can continue. */ we can continue. */
if (!state->space->crypt_data) { if (!state->space->crypt_data) {
fil_crypt_read_crypt_data(state->space); fil_crypt_read_crypt_data(&*state->space);
} }
if (fil_crypt_space_needs_rotation(state, key_state, recheck)) { if (fil_crypt_space_needs_rotation(state, key_state, recheck)) {
...@@ -1654,16 +1657,17 @@ fil_crypt_find_page_to_rotate( ...@@ -1654,16 +1657,17 @@ fil_crypt_find_page_to_rotate(
rotate_thread_t* state) rotate_thread_t* state)
{ {
ulint batch = srv_alloc_time * state->allocated_iops; ulint batch = srv_alloc_time * state->allocated_iops;
fil_space_t* space = state->space;
ut_ad(!space || space->referenced()); ut_ad(state->space == fil_system.space_list.end()
|| state->space->referenced());
/* If space is marked to be dropped stop rotation. */ /* If space is marked to be dropped stop rotation. */
if (!space || space->is_stopping()) { if (state->space == fil_system.space_list.end()
|| state->space->is_stopping()) {
return false; return false;
} }
fil_space_crypt_t *crypt_data = space->crypt_data; fil_space_crypt_t *crypt_data = state->space->crypt_data;
mysql_mutex_lock(&crypt_data->mutex); mysql_mutex_lock(&crypt_data->mutex);
ut_ad(key_state->key_id == crypt_data->key_id); ut_ad(key_state->key_id == crypt_data->key_id);
...@@ -1703,7 +1707,7 @@ fil_crypt_get_page_throttle( ...@@ -1703,7 +1707,7 @@ fil_crypt_get_page_throttle(
mtr_t* mtr, mtr_t* mtr,
ulint* sleeptime_ms) ulint* sleeptime_ms)
{ {
fil_space_t* space = state->space; fil_space_t* space = &*state->space;
const ulint zip_size = space->zip_size(); const ulint zip_size = space->zip_size();
const page_id_t page_id(space->id, offset); const page_id_t page_id(space->id, offset);
ut_ad(space->referenced()); ut_ad(space->referenced());
...@@ -1773,7 +1777,7 @@ fil_crypt_rotate_page( ...@@ -1773,7 +1777,7 @@ fil_crypt_rotate_page(
const key_state_t* key_state, const key_state_t* key_state,
rotate_thread_t* state) rotate_thread_t* state)
{ {
fil_space_t*space = state->space; fil_space_t *space = &*state->space;
ulint space_id = space->id; ulint space_id = space->id;
uint32_t offset = state->offset; uint32_t offset = state->offset;
ulint sleeptime_ms = 0; ulint sleeptime_ms = 0;
...@@ -1944,7 +1948,7 @@ void ...@@ -1944,7 +1948,7 @@ void
fil_crypt_flush_space( fil_crypt_flush_space(
rotate_thread_t* state) rotate_thread_t* state)
{ {
fil_space_t* space = state->space; fil_space_t* space = &*state->space;
fil_space_crypt_t *crypt_data = space->crypt_data; fil_space_crypt_t *crypt_data = space->crypt_data;
ut_ad(space->referenced()); ut_ad(space->referenced());
...@@ -2092,7 +2096,7 @@ static void fil_crypt_thread() ...@@ -2092,7 +2096,7 @@ static void fil_crypt_thread()
/* iterate all spaces searching for those needing rotation */ /* iterate all spaces searching for those needing rotation */
while (fil_crypt_find_space_to_rotate(&new_state, &thr, while (fil_crypt_find_space_to_rotate(&new_state, &thr,
&recheck)) { &recheck)) {
if (!thr.space) { if (thr.space == fil_system.space_list.end()) {
goto wait_for_work; goto wait_for_work;
} }
...@@ -2108,7 +2112,7 @@ static void fil_crypt_thread() ...@@ -2108,7 +2112,7 @@ static void fil_crypt_thread()
if (thr.space->is_stopping()) { if (thr.space->is_stopping()) {
fil_crypt_complete_rotate_space(&thr); fil_crypt_complete_rotate_space(&thr);
thr.space->release(); thr.space->release();
thr.space = nullptr; thr.space = fil_system.space_list.end();
break; break;
} }
...@@ -2120,7 +2124,7 @@ static void fil_crypt_thread() ...@@ -2120,7 +2124,7 @@ static void fil_crypt_thread()
} }
/* complete rotation */ /* complete rotation */
if (thr.space) { if (thr.space != fil_system.space_list.end()) {
fil_crypt_complete_rotate_space(&thr); fil_crypt_complete_rotate_space(&thr);
} }
...@@ -2132,9 +2136,9 @@ static void fil_crypt_thread() ...@@ -2132,9 +2136,9 @@ static void fil_crypt_thread()
fil_crypt_return_iops(&thr); fil_crypt_return_iops(&thr);
} }
if (thr.space) { if (thr.space != fil_system.space_list.end()) {
thr.space->release(); thr.space->release();
thr.space = nullptr; thr.space = fil_system.space_list.end();
} }
} }
...@@ -2196,45 +2200,43 @@ static void fil_crypt_rotation_list_fill() ...@@ -2196,45 +2200,43 @@ static void fil_crypt_rotation_list_fill()
{ {
mysql_mutex_assert_owner(&fil_system.mutex); mysql_mutex_assert_owner(&fil_system.mutex);
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t& space : fil_system.space_list) {
space != NULL; if (space.purpose != FIL_TYPE_TABLESPACE
space = UT_LIST_GET_NEXT(space_list, space)) { || space.is_in_rotation_list
if (space->purpose != FIL_TYPE_TABLESPACE || UT_LIST_GET_LEN(space.chain) == 0
|| space->is_in_rotation_list || !space.acquire_if_not_stopped()) {
|| UT_LIST_GET_LEN(space->chain) == 0
|| !space->acquire_if_not_stopped()) {
continue; continue;
} }
/* Ensure that crypt_data has been initialized. */ /* Ensure that crypt_data has been initialized. */
ut_ad(space->size); ut_ad(space.size);
/* Skip ENCRYPTION!=DEFAULT tablespaces. */ /* Skip ENCRYPTION!=DEFAULT tablespaces. */
if (space->crypt_data if (space.crypt_data
&& !space->crypt_data->is_default_encryption()) { && !space.crypt_data->is_default_encryption()) {
goto next; goto next;
} }
if (srv_encrypt_tables) { if (srv_encrypt_tables) {
/* Skip encrypted tablespaces if /* Skip encrypted tablespaces if
innodb_encrypt_tables!=OFF */ innodb_encrypt_tables!=OFF */
if (space->crypt_data if (space.crypt_data
&& space->crypt_data->min_key_version) { && space.crypt_data->min_key_version) {
goto next; goto next;
} }
} else { } else {
/* Skip unencrypted tablespaces if /* Skip unencrypted tablespaces if
innodb_encrypt_tables=OFF */ innodb_encrypt_tables=OFF */
if (!space->crypt_data if (!space.crypt_data
|| !space->crypt_data->min_key_version) { || !space.crypt_data->min_key_version) {
goto next; goto next;
} }
} }
fil_system.rotation_list.push_back(*space); fil_system.rotation_list.push_back(space);
space->is_in_rotation_list = true; space.is_in_rotation_list = true;
next: next:
space->release(); space.release();
} }
} }
......
...@@ -68,16 +68,15 @@ inline bool fil_is_user_tablespace_id(ulint space_id) ...@@ -68,16 +68,15 @@ inline bool fil_is_user_tablespace_id(ulint space_id)
bool fil_space_t::try_to_close(bool print_info) bool fil_space_t::try_to_close(bool print_info)
{ {
mysql_mutex_assert_owner(&fil_system.mutex); mysql_mutex_assert_owner(&fil_system.mutex);
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); space; for (fil_space_t &space : fil_system.space_list)
space= UT_LIST_GET_NEXT(space_list, space))
{ {
switch (space->purpose) { switch (space.purpose) {
case FIL_TYPE_TEMPORARY: case FIL_TYPE_TEMPORARY:
continue; continue;
case FIL_TYPE_IMPORT: case FIL_TYPE_IMPORT:
break; break;
case FIL_TYPE_TABLESPACE: case FIL_TYPE_TABLESPACE:
if (!fil_is_user_tablespace_id(space->id)) if (!fil_is_user_tablespace_id(space.id))
continue; continue;
} }
...@@ -85,14 +84,14 @@ bool fil_space_t::try_to_close(bool print_info) ...@@ -85,14 +84,14 @@ bool fil_space_t::try_to_close(bool print_info)
fil_node_open_file_low(), newly opened files are moved to the end fil_node_open_file_low(), newly opened files are moved to the end
of fil_system.space_list, so that they would be less likely to be of fil_system.space_list, so that they would be less likely to be
closed here. */ closed here. */
fil_node_t *node= UT_LIST_GET_FIRST(space->chain); fil_node_t *node= UT_LIST_GET_FIRST(space.chain);
ut_ad(node); ut_ad(node);
ut_ad(!UT_LIST_GET_NEXT(chain, node)); ut_ad(!UT_LIST_GET_NEXT(chain, node));
if (!node->is_open()) if (!node->is_open())
continue; continue;
if (const auto n= space->set_closing()) if (const auto n= space.set_closing())
{ {
if (print_info) if (print_info)
ib::info() << "Cannot close file " << node->name ib::info() << "Cannot close file " << node->name
...@@ -399,8 +398,8 @@ static bool fil_node_open_file_low(fil_node_t *node) ...@@ -399,8 +398,8 @@ static bool fil_node_open_file_low(fil_node_t *node)
{ {
/* Move the file last in fil_system.space_list, so that /* Move the file last in fil_system.space_list, so that
fil_space_t::try_to_close() should close it as a last resort. */ fil_space_t::try_to_close() should close it as a last resort. */
UT_LIST_REMOVE(fil_system.space_list, node->space); fil_system.space_list.erase(space_list_t::iterator(node->space));
UT_LIST_ADD_LAST(fil_system.space_list, node->space); fil_system.space_list.push_back(*node->space);
} }
fil_system.n_open++; fil_system.n_open++;
...@@ -779,7 +778,7 @@ std::vector<pfs_os_file_t> fil_system_t::detach(fil_space_t *space, ...@@ -779,7 +778,7 @@ std::vector<pfs_os_file_t> fil_system_t::detach(fil_space_t *space,
space->is_in_rotation_list= false; space->is_in_rotation_list= false;
rotation_list.remove(*space); rotation_list.remove(*space);
} }
UT_LIST_REMOVE(space_list, space); space_list.erase(space_list_t::iterator(space));
if (space == sys_space) if (space == sys_space)
sys_space= nullptr; sys_space= nullptr;
else if (space == temp_space) else if (space == temp_space)
...@@ -882,7 +881,7 @@ fil_space_free( ...@@ -882,7 +881,7 @@ fil_space_free(
if (space->max_lsn != 0) { if (space->max_lsn != 0) {
ut_d(space->max_lsn = 0); ut_d(space->max_lsn = 0);
UT_LIST_REMOVE(fil_system.named_spaces, space); fil_system.named_spaces.remove(*space);
} }
if (!recv_recovery_is_on()) { if (!recv_recovery_is_on()) {
...@@ -972,7 +971,7 @@ fil_space_t *fil_space_t::create(const char *name, ulint id, ulint flags, ...@@ -972,7 +971,7 @@ fil_space_t *fil_space_t::create(const char *name, ulint id, ulint flags,
HASH_INSERT(fil_space_t, hash, &fil_system.spaces, id, space); HASH_INSERT(fil_space_t, hash, &fil_system.spaces, id, space);
UT_LIST_ADD_LAST(fil_system.space_list, space); fil_system.space_list.push_back(*space);
switch (id) { switch (id) {
case 0: case 0:
...@@ -1272,7 +1271,7 @@ void fil_system_t::close() ...@@ -1272,7 +1271,7 @@ void fil_system_t::close()
{ {
ut_ad(this == &fil_system); ut_ad(this == &fil_system);
ut_a(unflushed_spaces.empty()); ut_a(unflushed_spaces.empty());
ut_a(!UT_LIST_GET_LEN(space_list)); ut_a(space_list.empty());
ut_ad(!sys_space); ut_ad(!sys_space);
ut_ad(!temp_space); ut_ad(!temp_space);
...@@ -1297,23 +1296,22 @@ ATTRIBUTE_COLD void fil_system_t::extend_to_recv_size() ...@@ -1297,23 +1296,22 @@ ATTRIBUTE_COLD void fil_system_t::extend_to_recv_size()
{ {
ut_ad(is_initialised()); ut_ad(is_initialised());
mysql_mutex_lock(&mutex); mysql_mutex_lock(&mutex);
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); space; for (fil_space_t &space : fil_system.space_list)
space= UT_LIST_GET_NEXT(space_list, space))
{ {
const uint32_t size= space->recv_size; const uint32_t size= space.recv_size;
if (size > space->size) if (size > space.size)
{ {
if (space->is_closing()) if (space.is_closing())
continue; continue;
space->reacquire(); space.reacquire();
bool success; bool success;
while (fil_space_extend_must_retry(space, UT_LIST_GET_LAST(space->chain), while (fil_space_extend_must_retry(&space, UT_LIST_GET_LAST(space.chain),
size, &success)) size, &success))
mysql_mutex_lock(&mutex); mysql_mutex_lock(&mutex);
/* Crash recovery requires the file extension to succeed. */ /* Crash recovery requires the file extension to succeed. */
ut_a(success); ut_a(success);
space->release(); space.release();
} }
} }
mysql_mutex_unlock(&mutex); mysql_mutex_unlock(&mutex);
...@@ -1322,64 +1320,58 @@ ATTRIBUTE_COLD void fil_system_t::extend_to_recv_size() ...@@ -1322,64 +1320,58 @@ ATTRIBUTE_COLD void fil_system_t::extend_to_recv_size()
/** Close all tablespace files at shutdown */ /** Close all tablespace files at shutdown */
void fil_space_t::close_all() void fil_space_t::close_all()
{ {
if (!fil_system.is_initialised()) { if (!fil_system.is_initialised())
return; return;
}
fil_space_t* space;
/* At shutdown, we should not have any files in this list. */ /* At shutdown, we should not have any files in this list. */
ut_ad(srv_fast_shutdown == 2 ut_ad(srv_fast_shutdown == 2 || !srv_was_started ||
|| !srv_was_started fil_system.named_spaces.empty());
|| UT_LIST_GET_LEN(fil_system.named_spaces) == 0);
fil_flush_file_spaces(); fil_flush_file_spaces();
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
for (space = UT_LIST_GET_FIRST(fil_system.space_list); space; ) { while (!fil_system.space_list.empty())
fil_node_t* node; {
fil_space_t* prev_space = space; fil_space_t &space= fil_system.space_list.front();
for (node = UT_LIST_GET_FIRST(space->chain); for (fil_node_t *node= UT_LIST_GET_FIRST(space.chain); node != NULL;
node != NULL; node= UT_LIST_GET_NEXT(chain, node))
node = UT_LIST_GET_NEXT(chain, node)) { {
if (!node->is_open()) { if (!node->is_open())
next: {
next:
continue; continue;
} }
for (ulint count = 10000; count--; ) { for (ulint count= 10000; count--;)
if (!space->set_closing()) { {
if (!space.set_closing())
{
node->close(); node->close();
goto next; goto next;
} }
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
std::this_thread::sleep_for( std::this_thread::sleep_for(std::chrono::microseconds(100));
std::chrono::microseconds(100));
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
if (!node->is_open()) { if (!node->is_open())
goto next; goto next;
} }
}
ib::error() << "File '" << node->name ib::error() << "File '" << node->name << "' has " << space.referenced()
<< "' has " << space->referenced()
<< " operations"; << " operations";
} }
space = UT_LIST_GET_NEXT(space_list, space); fil_system.detach(&space);
fil_system.detach(prev_space);
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
fil_space_free_low(prev_space); fil_space_free_low(&space);
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
} }
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
ut_ad(srv_fast_shutdown == 2 ut_ad(srv_fast_shutdown == 2 || !srv_was_started ||
|| !srv_was_started fil_system.named_spaces.empty());
|| UT_LIST_GET_LEN(fil_system.named_spaces) == 0);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -1858,7 +1850,7 @@ dberr_t fil_delete_tablespace(ulint id, bool if_exists, ...@@ -1858,7 +1850,7 @@ dberr_t fil_delete_tablespace(ulint id, bool if_exists,
if (space->max_lsn != 0) { if (space->max_lsn != 0) {
ut_d(space->max_lsn = 0); ut_d(space->max_lsn = 0);
UT_LIST_REMOVE(fil_system.named_spaces, space); fil_system.named_spaces.remove(*space);
} }
mysql_mutex_unlock(&log_sys.mutex); mysql_mutex_unlock(&log_sys.mutex);
...@@ -2041,13 +2033,12 @@ fil_rename_tablespace_check( ...@@ -2041,13 +2033,12 @@ fil_rename_tablespace_check(
new tablespace file. */ new tablespace file. */
retry: retry:
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t& space : fil_system.space_list) {
space; space = UT_LIST_GET_NEXT(space_list, space)) { ulint id = space.id;
ulint id = space->id;
if (id if (id
&& space->purpose == FIL_TYPE_TABLESPACE && space.purpose == FIL_TYPE_TABLESPACE
&& !strcmp(new_path, && !strcmp(new_path,
UT_LIST_GET_FIRST(space->chain)->name)) { UT_LIST_GET_FIRST(space.chain)->name)) {
ib::info() << "TRUNCATE rollback: " << id ib::info() << "TRUNCATE rollback: " << id
<< "," << new_path; << "," << new_path;
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
...@@ -3403,10 +3394,8 @@ bool fil_validate() ...@@ -3403,10 +3394,8 @@ bool fil_validate()
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
for (fil_space_t *space = UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t &space : fil_system.space_list) {
space != NULL; n_open += Check::validate(&space);
space = UT_LIST_GET_NEXT(space_list, space)) {
n_open += Check::validate(space);
} }
ut_a(fil_system.n_open == n_open); ut_a(fil_system.n_open == n_open);
...@@ -3501,7 +3490,7 @@ fil_names_dirty( ...@@ -3501,7 +3490,7 @@ fil_names_dirty(
ut_ad(space->max_lsn == 0); ut_ad(space->max_lsn == 0);
ut_d(fil_space_validate_for_mtr_commit(space)); ut_d(fil_space_validate_for_mtr_commit(space));
UT_LIST_ADD_LAST(fil_system.named_spaces, space); fil_system.named_spaces.push_back(*space);
space->max_lsn = log_sys.get_lsn(); space->max_lsn = log_sys.get_lsn();
} }
...@@ -3515,7 +3504,7 @@ void fil_names_dirty_and_write(fil_space_t* space) ...@@ -3515,7 +3504,7 @@ void fil_names_dirty_and_write(fil_space_t* space)
ut_d(fil_space_validate_for_mtr_commit(space)); ut_d(fil_space_validate_for_mtr_commit(space));
ut_ad(space->max_lsn == log_sys.get_lsn()); ut_ad(space->max_lsn == log_sys.get_lsn());
UT_LIST_ADD_LAST(fil_system.named_spaces, space); fil_system.named_spaces.push_back(*space);
mtr_t mtr; mtr_t mtr;
mtr.start(); mtr.start();
fil_names_write(space, &mtr); fil_names_write(space, &mtr);
...@@ -3557,27 +3546,27 @@ fil_names_clear( ...@@ -3557,27 +3546,27 @@ fil_names_clear(
mtr.start(); mtr.start();
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.named_spaces); for (auto it = fil_system.named_spaces.begin();
space != NULL; ) { it != fil_system.named_spaces.end(); ) {
if (mtr.get_log()->size() if (mtr.get_log()->size()
+ (3 + 5 + 1) + strlen(space->chain.start->name) + (3 + 5 + 1) + strlen(it->chain.start->name)
>= mtr_checkpoint_size) { >= mtr_checkpoint_size) {
/* Prevent log parse buffer overflow */ /* Prevent log parse buffer overflow */
mtr.commit_files(); mtr.commit_files();
mtr.start(); mtr.start();
} }
fil_space_t* next = UT_LIST_GET_NEXT(named_spaces, space); auto next = std::next(it);
ut_ad(space->max_lsn > 0); ut_ad(it->max_lsn > 0);
if (space->max_lsn < lsn) { if (it->max_lsn < lsn) {
/* The tablespace was last dirtied before the /* The tablespace was last dirtied before the
checkpoint LSN. Remove it from the list, so checkpoint LSN. Remove it from the list, so
that if the tablespace is not going to be that if the tablespace is not going to be
modified any more, subsequent checkpoints will modified any more, subsequent checkpoints will
avoid calling fil_names_write() on it. */ avoid calling fil_names_write() on it. */
space->max_lsn = 0; it->max_lsn = 0;
UT_LIST_REMOVE(fil_system.named_spaces, space); fil_system.named_spaces.erase(it);
} }
/* max_lsn is the last LSN where fil_names_dirty_and_write() /* max_lsn is the last LSN where fil_names_dirty_and_write()
...@@ -3585,10 +3574,10 @@ fil_names_clear( ...@@ -3585,10 +3574,10 @@ fil_names_clear(
where max_lsn turned nonzero), we could avoid the where max_lsn turned nonzero), we could avoid the
fil_names_write() call if min_lsn > lsn. */ fil_names_write() call if min_lsn > lsn. */
fil_names_write(space, &mtr); fil_names_write(&*it, &mtr);
do_write = true; do_write = true;
space = next; it = next;
} }
if (do_write) { if (do_write) {
...@@ -3676,3 +3665,45 @@ fil_space_get_block_size(const fil_space_t* space, unsigned offset) ...@@ -3676,3 +3665,45 @@ fil_space_get_block_size(const fil_space_t* space, unsigned offset)
return block_size; return block_size;
} }
#ifdef UNIV_DEBUG
fil_space_t *fil_space_t::next_in_space_list()
{
space_list_t::iterator it(this);
auto end= fil_system.space_list.end();
if (it == end)
return nullptr;
++it;
return it == end ? nullptr : &*it;
}
fil_space_t *fil_space_t::prev_in_space_list()
{
space_list_t::iterator it(this);
if (it == fil_system.space_list.begin())
return nullptr;
--it;
return &*it;
}
fil_space_t *fil_space_t::next_in_unflushed_spaces()
{
sized_ilist<fil_space_t, unflushed_spaces_tag_t>::iterator it(this);
auto end= fil_system.unflushed_spaces.end();
if (it == end)
return nullptr;
++it;
return it == end ? nullptr : &*it;
}
fil_space_t *fil_space_t::prev_in_unflushed_spaces()
{
sized_ilist<fil_space_t, unflushed_spaces_tag_t>::iterator it(this);
if (it == fil_system.unflushed_spaces.begin())
return nullptr;
--it;
return &*it;
}
#endif
...@@ -5735,15 +5735,13 @@ static void fil_get_fts_spaces(fts_space_set_t& fts_space_set) ...@@ -5735,15 +5735,13 @@ static void fil_get_fts_spaces(fts_space_set_t& fts_space_set)
{ {
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t &space : fil_system.space_list)
space;
space= UT_LIST_GET_NEXT(space_list, space))
{ {
index_id_t index_id= 0; index_id_t index_id= 0;
table_id_t table_id= 0; table_id_t table_id= 0;
if (space->purpose == FIL_TYPE_TABLESPACE if (space.purpose == FIL_TYPE_TABLESPACE
&& fts_check_aux_table(space->name, &table_id, &index_id)) && fts_check_aux_table(space.name, &table_id, &index_id))
fts_space_set.insert(std::make_pair(table_id, index_id)); fts_space_set.insert(std::make_pair(table_id, index_id));
} }
......
...@@ -6552,17 +6552,16 @@ static int i_s_sys_tablespaces_fill_table(THD *thd, TABLE_LIST *tables, Item*) ...@@ -6552,17 +6552,16 @@ static int i_s_sys_tablespaces_fill_table(THD *thd, TABLE_LIST *tables, Item*)
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
fil_system.freeze_space_list++; fil_system.freeze_space_list++;
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t &space : fil_system.space_list)
space; space= UT_LIST_GET_NEXT(space_list, space))
{ {
if (space->purpose == FIL_TYPE_TABLESPACE && !space->is_stopping() && if (space.purpose == FIL_TYPE_TABLESPACE && !space.is_stopping() &&
space->chain.start) space.chain.start)
{ {
space->reacquire(); space.reacquire();
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
err= i_s_sys_tablespaces_fill(thd, *space, tables->table); err= i_s_sys_tablespaces_fill(thd, space, tables->table);
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
space->release(); space.release();
if (err) if (err)
break; break;
} }
...@@ -6772,16 +6771,15 @@ i_s_tablespaces_encryption_fill_table( ...@@ -6772,16 +6771,15 @@ i_s_tablespaces_encryption_fill_table(
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
fil_system.freeze_space_list++; fil_system.freeze_space_list++;
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t& space : fil_system.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_stopping()) {
&& !space->is_stopping()) { space.reacquire();
space->reacquire();
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
err = i_s_dict_fill_tablespaces_encryption( err = i_s_dict_fill_tablespaces_encryption(
thd, space, tables->table); thd, &space, tables->table);
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
space->release(); space.release();
if (err) { if (err) {
break; break;
} }
......
...@@ -213,12 +213,13 @@ struct fil_space_crypt_status_t { ...@@ -213,12 +213,13 @@ struct fil_space_crypt_status_t {
}; };
/** Statistics about encryption key rotation */ /** Statistics about encryption key rotation */
struct fil_crypt_stat_t { struct fil_crypt_stat_t
ulint pages_read_from_cache; {
ulint pages_read_from_disk; ulint pages_read_from_cache= 0;
ulint pages_modified; ulint pages_read_from_disk= 0;
ulint pages_flushed; ulint pages_modified= 0;
ulint estimated_iops; ulint pages_flushed= 0;
ulint estimated_iops= 0;
}; };
/********************************************************************* /*********************************************************************
......
...@@ -44,6 +44,10 @@ Created 10/25/1995 Heikki Tuuri ...@@ -44,6 +44,10 @@ Created 10/25/1995 Heikki Tuuri
struct unflushed_spaces_tag_t; struct unflushed_spaces_tag_t;
struct rotation_list_tag_t; struct rotation_list_tag_t;
struct space_list_tag_t;
struct named_spaces_tag_t;
using space_list_t= ilist<fil_space_t, space_list_tag_t>;
// Forward declaration // Forward declaration
extern my_bool srv_use_doublewrite_buf; extern my_bool srv_use_doublewrite_buf;
...@@ -331,8 +335,10 @@ enum fil_encryption_t ...@@ -331,8 +335,10 @@ enum fil_encryption_t
FIL_ENCRYPTION_OFF FIL_ENCRYPTION_OFF
}; };
struct fil_space_t final : struct fil_space_t final : ilist_node<unflushed_spaces_tag_t>,
ilist_node<unflushed_spaces_tag_t>, ilist_node<rotation_list_tag_t> ilist_node<rotation_list_tag_t>,
ilist_node<space_list_tag_t>,
ilist_node<named_spaces_tag_t>
#else #else
struct fil_space_t final struct fil_space_t final
#endif #endif
...@@ -377,6 +383,14 @@ struct fil_space_t final ...@@ -377,6 +383,14 @@ struct fil_space_t final
/*!< number of reserved free extents for /*!< number of reserved free extents for
ongoing operations like B-tree page split */ ongoing operations like B-tree page split */
private: private:
#ifdef UNIV_DEBUG
fil_space_t *next_in_space_list();
fil_space_t *prev_in_space_list();
fil_space_t *next_in_unflushed_spaces();
fil_space_t *prev_in_unflushed_spaces();
#endif
/** the committed size of the tablespace in pages */ /** the committed size of the tablespace in pages */
Atomic_relaxed<uint32_t> committed_size; Atomic_relaxed<uint32_t> committed_size;
/** Number of pending operations on the file. /** Number of pending operations on the file.
...@@ -399,12 +413,6 @@ struct fil_space_t final ...@@ -399,12 +413,6 @@ struct fil_space_t final
os_thread_id_t latch_owner; os_thread_id_t latch_owner;
ut_d(Atomic_relaxed<uint32_t> latch_count;) ut_d(Atomic_relaxed<uint32_t> latch_count;)
public: public:
UT_LIST_NODE_T(fil_space_t) named_spaces;
/*!< list of spaces for which FILE_MODIFY
records have been issued */
UT_LIST_NODE_T(fil_space_t) space_list;
/*!< list of all spaces */
/** MariaDB encryption data */ /** MariaDB encryption data */
fil_space_crypt_t* crypt_data; fil_space_crypt_t* crypt_data;
...@@ -989,8 +997,8 @@ struct fil_space_t final ...@@ -989,8 +997,8 @@ struct fil_space_t final
@param encrypt expected state of innodb_encrypt_tables @param encrypt expected state of innodb_encrypt_tables
@return the next tablespace @return the next tablespace
@retval nullptr upon reaching the end of the iteration */ @retval nullptr upon reaching the end of the iteration */
static inline fil_space_t *next(fil_space_t *space, bool recheck, static space_list_t::iterator next(space_list_t::iterator space,
bool encrypt); bool recheck, bool encrypt);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
bool is_latched() const { return latch_count != 0; } bool is_latched() const { return latch_count != 0; }
...@@ -1371,11 +1379,7 @@ struct fil_system_t { ...@@ -1371,11 +1379,7 @@ struct fil_system_t {
Some members may require late initialisation, thus we just mark object as Some members may require late initialisation, thus we just mark object as
uninitialised. Real initialisation happens in create(). uninitialised. Real initialisation happens in create().
*/ */
fil_system_t(): m_initialised(false) fil_system_t() : m_initialised(false) {}
{
UT_LIST_INIT(space_list, &fil_space_t::space_list);
UT_LIST_INIT(named_spaces, &fil_space_t::named_spaces);
}
bool is_initialised() const { return m_initialised; } bool is_initialised() const { return m_initialised; }
...@@ -1434,9 +1438,9 @@ struct fil_system_t { ...@@ -1434,9 +1438,9 @@ struct fil_system_t {
/** nonzero if fil_node_open_file_low() should avoid moving the tablespace /** nonzero if fil_node_open_file_low() should avoid moving the tablespace
to the end of space_list, for FIFO policy of try_to_close() */ to the end of space_list, for FIFO policy of try_to_close() */
ulint freeze_space_list; ulint freeze_space_list;
UT_LIST_BASE_NODE_T(fil_space_t) space_list; ilist<fil_space_t, space_list_tag_t> space_list;
/*!< list of all file spaces */ /*!< list of all file spaces */
UT_LIST_BASE_NODE_T(fil_space_t) named_spaces; ilist<fil_space_t, named_spaces_tag_t> named_spaces;
/*!< list of all file spaces /*!< list of all file spaces
for which a FILE_MODIFY for which a FILE_MODIFY
record has been written since record has been written since
...@@ -1458,8 +1462,7 @@ struct fil_system_t { ...@@ -1458,8 +1462,7 @@ struct fil_system_t {
@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, fil_space_t* keyrotate_next(fil_space_t* space, bool recheck, bool encrypt);
bool encrypt);
/** Extend all open data files to the recovered size */ /** Extend all open data files to the recovered size */
ATTRIBUTE_COLD void extend_to_recv_size(); ATTRIBUTE_COLD void extend_to_recv_size();
......
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