summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extra/mariabackup/xtrabackup.cc2
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_flush_method_func.result2
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_innodb.result2
-rw-r--r--sql-bench/example4
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
-rw-r--r--storage/innobase/include/fil0fil.h10
-rw-r--r--storage/innobase/os/os0file.cc44
7 files changed, 27 insertions, 39 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 62fdace654d..22db660bd54 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -1506,7 +1506,7 @@ struct my_option xb_server_options[] =
"With which method to flush data.",
&srv_file_flush_method, &srv_file_flush_method,
&innodb_flush_method_typelib, GET_ENUM, REQUIRED_ARG,
- IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_FSYNC), 0, 0, 0, 0, 0},
+ IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_O_DIRECT), 0, 0, 0, 0, 0},
{"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE,
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
diff --git a/mysql-test/suite/sys_vars/r/innodb_flush_method_func.result b/mysql-test/suite/sys_vars/r/innodb_flush_method_func.result
index afecd9ab6cc..c4881df9375 100644
--- a/mysql-test/suite/sys_vars/r/innodb_flush_method_func.result
+++ b/mysql-test/suite/sys_vars/r/innodb_flush_method_func.result
@@ -1,7 +1,7 @@
call mtr.add_suppression("InnoDB: Failed to set .*DIRECT");
select @@innodb_flush_method;
@@innodb_flush_method
-fsync
+O_DIRECT
create table t(a serial) engine=innodb;
FLUSH TABLES;
# restart: --innodb-flush-method=5
diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
index 3fee1d1288b..e47c35f4d1f 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
@@ -743,7 +743,7 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_FLUSH_METHOD
SESSION_VALUE NULL
-DEFAULT_VALUE fsync
+DEFAULT_VALUE O_DIRECT
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE ENUM
VARIABLE_COMMENT With which method to flush data.
diff --git a/sql-bench/example b/sql-bench/example
index 29c1d81449a..db945d8bfc3 100644
--- a/sql-bench/example
+++ b/sql-bench/example
@@ -6,9 +6,9 @@ machine="Linux-x64"
# InnoDB tests
-./run-all-tests --suffix=-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_log_file_size=2000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --innodb_flush_method=O_DIRECT --innodb_log_files_in_group=1 --skip-innodb-doublewrite" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --log
+./run-all-tests --suffix=-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_log_file_size=2000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --log
-./run-all-tests --suffix=_fast-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_log_file_size=2000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --innodb_flush_method=O_DIRECT --innodb_log_files_in_group=1 --skip-innodb-doublewrite" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --fast --log
+./run-all-tests --suffix=_fast-innodb --comments="Engine=InnoDB --innodb_buffer_pool_size=256M --innodb_log_file_size=2000M --innodb_log_buffer_size=16M --innodb_lock_wait_timeout=50 --innodb_flush_log_at_trx_commit=1 --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --fast --log
# MyISAM tests
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index f83367af75d..5e448146781 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -18308,7 +18308,7 @@ static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
static MYSQL_SYSVAR_ENUM(flush_method, innodb_flush_method,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"With which method to flush data.",
- NULL, NULL, IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_FSYNC),
+ NULL, NULL, IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_O_DIRECT),
&innodb_flush_method_typelib);
static MYSQL_SYSVAR_BOOL(force_load_corrupted, srv_load_corrupted,
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 94740c68410..4006cb8d765 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -61,13 +61,11 @@ enum srv_flush_t
/** do not flush after writing */
SRV_NOSYNC,
/** invoke os_file_set_nocache() on data files. This implies using
- non-buffered IO but still using fsync, the reason for which is that
- some FS do not flush meta-data when unbuffered IO happens */
+ unbuffered I/O but still fdatasync(), because some filesystems might
+ not flush meta-data on write completion */
SRV_O_DIRECT,
- /** do not use fsync() when using direct IO i.e.: it can be set to
- avoid the fsync() call that we make when using SRV_UNIX_O_DIRECT.
- However, in this case user/DBA should be sure about the integrity of
- the meta-data */
+ /** Like O_DIRECT, but skip fdatasync(), assuming that the data is
+ durable on write completion */
SRV_O_DIRECT_NO_FSYNC
#ifdef _WIN32
/** Traditional Windows appoach to open all files without caching,
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index a4f8b0ee2ef..9a11c91cd15 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2020, MariaDB Corporation.
+Copyright (c) 2013, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are
@@ -1112,12 +1112,8 @@ os_file_create_simple_func(
/* This function is always called for data files, we should disable
OS caching (O_DIRECT) here as we do in os_file_create_func(), so
we open the same file in the same mode, see man page of open(2). */
- if (!srv_read_only_mode
- && *success
- && (srv_file_flush_method == SRV_O_DIRECT
- || srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC)) {
-
- os_file_set_nocache(file, name, mode_str);
+ if (!srv_read_only_mode && *success) {
+ os_file_set_nocache(file, name, mode_str);
}
#ifdef USE_FILE_LOCK
@@ -1426,11 +1422,8 @@ os_file_create_func(
if (!read_only
&& *success
&& type != OS_LOG_FILE && type != OS_DATA_TEMP_FILE
- && type != OS_DATA_FILE_NO_O_DIRECT
- && (srv_file_flush_method == SRV_O_DIRECT
- || srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC)) {
-
- os_file_set_nocache(file, name, mode_str);
+ && type != OS_DATA_FILE_NO_O_DIRECT) {
+ os_file_set_nocache(file, name, mode_str);
}
#ifdef USE_FILE_LOCK
@@ -3484,6 +3477,15 @@ os_file_set_nocache(
const char* file_name MY_ATTRIBUTE((unused)),
const char* operation_name MY_ATTRIBUTE((unused)))
{
+ const auto innodb_flush_method = srv_file_flush_method;
+ switch (innodb_flush_method) {
+ case SRV_O_DIRECT:
+ case SRV_O_DIRECT_NO_FSYNC:
+ break;
+ default:
+ return;
+ }
+
/* some versions of Solaris may not have DIRECTIO_ON */
#if defined(UNIV_SOLARIS) && defined(DIRECTIO_ON)
if (directio(fd, DIRECTIO_ON) == -1) {
@@ -3502,23 +3504,11 @@ os_file_set_nocache(
if (errno_save == EINVAL) {
if (!warning_message_printed) {
warning_message_printed = true;
-# ifdef UNIV_LINUX
- ib::warn()
- << "Failed to set O_DIRECT on file"
- << file_name << "; " << operation_name
- << ": " << strerror(errno_save) << ", "
- "continuing anyway. O_DIRECT is "
- "known to result in 'Invalid argument' "
- "on Linux on tmpfs, "
- "see MySQL Bug#26662.";
-# else /* UNIV_LINUX */
- goto short_warning;
-# endif /* UNIV_LINUX */
+ ib::info()
+ << "Setting O_DIRECT on file "
+ << file_name << " failed";
}
} else {
-# ifndef UNIV_LINUX
-short_warning:
-# endif
ib::warn()
<< "Failed to set O_DIRECT on file "
<< file_name << "; " << operation_name