Permalink
Browse files

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: Sunny Bains <sunny.bains@oracle.com>
RB: 8981
  • Loading branch information...
Bin Su
Bin Su committed May 21, 2015
1 parent dc45e40 commit b4daac21f52ced96c11632b83445111c0acede56
Showing with 12 additions and 1 deletion.
  1. +12 −1 storage/innobase/os/os0file.c
@@ -1,6 +1,6 @@
/***********************************************************************
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);

0 comments on commit b4daac2

Please sign in to comment.