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.cc117
1 files changed, 45 insertions, 72 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 4ca79ca96c4..9abbc4a540a 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -409,7 +409,7 @@ fil_space_is_flushed(
node != NULL;
node = UT_LIST_GET_NEXT(chain, node)) {
- if (node->modification_counter > node->flush_counter) {
+ if (node->needs_flush) {
ut_ad(!fil_buffering_disabled(space));
return(false);
@@ -446,8 +446,6 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle,
ut_a(!is_raw || srv_start_raw_disk_in_use);
- node->sync_event = os_event_create("fsync_event");
-
node->is_raw_disk = is_raw;
node->size = size;
@@ -678,7 +676,7 @@ void fil_node_t::close()
ut_a(n_pending == 0);
ut_a(n_pending_flushes == 0);
ut_a(!being_extended);
- ut_a(modification_counter == flush_counter
+ ut_a(!needs_flush
|| space->purpose == FIL_TYPE_TEMPORARY
|| srv_fast_shutdown == 2
|| !srv_was_started);
@@ -727,7 +725,7 @@ fil_try_to_close_file_in_LRU(
node != NULL;
node = UT_LIST_GET_PREV(LRU, node)) {
- if (node->modification_counter == node->flush_counter
+ if (!node->needs_flush
&& node->n_pending_flushes == 0
&& !node->being_extended) {
@@ -747,11 +745,9 @@ fil_try_to_close_file_in_LRU(
<< node->n_pending_flushes;
}
- if (node->modification_counter != node->flush_counter) {
+ if (node->needs_flush) {
ib::warn() << "Cannot close file " << node->name
- << ", because modification count "
- << node->modification_counter <<
- " != flush count " << node->flush_counter;
+ << ", because is should be flushed first";
}
if (node->being_extended) {
@@ -776,7 +772,7 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false)
/* No need to flush. User has explicitly disabled
buffering. */
- ut_ad(!space->is_in_unflushed_spaces);
+ ut_ad(!space->is_in_unflushed_spaces());
ut_ad(fil_space_is_flushed(space));
ut_ad(space->n_pending_flushes == 0);
@@ -784,8 +780,7 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false)
for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain);
node != NULL;
node = UT_LIST_GET_NEXT(chain, node)) {
- ut_ad(node->modification_counter
- == node->flush_counter);
+ ut_ad(!node->needs_flush);
ut_ad(node->n_pending_flushes == 0);
}
#endif /* UNIV_DEBUG */
@@ -800,9 +795,7 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false)
node != NULL;
node = UT_LIST_GET_NEXT(chain, node)) {
- int64_t old_mod_counter = node->modification_counter;
-
- if (old_mod_counter <= node->flush_counter) {
+ if (!node->needs_flush) {
continue;
}
@@ -826,31 +819,10 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false)
goto skip_flush;
}
#endif /* _WIN32 */
-retry:
- if (node->n_pending_flushes > 0) {
- /* We want to avoid calling os_file_flush() on
- the file twice at the same time, because we do
- not know what bugs OS's may contain in file
- i/o */
-
- int64_t sig_count = os_event_reset(node->sync_event);
-
- mutex_exit(&fil_system.mutex);
-
- os_event_wait_low(node->sync_event, sig_count);
-
- mutex_enter(&fil_system.mutex);
-
- if (node->flush_counter >= old_mod_counter) {
-
- goto skip_flush;
- }
-
- goto retry;
- }
ut_a(node->is_open());
node->n_pending_flushes++;
+ node->needs_flush = false;
mutex_exit(&fil_system.mutex);
@@ -858,18 +830,14 @@ retry:
mutex_enter(&fil_system.mutex);
- os_event_set(node->sync_event);
-
node->n_pending_flushes--;
+#ifdef _WIN32
skip_flush:
- if (node->flush_counter < old_mod_counter) {
- node->flush_counter = old_mod_counter;
-
- if (space->is_in_unflushed_spaces
+#endif /* _WIN32 */
+ if (!node->needs_flush) {
+ if (space->is_in_unflushed_spaces()
&& fil_space_is_flushed(space)) {
- space->is_in_unflushed_spaces = false;
-
UT_LIST_REMOVE(
fil_system.unflushed_spaces,
space);
@@ -1164,19 +1132,16 @@ fil_node_close_to_free(
/* We fool the assertion in fil_node_t::close() to think
there are no unflushed modifications in the file */
- node->modification_counter = node->flush_counter;
- os_event_set(node->sync_event);
+ node->needs_flush = false;
if (fil_buffering_disabled(space)) {
- ut_ad(!space->is_in_unflushed_spaces);
+ ut_ad(!space->is_in_unflushed_spaces());
ut_ad(fil_space_is_flushed(space));
- } else if (space->is_in_unflushed_spaces
+ } else if (space->is_in_unflushed_spaces()
&& fil_space_is_flushed(space)) {
- space->is_in_unflushed_spaces = false;
-
UT_LIST_REMOVE(fil_system.unflushed_spaces, space);
}
@@ -1197,16 +1162,14 @@ fil_space_detach(
HASH_DELETE(fil_space_t, hash, fil_system.spaces, space->id, space);
- if (space->is_in_unflushed_spaces) {
+ if (space->is_in_unflushed_spaces()) {
ut_ad(!fil_buffering_disabled(space));
- space->is_in_unflushed_spaces = false;
UT_LIST_REMOVE(fil_system.unflushed_spaces, space);
}
- if (space->is_in_rotation_list) {
- space->is_in_rotation_list = false;
+ if (space->is_in_rotation_list()) {
UT_LIST_REMOVE(fil_system.rotation_list, space);
}
@@ -1252,7 +1215,6 @@ fil_space_free_low(
for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain);
node != NULL; ) {
ut_d(space->size -= node->size);
- os_event_destroy(node->sync_event);
ut_free(node->name);
fil_node_t* old_node = node;
node = UT_LIST_GET_NEXT(chain, node);
@@ -1428,11 +1390,8 @@ fil_space_create(
/* Key rotation is not enabled, need to inform background
encryption threads. */
UT_LIST_ADD_LAST(fil_system.rotation_list, space);
- space->is_in_rotation_list = true;
mutex_exit(&fil_system.mutex);
- mutex_enter(&fil_crypt_threads_mutex);
os_event_set(fil_crypt_threads_event);
- mutex_exit(&fil_crypt_threads_mutex);
} else {
mutex_exit(&fil_system.mutex);
}
@@ -4098,24 +4057,21 @@ fil_node_complete_io(fil_node_t* node, const IORequest& type)
ut_ad(!srv_read_only_mode
|| node->space->purpose == FIL_TYPE_TEMPORARY);
- ++fil_system.modification_counter;
-
- node->modification_counter = fil_system.modification_counter;
-
if (fil_buffering_disabled(node->space)) {
/* We don't need to keep track of unflushed
changes as user has explicitly disabled
buffering. */
- ut_ad(!node->space->is_in_unflushed_spaces);
- node->flush_counter = node->modification_counter;
-
- } else if (!node->space->is_in_unflushed_spaces) {
+ ut_ad(!node->space->is_in_unflushed_spaces());
+ ut_ad(node->needs_flush == false);
- node->space->is_in_unflushed_spaces = true;
+ } else {
+ node->needs_flush = true;
- UT_LIST_ADD_FIRST(
- fil_system.unflushed_spaces, node->space);
+ if (!node->space->is_in_unflushed_spaces()) {
+ UT_LIST_ADD_FIRST(fil_system.unflushed_spaces,
+ node->space);
+ }
}
}
@@ -5118,8 +5074,7 @@ fil_space_remove_from_keyrotation(fil_space_t* space)
ut_ad(mutex_own(&fil_system.mutex));
ut_ad(space);
- if (space->is_in_rotation_list && !space->referenced()) {
- space->is_in_rotation_list = false;
+ if (!space->referenced() && space->is_in_rotation_list()) {
ut_a(UT_LIST_GET_LEN(fil_system.rotation_list) > 0);
UT_LIST_REMOVE(fil_system.rotation_list, space);
}
@@ -5260,3 +5215,21 @@ fil_space_set_punch_hole(
{
node->space->punch_hole = val;
}
+
+/** Checks that this tablespace in a list of unflushed tablespaces.
+@return true if in a list */
+bool fil_space_t::is_in_unflushed_spaces() const {
+ ut_ad(mutex_own(&fil_system.mutex));
+
+ return fil_system.unflushed_spaces.start == this
+ || unflushed_spaces.next || unflushed_spaces.prev;
+}
+
+/** Checks that this tablespace needs key rotation.
+@return true if in a rotation list */
+bool fil_space_t::is_in_rotation_list() const {
+ ut_ad(mutex_own(&fil_system.mutex));
+
+ return fil_system.rotation_list.start == this || rotation_list.next
+ || rotation_list.prev;
+}