Proposal for adding O_DIRECT support into JDK 9

Brian Burkhalter brian.burkhalter at oracle.com
Tue Oct 10 19:33:49 UTC 2017


Hello,

I have two informational items to report.

Firstly, please note that pursuant to the fix for [1] it was necessary to update this patch to version 19 [2]. The conflict was with FileChannelImpl.java [3]. This change has been verified on macOS and a complete test run is in progress.

Secondly, before the Direct I/O patch can be integrated, a Compatibility and Specification Request (CSR) (https://wiki.openjdk.java.net/display/csr/Main) will need to be created and approved. I will create a CSR issue and start moving it towards review.

Thanks,

Brian

[1] https://bugs.openjdk.java.net/browse/JDK-8147615
[2] http://cr.openjdk.java.net/~bpb/8164900/webrev.19/
[3] FileChannelImpl.java diff

--- a/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
+++ b/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
@@ -92,18 +92,32 @@
     // Positional-read is not interruptible
     private volatile boolean uninterruptible;
 
+    // DirectIO flag
+    private final boolean direct;
+
+    // IO alignment value for DirectIO
+    private final int alignment;
+
     // Cleanable with an action which closes this channel's file descriptor
     private final Cleanable closer;
 
     private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
-                            boolean writable, Object parent)
+                            boolean writable, boolean direct, Object parent)
     {
         this.fd = fd;
         this.readable = readable;
         this.writable = writable;
         this.parent = parent;
         this.path = path;
+        this.direct = direct;
         this.nd = new FileDispatcherImpl();
+        if (direct) {
+            assert path != null;
+            this.alignment = nd.setDirectIO(fd, path);
+        } else {
+            this.alignment = -1;
+        }
+
         // Register a cleaning action if and only if there is no parent
         // as the parent will take care of closing the file descriptor.
         this.closer= parent != null ? null :


On Oct 9, 2017, at 5:57 PM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:

> I updated version 18 of the patch with the fix for the compilation errors on macOS:
> 
> http://cr.openjdk.java.net/~bpb/8164900/webrev.18/
> 
> This ran successfully through our regression harness for the IO and NIO core tests and all platforms passed. I also re-reviewed the code changes once again.
> 
> Barring objections to the contrary, I am ready to sponsor this version.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20171010/2b98e437/attachment.html>


More information about the nio-dev mailing list