projects
/
redis.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d3277ec
)
fsync always now uses O_DIRECT on Linux
author
antirez
<antirez@gmail.com>
Tue, 20 Apr 2010 16:25:30 +0000
(18:25 +0200)
committer
antirez
<antirez@gmail.com>
Tue, 20 Apr 2010 16:25:30 +0000
(18:25 +0200)
config.h
patch
|
blob
|
blame
|
history
redis.c
patch
|
blob
|
blame
|
history
diff --git
a/config.h
b/config.h
index 754d3aa86f7341c7dad02664b8d10f47d270598e..d1da9887dfc64930a72886c1cc5a4f029635296e 100644
(file)
--- a/
config.h
+++ b/
config.h
@@
-35,4
+35,9
@@
#define HAVE_KQUEUE 1
#endif
#define HAVE_KQUEUE 1
#endif
+/* test for O_DIRECT */
+#ifdef __linux__
+#define HAVE_O_DIRECT 1
+#endif
+
#endif
#endif
diff --git
a/redis.c
b/redis.c
index 53d5c215c7ba11488c1eeb110b357f7046f8485b..de4f5763d79acb07a0f00572d6d06ee2a9b77f84 100644
(file)
--- a/
redis.c
+++ b/
redis.c
@@
-1673,7
+1673,16
@@
static void initServer() {
acceptHandler, NULL) == AE_ERR) oom("creating file event");
if (server.appendonly) {
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));
if (server.appendfd == -1) {
redisLog(REDIS_WARNING, "Can't open the append-only file: %s",
strerror(errno));