Skip to content

Commit b4daac2

Browse files
author
Bin Su
committed
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 <[email protected]> RB: 8981
1 parent dc45e40 commit b4daac2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

storage/innobase/os/os0file.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***********************************************************************
22
3-
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
3+
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2009, Percona Inc.
55
66
Portions of this file contain modifications contributed and copyrighted
@@ -1276,16 +1276,19 @@ os_file_create_simple_no_error_handling_func(
12761276
#else /* __WIN__ */
12771277
os_file_t file;
12781278
int create_flag;
1279+
const char* mode_str = NULL;
12791280

12801281
ut_a(name);
12811282

12821283
if (create_mode == OS_FILE_OPEN) {
1284+
mode_str = "OPEN";
12831285
if (access_type == OS_FILE_READ_ONLY) {
12841286
create_flag = O_RDONLY;
12851287
} else {
12861288
create_flag = O_RDWR;
12871289
}
12881290
} else if (create_mode == OS_FILE_CREATE) {
1291+
mode_str = "CREATE";
12891292
create_flag = O_RDWR | O_CREAT | O_EXCL;
12901293
} else {
12911294
create_flag = 0;
@@ -1310,6 +1313,14 @@ os_file_create_simple_no_error_handling_func(
13101313
#endif
13111314
} else {
13121315
*success = TRUE;
1316+
1317+
/* This function is always called for data files, we should
1318+
disable OS caching (O_DIRECT) here as we do in
1319+
os_file_create_func(), so we open the same file in the same
1320+
mode, see man page of open(2). */
1321+
if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
1322+
os_file_set_nocache(file, name, mode_str);
1323+
}
13131324
}
13141325

13151326
return(file);

0 commit comments

Comments
 (0)