Proposal for adding O_DIRECT support into JDK 9
Lu, Yingqi
yingqi.lu at intel.com
Fri Sep 1 22:15:53 UTC 2017
Hi Brian,
When I add back the Windows flags, I forgot to check on the file descriptor. Your patch perfectly solved the issue. Thank you!!
I also patched the jdk/make/test/JtregNative.gmk to make sure the native library is not going to be built on Windows.
Interestingly, I tried all 4 tests on Windows and they all passed.
$ ./jtreg/bin/jtreg jdk/test/java/nio/channels/FileChannel/directio
Directory "JTwork" not found: creating
Directory "JTreport" not found: creating
Test results: passed: 4
Report written to C:\cygwin64\home\ylu41\jdk10-directio-0831\JTreport\html\report.html
Results written to C:\cygwin64\home\ylu41\jdk10-directio-0831\JTwork
The test environment is Windows 10 enterprise 64 bit. I did everything through Cygwin.
Thanks,
Lucy
From: nio-dev [mailto:nio-dev-bounces at openjdk.java.net] On Behalf Of Lu, Yingqi
Sent: Friday, September 01, 2017 12:18 PM
To: Brian Burkhalter <brian.burkhalter at oracle.com>
Cc: nio-dev at openjdk.java.net
Subject: RE: Proposal for adding O_DIRECT support into JDK 9
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<mailto:yingqi.lu at intel.com>>
Cc: Alan Bateman <Alan.Bateman at oracle.com<mailto:Alan.Bateman at oracle.com>>; nio-dev at openjdk.java.net<mailto: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/ec55e868/attachment-0001.html>
More information about the nio-dev
mailing list