Skip to content
This repository
Browse code

On Linux now fdatasync() is used insetad of fsync() in order to flush…

… the AOF file kernel buffers
  • Loading branch information...
commit 10ce12761a9971512e0702c73434bcef0f212e7d 1 parent 7aaaad5
antirez authored

Showing 3 changed files with 12 additions and 5 deletions. Show diff stats Hide diff stats

  1. +7 0 config.h
  2. +1 1  fmacros.h
  3. +4 4 redis.c
7 config.h
@@ -35,4 +35,11 @@
35 35 #define HAVE_KQUEUE 1
36 36 #endif
37 37
  38 +/* define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
  39 +#ifdef __linux__
  40 +#define aof_fsync fdatasync
  41 +#else
  42 +#define aof_fsync fsync
  43 +#endif
  44 +
38 45 #endif
2  fmacros.h
@@ -2,7 +2,7 @@
2 2 #define _REDIS_FMACRO_H
3 3
4 4 #define _BSD_SOURCE
5   -#define _XOPEN_SOURCE
  5 +#define _XOPEN_SOURCE 700
6 6 #define _LARGEFILE_SOURCE
7 7 #define _FILE_OFFSET_BITS 64
8 8
8 redis.c
@@ -37,8 +37,6 @@
37 37 #include <string.h>
38 38 #include <time.h>
39 39 #include <unistd.h>
40   -#define __USE_POSIX199309
41   -#define __USE_UNIX98
42 40 #include <signal.h>
43 41
44 42 #ifdef HAVE_BACKTRACE
@@ -4049,7 +4047,7 @@ static void echoCommand(redisClient *c) {
4049 4047
4050 4048 static void setGenericCommand(redisClient *c, int nx, robj *key, robj *val, robj *expire) {
4051 4049 int retval;
4052   - long seconds;
  4050 + long seconds = 0; /* initialized to avoid an harmness warning */
4053 4051
4054 4052 if (expire) {
4055 4053 if (getLongFromObjectOrReply(c, expire, &seconds, NULL) != REDIS_OK)
@@ -8090,7 +8088,9 @@ static void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv
8090 8088 (server.appendfsync == APPENDFSYNC_EVERYSEC &&
8091 8089 now-server.lastfsync > 1))
8092 8090 {
8093   - fsync(server.appendfd); /* Let's try to get this data on the disk */
  8091 + /* aof_fsync is defined as fdatasync() for Linux in order to avoid
  8092 + * flushing metadata. */
  8093 + aof_fsync(server.appendfd); /* Let's try to get this data on the disk */
8094 8094 server.lastfsync = now;
8095 8095 }
8096 8096 }

0 comments on commit 10ce127

Please sign in to comment.
Something went wrong with that request. Please try again.