Merge lp:~vlad-lesin/percona-server/5.1-bug801989 into lp:percona-server/5.1

Proposed by Vlad Lesin
Status: Work in progress
Proposed branch: lp:~vlad-lesin/percona-server/5.1-bug801989
Merge into: lp:percona-server/5.1
Diff against target: 64 lines (+13/-5)
2 files modified
Percona-Server/storage/innodb_plugin/include/os0file.h (+3/-2)
Percona-Server/storage/innodb_plugin/os/os0file.c (+10/-3)
To merge this branch: bzr merge lp:~vlad-lesin/percona-server/5.1-bug801989
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Needs Fixing
Review via email: mp+124113@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Vlad,

The patch looks good. But as we discussed it should be recommitted to a GCA 5.1 branch.

Since you have to recommit it anyway, please add braces around the statement in the if() block, as done in everywhere in InnoDB.

review: Needs Fixing

Unmerged revisions

482. By Vlad Lesin

The bug #801989 fix.

The main idea of this fix is to return "true" on success and "false" otherwise
from os_file_set_nocache(). That allows to process O_DIRECT flag setting failures.

If setting O_DIRECT failes on log files the srv_unix_file_flush_method is set
to SRV_UNIX_O_DIRECT value to do fsync() on log files. If O_DIRECT fails on
other files the error is ignored to do buffered I/O on filesystems that do not
support direct I/O(for example tmpfs).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/storage/innodb_plugin/include/os0file.h'
2--- Percona-Server/storage/innodb_plugin/include/os0file.h 2012-06-14 09:16:03 +0000
3+++ Percona-Server/storage/innodb_plugin/include/os0file.h 2012-09-13 07:30:44 +0000
4@@ -338,9 +338,10 @@
5 used by a backup program reading the file */
6 ibool* success);/*!< out: TRUE if succeed, FALSE if error */
7 /****************************************************************//**
8-Tries to disable OS caching on an opened file descriptor. */
9+Tries to disable OS caching on an opened file descriptor.
10+@return TRUE if operation is success and FALSE otherwise */
11 UNIV_INTERN
12-void
13+ibool
14 os_file_set_nocache(
15 /*================*/
16 int fd, /*!< in: file descriptor to alter */
17
18=== modified file 'Percona-Server/storage/innodb_plugin/os/os0file.c'
19--- Percona-Server/storage/innodb_plugin/os/os0file.c 2012-06-14 09:16:03 +0000
20+++ Percona-Server/storage/innodb_plugin/os/os0file.c 2012-09-13 07:30:44 +0000
21@@ -1218,9 +1218,10 @@
22 }
23
24 /****************************************************************//**
25-Tries to disable OS caching on an opened file descriptor. */
26+Tries to disable OS caching on an opened file descriptor.
27+@return TRUE if operation is success and FALSE otherwise */
28 UNIV_INTERN
29-void
30+ibool
31 os_file_set_nocache(
32 /*================*/
33 int fd /*!< in: file descriptor to alter */
34@@ -1241,6 +1242,7 @@
35 " InnoDB: Failed to set DIRECTIO_ON "
36 "on file %s: %s: %s, continuing anyway\n",
37 file_name, operation_name, strerror(errno_save));
38+ return FALSE;
39 }
40 #elif defined(O_DIRECT)
41 if (fcntl(fd, F_SETFL, O_DIRECT) == -1) {
42@@ -1258,8 +1260,10 @@
43 "'Invalid argument' on Linux on tmpfs, "
44 "see MySQL Bug#26662\n");
45 }
46+ return FALSE;
47 }
48 #endif
49+ return TRUE;
50 }
51
52 /****************************************************************//**
53@@ -1488,7 +1492,10 @@
54
55 /* ALL_O_DIRECT: O_DIRECT also for transaction log file */
56 if (srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT) {
57- os_file_set_nocache(file, name, mode_str);
58+ /* Do fsync() on log files when setting O_DIRECT fails.
59+ See log_io_complete() */
60+ if (!os_file_set_nocache(file, name, mode_str))
61+ srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
62 }
63
64 #ifdef USE_FILE_LOCK

Subscribers

People subscribed via source and target branches