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.
Portions of this file contain modifications contributed and copyrighted
......@@ -1276,16 +1276,19 @@ os_file_create_simple_no_error_handling_func(
#else /* __WIN__ */
os_file_t file;
int create_flag;
const char* mode_str = NULL;
ut_a(name);
if (create_mode == OS_FILE_OPEN) {
mode_str = "OPEN";
if (access_type == OS_FILE_READ_ONLY) {
create_flag = O_RDONLY;
} else {
create_flag = O_RDWR;
}
} else if (create_mode == OS_FILE_CREATE) {
mode_str = "CREATE";
create_flag = O_RDWR | O_CREAT | O_EXCL;
} else {
create_flag = 0;
......@@ -1310,6 +1313,14 @@ os_file_create_simple_no_error_handling_func(
#endif
} else {
*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);
......
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