diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c index 32e7f144026..46fcf400d34 100644 --- a/innobase/log/log0log.c +++ b/innobase/log/log0log.c @@ -838,14 +838,18 @@ log_io_complete( /* It was a checkpoint write */ group = (log_group_t*)((ulint)group - 1); - fil_flush(group->space_id); - + if (srv_unix_file_flush_method == SRV_UNIX_LITTLESYNC) { + fil_flush(group->space_id); + } + log_io_complete_checkpoint(group); return; } - fil_flush(group->space_id); + if (srv_unix_file_flush_method == SRV_UNIX_LITTLESYNC) { + fil_flush(group->space_id); + } mutex_enter(&(log_sys->mutex)); @@ -1474,7 +1478,9 @@ log_checkpoint( recv_apply_hashed_log_recs(TRUE); } - fil_flush_file_spaces(FIL_TABLESPACE); + if (srv_unix_file_flush_method == SRV_UNIX_LITTLESYNC) { + fil_flush_file_spaces(FIL_TABLESPACE); + } mutex_enter(&(log_sys->mutex)); diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 7a6edd5a7c1..fa0c266a82a 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -9,6 +9,7 @@ Created 10/21/1995 Heikki Tuuri #include "os0file.h" #include "os0sync.h" #include "ut0mem.h" +#include "srv0srv.h" #ifdef POSIX_ASYNC_IO @@ -345,12 +346,11 @@ try_again: UT_NOT_USED(purpose); - /* On Linux opening a file in the O_SYNC mode seems to be much - more efficient for small writes than calling an explicit fsync or - fdatasync after each write, but on Solaris O_SYNC and O_DSYNC is - extremely slow in large block writes to a big file. Therefore we - do not use these options, but use explicit fdatasync. */ - +#ifdef O_DSYNC + if (srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { + create_flag = create_flag | O_DSYNC; + } +#endif if (create_mode == OS_FILE_CREATE) { file = open(name, create_flag, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); @@ -546,6 +546,12 @@ os_file_flush( return(FALSE); #else int ret; + +#ifdef O_DSYNC + if (srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { + return(TRUE); + } +#endif #ifdef HAVE_FDATASYNC ret = fdatasync(file); @@ -621,10 +627,15 @@ os_file_pwrite( #ifdef HAVE_PWRITE ret = pwrite(file, buf, n, offs); - /* Always do fsync to reduce the probability that when the OS crashes, - a database page is only partially physically written to disk. */ + if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) { - ut_a(TRUE == os_file_flush(file)); + /* Always do fsync to reduce the probability that when + the OS crashes, a database page is only partially + physically written to disk. */ + + ut_a(TRUE == os_file_flush(file)); + } return(ret); #else @@ -645,10 +656,15 @@ os_file_pwrite( ret = write(file, buf, n); - /* Always do fsync to reduce the probability that when the OS crashes, - a database page is only partially physically written to disk. */ + if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) { - ut_a(TRUE == os_file_flush(file)); + /* Always do fsync to reduce the probability that when + the OS crashes, a database page is only partially + physically written to disk. */ + + ut_a(TRUE == os_file_flush(file)); + } os_mutex_exit(os_file_seek_mutexes[i]); diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 105d6e11623..29ddf2a21c8 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -548,8 +548,6 @@ innobase_start_or_create_for_mysql(void) return(DB_ERROR); } - printf("InnoDB file flush method %lu\n", srv_unix_file_flush_method); - os_aio_use_native_aio = srv_use_native_aio; err = srv_boot();