Proposal for adding O_DIRECT support into JDK 9

Lu, Yingqi yingqi.lu at intel.com
Fri Sep 1 19:18:01 UTC 2017


Hi Brain,

I had that issue before. I solved it by provide the -nativepath: to jtreg (only test it on Linux). Are you already using the parameter?

I will have to look into the Windows code. Will let you know soon.

Thanks,
Lucy

From: Brian Burkhalter [mailto:brian.burkhalter at oracle.com]
Sent: Friday, September 01, 2017 12:09 PM
To: Lu, Yingqi <yingqi.lu at intel.com>
Cc: Alan Bateman <Alan.Bateman at oracle.com>; nio-dev at openjdk.java.net
Subject: Re: Proposal for adding O_DIRECT support into JDK 9

Hi Lucy,

DirectIOTest fails for me on Linux, macOS, and Solaris with the message "java.lang.UnsatisfiedLinkError: no DirectIO in java.library.path."

There is a compilation error on Windows which is fixed by the patch included below. With this patch applied however the four read/write direct tests fail with this error:

java.lang.IllegalArgumentException: Unit size not a power of two: -1
          at java.base/java.nio.ByteBuffer.alignmentOffset(ByteBuffer.java:1659)
          at java.base/java.nio.ByteBuffer.alignedSlice(ByteBuffer.java:1729)
          at java.base/sun.nio.ch.Util.getTemporaryAlignedDirectBuffer(Util.java:263)
          at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:72)
          at java.base/sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:277)

Thanks,

Brian

On Aug 31, 2017, at 3:49 PM, Lu, Yingqi <yingqi.lu at intel.com<mailto:yingqi.lu at intel.com>> wrote:


1.      Following the example of stringPlatformChars, made the DirectIOTest native library being compiled automatically. Removed DirectIOTest.java, README file and Makefile.

--- a/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java
+++ b/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java
@@ -132,7 +132,7 @@
         CharBuffer buffer = CharBuffer.allocate(filePath.length());
         buffer.put(filePath);
         try {
-            result = setDirect0(buffer);
+            result = setDirect0(fd, buffer);
         } catch (IOException e) {
             throw new UnsupportedOperationException
                 ("Error setting up DirectIO", e);
@@ -195,5 +195,6 @@

     static native long duplicateHandle(long fd) throws IOException;

-    static native int setDirect0(CharBuffer buffer) throws IOException;
+    static native int setDirect0(FileDescriptor fd, CharBuffer buffer)
+        throws IOException;
 }
--- a/src/java.base/windows/native/libnio/ch/FileDispatcherImpl.c
+++ b/src/java.base/windows/native/libnio/ch/FileDispatcherImpl.c
@@ -459,11 +459,11 @@

 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_FileDispatcherImpl_setDirect0(JNIEnv *env, jclass this,
-                                           jobject buffer)
+                                              jobject fdObj, jobject buffer)
 {
     jint result = -1;

-    HANDLE orig = (HANDLE)(handleval(env, fObj));
+    HANDLE orig = (HANDLE)(handleval(env, fdObj));

     HANDLE modify = ReOpenFile(orig, 0, 0,
             FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20170901/6dab2266/attachment-0001.html>


More information about the nio-dev mailing list