kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject kudu git commit: env: do not convert all Flush() calls into fsync() on macOS
Date Mon, 12 Dec 2016 22:30:16 GMT
Repository: kudu
Updated Branches:
  refs/heads/master c681f9348 -> 9e72f055b


env: do not convert all Flush() calls into fsync() on macOS

On Linux, we don't expect sync_file_range() to actually provide durability;
we use it to tell the kernel to start writing back dirty pages while we go
off and do other work. That is, it must be followed up with an fsync() if
durability is actually desired.

To that end, let's only convert Flush() to fsync() if a synchronous flush
was requested. Even then I'm not sure it makes sense (sync_file_range()
explicitly does NOT guarantee durability, even if SYNC_FILE_RANGE_WAIT_AFTER
was used), but at least callers will get the "only return when all dirty
pages have been written out" behavior they probably wanted.

I also snuck in a change to add SYNC_FILE_RANGE_WAIT_BEFORE to the
FLUSH_SYNC case on Linux. It's largely academic (since FLUSH_SYNC is never
actually used), but it's safer if it is ever used for data integrity.

Change-Id: I01bdd8dbaaad0205c0795a87dd973c8bf0fb87dc
Reviewed-on: http://gerrit.cloudera.org:8080/5457
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <aserbin@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/9e72f055
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/9e72f055
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/9e72f055

Branch: refs/heads/master
Commit: 9e72f055b57d2662828cadc249234f31057c22fd
Parents: c681f93
Author: Adar Dembo <adar@cloudera.com>
Authored: Fri Dec 9 18:40:48 2016 -0800
Committer: Adar Dembo <adar@cloudera.com>
Committed: Mon Dec 12 22:29:43 2016 +0000

----------------------------------------------------------------------
 src/kudu/util/env_posix.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/9e72f055/src/kudu/util/env_posix.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/env_posix.cc b/src/kudu/util/env_posix.cc
index d1d9a23..2d3b6a0 100644
--- a/src/kudu/util/env_posix.cc
+++ b/src/kudu/util/env_posix.cc
@@ -432,13 +432,14 @@ class PosixWritableFile : public WritableFile {
 #if defined(__linux__)
     int flags = SYNC_FILE_RANGE_WRITE;
     if (mode == FLUSH_SYNC) {
+      flags |= SYNC_FILE_RANGE_WAIT_BEFORE;
       flags |= SYNC_FILE_RANGE_WAIT_AFTER;
     }
     if (sync_file_range(fd_, 0, 0, flags) < 0) {
       return IOError(filename_, errno);
     }
 #else
-    if (fsync(fd_) < 0) {
+    if (mode == Env::FLUSH_SYNC && fsync(fd_) < 0) {
       return IOError(filename_, errno);
     }
 #endif
@@ -657,7 +658,7 @@ class PosixRWFile : public RWFile {
       return IOError(filename_, errno);
     }
 #else
-    if (fsync(fd_) < 0) {
+    if (mode == Env::FLUSH_SYNC && fsync(fd_) < 0) {
       return IOError(filename_, errno);
     }
 #endif


Mime
View raw message