mohan-chinnappan-n / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

fsync() to fdatasync() in SyncDirIfManifest() #244

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It is not a bug or issue.
It is just a comment for tuning of SyncDirIfManifest().

I think fdatasync() is enough to sync directory and can show a little bit 
better performance.

diff --git a/util/env_posix.cc b/util/env_posix.cc
index e1cbebd..e563663 100644
--- a/util/env_posix.cc
+++ b/util/env_posix.cc
@@ -233,7 +233,7 @@ class PosixWritableFile : public WritableFile {
       if (fd < 0) {
         s = IOError(dir, errno);
       } else {
-        if (fsync(fd) < 0) {
+        if (fdatasync(fd) < 0) {
           s = IOError(dir, errno);
         }
         close(fd);

Thank you.

Original issue reported on code.google.com by yongilj...@gmail.com on 17 Jul 2014 at 6:11

GoogleCodeExporter commented 9 years ago
fdatasync() is from glibc and is not available on all supported platforms e.g. 
Windows, OS X, so a fallback would need to be defined.

Original comment by jsbell@chromium.org on 17 Jul 2014 at 5:26

GoogleCodeExporter commented 9 years ago
The code already falls back to fsync when fdatasync is not available by 
"#define fdatasync fsync." This change should work on all platforms with fsync.

Original comment by res...@gmail.com on 17 Jul 2014 at 5:32