summaryrefslogtreecommitdiff
path: root/storage/innobase/fil/fil0fil.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/fil/fil0fil.cc')
-rw-r--r--storage/innobase/fil/fil0fil.cc83
1 files changed, 27 insertions, 56 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 3874616e230..21743a0e076 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -588,8 +588,7 @@ fil_try_to_close_file_in_LRU(
static void fil_flush_low(fil_space_t* space, bool metadata = false)
{
ut_ad(mutex_own(&fil_system.mutex));
- ut_ad(space);
- ut_ad(!space->stop_new_ops);
+ ut_ad(!space->is_stopping());
if (srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC) {
/* No need to flush. User has explicitly disabled
@@ -859,14 +858,14 @@ fil_mutex_enter_and_prepare_for_io(
this tablespace (multiple threads trying to extend
this tablespace).
- Also, fil_space_set_recv_size() may have been invoked
- again during the file extension while fil_system.mutex
- was not being held by us.
+ Also, fil_space_set_recv_size_and_flags() may have been
+ invoked again during the file extension while
+ fil_system.mutex was not being held by us.
Only if space->recv_size matches what we read
originally, reset the field. In this way, a
subsequent I/O request will handle any pending
- fil_space_set_recv_size(). */
+ fil_space_set_recv_size_and_flags(). */
if (size == space->recv_size) {
space->recv_size = 0;
@@ -1321,22 +1320,18 @@ fil_space_get_space(
return(space);
}
-/** Set the recovered size of a tablespace in pages.
-@param id tablespace ID
-@param size recovered size in pages */
-UNIV_INTERN
-void
-fil_space_set_recv_size(ulint id, ulint size)
+void fil_space_set_recv_size_and_flags(ulint id, ulint size, uint32_t flags)
{
- mutex_enter(&fil_system.mutex);
- ut_ad(size);
- ut_ad(id < SRV_SPACE_ID_UPPER_BOUND);
-
- if (fil_space_t* space = fil_space_get_space(id)) {
- space->recv_size = size;
- }
-
- mutex_exit(&fil_system.mutex);
+ ut_ad(id < SRV_SPACE_ID_UPPER_BOUND);
+ mutex_enter(&fil_system.mutex);
+ if (fil_space_t *space= fil_space_get_space(id))
+ {
+ if (size)
+ space->recv_size= size;
+ if (flags != FSP_FLAGS_FCRC32_MASK_MARKER)
+ space->flags= flags;
+ }
+ mutex_exit(&fil_system.mutex);
}
/*******************************************************************//**
@@ -1724,10 +1719,8 @@ fil_space_t* fil_space_acquire_low(ulint id, bool silent)
ib::warn() << "Trying to access missing"
" tablespace " << id;
}
- } else if (space->is_stopping()) {
+ } else if (!space->acquire()) {
space = NULL;
- } else {
- space->acquire();
}
mutex_exit(&fil_system.mutex);
@@ -1955,14 +1948,14 @@ static ulint fil_check_pending_ops(const fil_space_t* space, ulint count)
{
ut_ad(mutex_own(&fil_system.mutex));
- if (space == NULL) {
+ if (!space) {
return 0;
}
- if (ulint n_pending_ops = space->n_pending_ops) {
+ if (auto n_pending_ops = space->referenced()) {
- /* Give a warning every 10 second, starting after 1 second */
- if ((count % 500) == 50) {
+ /* Give a warning every 10 second, starting after 1 second */
+ if ((count % 500) == 50) {
ib::warn() << "Trying to delete"
" tablespace '" << space->name
<< "' but there are " << n_pending_ops
@@ -2033,14 +2026,13 @@ fil_check_pending_operations(
fil_space_t* sp = fil_space_get_by_id(id);
if (sp) {
- sp->stop_new_ops = true;
- if (sp->crypt_data) {
- sp->acquire();
+ if (sp->crypt_data && sp->acquire()) {
mutex_exit(&fil_system.mutex);
fil_space_crypt_close_tablespace(sp);
mutex_enter(&fil_system.mutex);
sp->release();
}
+ sp->set_stopping(true);
}
/* Check for pending operations. */
@@ -2521,7 +2513,7 @@ fil_rename_tablespace(
multiple datafiles per tablespace. */
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
node = UT_LIST_GET_FIRST(space->chain);
- space->n_pending_ops++;
+ ut_a(space->acquire());
mutex_exit(&fil_system.mutex);
@@ -2543,8 +2535,7 @@ fil_rename_tablespace(
/* log_sys.mutex is above fil_system.mutex in the latching order */
ut_ad(log_mutex_own());
mutex_enter(&fil_system.mutex);
- ut_ad(space->n_pending_ops);
- space->n_pending_ops--;
+ space->release();
ut_ad(space->name == old_space_name);
ut_ad(node->name == old_file_name);
bool success;
@@ -3797,7 +3788,7 @@ fil_io(
if (!space
|| (req_type.is_read()
&& !sync
- && space->stop_new_ops
+ && space->is_stopping()
&& !space->is_being_truncated)) {
mutex_exit(&fil_system.mutex);
@@ -4223,7 +4214,7 @@ fil_space_validate_for_mtr_commit(
mini-transaction, we should have !space->stop_new_ops. This is
guaranteed by meta-data locks or transactional locks, or
dict_sys.latch (X-lock in DROP, S-lock in purge). */
- ut_ad(!space->stop_new_ops
+ ut_ad(!space->is_stopping()
|| space->is_being_truncated /* fil_truncate_prepare() */
|| space->referenced());
}
@@ -4430,23 +4421,3 @@ fil_space_get_block_size(const fil_space_t* space, unsigned offset)
return block_size;
}
-
-/*******************************************************************//**
-Returns the table space by a given id, NULL if not found. */
-fil_space_t*
-fil_space_found_by_id(
-/*==================*/
- ulint id) /*!< in: space id */
-{
- fil_space_t* space = NULL;
- mutex_enter(&fil_system.mutex);
- space = fil_space_get_by_id(id);
-
- /* Not found if space is being deleted */
- if (space && space->stop_new_ops) {
- space = NULL;
- }
-
- mutex_exit(&fil_system.mutex);
- return space;
-}