Commit 555f955a authored by Eugene Kosov's avatar Eugene Kosov

use O_DSYNC for InnoDB

O_DSYNC is faster than O_SYNC because it syncs as little as needed
(e.g. no timestamp changes)

This change is similar to change fsync() -> fdatasync() in MDEV-21382
parent f2832a01
...@@ -612,7 +612,7 @@ extern PSI_stage_info srv_stage_buffer_pool_load; ...@@ -612,7 +612,7 @@ extern PSI_stage_info srv_stage_buffer_pool_load;
/** Alternatives for innodb_flush_method */ /** Alternatives for innodb_flush_method */
enum srv_flush_t { enum srv_flush_t {
SRV_FSYNC = 0, /*!< fsync, the default */ SRV_FSYNC = 0, /*!< fsync, the default */
SRV_O_DSYNC, /*!< open log files in O_SYNC mode */ SRV_O_DSYNC, /*!< open log files in O_DSYNC mode */
SRV_LITTLESYNC, /*!< do not call os_file_flush() SRV_LITTLESYNC, /*!< do not call os_file_flush()
when writing data files, but do flush when writing data files, but do flush
after writing to log files */ after writing to log files */
......
...@@ -1390,18 +1390,17 @@ os_file_create_func( ...@@ -1390,18 +1390,17 @@ os_file_create_func(
ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL); ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL);
#ifdef O_SYNC /* We let O_DSYNC only affect log files */
/* We let O_SYNC only affect log files; note that we map O_DSYNC to
O_SYNC because the datasync options seemed to corrupt files in 2001
in both Linux and Solaris */
if (!read_only if (!read_only
&& type == OS_LOG_FILE && type == OS_LOG_FILE
&& srv_file_flush_method == SRV_O_DSYNC) { && srv_file_flush_method == SRV_O_DSYNC) {
#ifdef O_DSYNC
create_flag |= O_DSYNC;
#else
create_flag |= O_SYNC; create_flag |= O_SYNC;
#endif
} }
#endif /* O_SYNC */
os_file_t file; os_file_t file;
bool retry; bool retry;
...@@ -2492,7 +2491,7 @@ os_file_create_func( ...@@ -2492,7 +2491,7 @@ os_file_create_func(
{ {
case SRV_O_DSYNC: case SRV_O_DSYNC:
if (type == OS_LOG_FILE) { if (type == OS_LOG_FILE) {
/* Map O_SYNC to FILE_WRITE_THROUGH */ /* Map O_DSYNC to FILE_WRITE_THROUGH */
attributes |= FILE_FLAG_WRITE_THROUGH; attributes |= FILE_FLAG_WRITE_THROUGH;
} }
break; break;
......
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