You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2018/04/17 15:59:14 UTC

[19/23] ignite git commit: IGNITE-8282 Direct IO: support fdatasync, which does not flush modified metadata - Fixes #3833.

IGNITE-8282 Direct IO: support fdatasync, which does not flush modified metadata - Fixes #3833.

Signed-off-by: dpavlov <dp...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/63dc75b8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/63dc75b8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/63dc75b8

Branch: refs/heads/ignite-7708
Commit: 63dc75b85b12f1c7bea796714c1e88925c16b1ab
Parents: e254e65
Author: dpavlov <dp...@apache.org>
Authored: Tue Apr 17 16:25:37 2018 +0300
Committer: dpavlov <dp...@apache.org>
Committed: Tue Apr 17 16:25:37 2018 +0300

----------------------------------------------------------------------
 .../persistence/file/AlignedBuffersDirectFileIO.java      |  6 +++++-
 .../cache/persistence/file/IgniteNativeIoLib.java         | 10 ++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/63dc75b8/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIO.java
----------------------------------------------------------------------
diff --git a/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIO.java b/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIO.java
index 681426c..0168d2a 100644
--- a/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIO.java
+++ b/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIO.java
@@ -471,7 +471,11 @@ public class AlignedBuffersDirectFileIO implements FileIO {
 
     /** {@inheritDoc} */
     @Override public void force(boolean withMetadata) throws IOException {
-        if (IgniteNativeIoLib.fsync(fdCheckOpened()) < 0)
+        int fd = fdCheckOpened();
+
+        int res = withMetadata ? IgniteNativeIoLib.fsync(fd) : IgniteNativeIoLib.fdatasync(fd);
+
+        if (res < 0)
             throw new IOException(String.format("Error fsync()'ing %s, got %s", file, getLastError()));
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/63dc75b8/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoLib.java
----------------------------------------------------------------------
diff --git a/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoLib.java b/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoLib.java
index 47f1e6a..65ef8d7 100644
--- a/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoLib.java
+++ b/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoLib.java
@@ -316,6 +316,16 @@ public class IgniteNativeIoLib {
     public static native int fsync(int fd);
 
     /**
+     * Synchronize a file's in-core state with storage device. See "man 2 fsync".
+     *
+     * Similar to {@link #fsync(int)}, but does not flush modified metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled
+     *
+     * @param fd file descriptor.
+     * @return On success return zero. On error, -1 is returned, and errno is set appropriately.
+     */
+    public static native int fdatasync(int fd);
+
+    /**
      * Allocates size bytes and places the address of the allocated memory in {@code memptr}.
      * The address of the allocated memory will be a multiple of {@code alignment}.
      *