提交 566c3c7a 编写于 作者: A antirez

fsync always now uses O_DIRECT on Linux

上级 d3277ecd
......@@ -35,4 +35,9 @@
#define HAVE_KQUEUE 1
#endif
/* test for O_DIRECT */
#ifdef __linux__
#define HAVE_O_DIRECT 1
#endif
#endif
......@@ -1673,7 +1673,16 @@ static void initServer() {
acceptHandler, NULL) == AE_ERR) oom("creating file event");
if (server.appendonly) {
server.appendfd = open(server.appendfilename,O_WRONLY|O_APPEND|O_CREAT,0644);
int flags = O_WRONLY|O_APPEND|O_CREAT;
#ifdef HAVE_O_DIRECT
if (server.appendfsync == APPENDFSYNC_ALWAYS) {
flags |= O_DIRECT;
server.appendfsync = APPENDFSYNC_NO;
}
#endif
server.appendfd = open(server.appendfilename,flags,0644);
if (server.appendfd == -1) {
redisLog(REDIS_WARNING, "Can't open the append-only file: %s",
strerror(errno));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册