Commit b4daac21 authored by Bin Su's avatar Bin Su

Bug#21113036 - MYSQL/INNODB MIX BUFFERED AND DIRECT IO

As man page of open(2) suggested, we should open the same file in the same
mode, to have better performance. For some data files, we will first call
os_file_create_simple_no_error_handling_func() to open them, and then call
os_file_create_func() again. We have to make sure if DIRECT IO is specified,
these two functions should both open file with O_DIRECT.
Reviewed-by: default avatarSunny Bains <sunny.bains@oracle.com>
RB: 8981
parent dc45e408
/*********************************************************************** /***********************************************************************
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Portions of this file contain modifications contributed and copyrighted Portions of this file contain modifications contributed and copyrighted
...@@ -1276,16 +1276,19 @@ os_file_create_simple_no_error_handling_func( ...@@ -1276,16 +1276,19 @@ os_file_create_simple_no_error_handling_func(
#else /* __WIN__ */ #else /* __WIN__ */
os_file_t file; os_file_t file;
int create_flag; int create_flag;
const char* mode_str = NULL;
ut_a(name); ut_a(name);
if (create_mode == OS_FILE_OPEN) { if (create_mode == OS_FILE_OPEN) {
mode_str = "OPEN";
if (access_type == OS_FILE_READ_ONLY) { if (access_type == OS_FILE_READ_ONLY) {
create_flag = O_RDONLY; create_flag = O_RDONLY;
} else { } else {
create_flag = O_RDWR; create_flag = O_RDWR;
} }
} else if (create_mode == OS_FILE_CREATE) { } else if (create_mode == OS_FILE_CREATE) {
mode_str = "CREATE";
create_flag = O_RDWR | O_CREAT | O_EXCL; create_flag = O_RDWR | O_CREAT | O_EXCL;
} else { } else {
create_flag = 0; create_flag = 0;
...@@ -1310,6 +1313,14 @@ os_file_create_simple_no_error_handling_func( ...@@ -1310,6 +1313,14 @@ os_file_create_simple_no_error_handling_func(
#endif #endif
} else { } else {
*success = TRUE; *success = TRUE;
/* 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_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
os_file_set_nocache(file, name, mode_str);
}
} }
return(file); return(file);
......
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