Skip to content

Commit ab9d60b

Browse files
Herman Leefacebook-github-bot
Herman Lee
authored andcommitted
Add posix_fadvise(FADV_DONTNEED) to flush buffered pages
Summary: When InnoDB opens a .ibd or log file in O_DIRECT mode, request the os to flush the buffer cache. Otherwise, direct IO is serialized when buffered pages for the file existing within the filesystem cache. Reviewed By: alxyang Differential Revision: D5100237 fbshipit-source-id: bbbd3db
1 parent ad90bf7 commit ab9d60b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

storage/innobase/os/os0file.cc

+10
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ Created 10/21/1995 Heikki Tuuri
6565
#include <libaio.h>
6666
#endif
6767

68+
/* Ignore posix_fadvise() on those platforms where it does not exist */
69+
#if defined __WIN__
70+
# define posix_fadvise(fd, offset, len, advice) /* nothing */
71+
#endif /* __WIN__ */
72+
6873
#define max(a,b) ((a)>(b)?(a):(b))
6974

7075
/* Configurable histogram step sizes */
@@ -1703,6 +1708,11 @@ os_file_set_nocache(
17031708
}
17041709
return -1;
17051710
}
1711+
#ifdef POSIX_FADV_DONTNEED
1712+
/* Request the filesystem to flush cached pages. Otherwise,
1713+
DIRECTIO requests are serialized. */
1714+
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
1715+
#endif /* POSIX_FADV_DONTNEED */
17061716
#endif /* defined(UNIV_SOLARIS) && defined(DIRECTIO_ON) */
17071717
return 0;
17081718
}

0 commit comments

Comments
 (0)