Proposal for adding O_DIRECT support into JDK 9
Volker Simonis
volker.simonis at gmail.com
Mon Sep 18 08:28:02 UTC 2017
Sorry if I'm missing something here, but I think "open()" has the
following signature:
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
So I don't quite understand what:
open(path, 'r')
should stand for. Maybe you've mixed it up with "fopen()"
FILE *fopen(const char *path, const char *mode);
which takes a character as second argument?
"open()" simply takes one of the following constants O_RDONLY,
O_WRONLY, or O_RDWR as 'flags' argument. If you use that you shouldn't
need the third 'mode' argument. And if you want to use a 'mode'
argument, please use one of the predefined constants instead of a
plain number.
Regards,
Volker
On Sat, Sep 16, 2017 at 12:53 AM, Brian Burkhalter
<brian.burkhalter at oracle.com> wrote:
> Hi Lucy,
>
> This change works:
>
> --- a/test/java/nio/channels/FileChannel/directio/libDirectIO.c
> +++ b/test/java/nio/channels/FileChannel/directio/libDirectIO.c
> @@ -71,7 +71,7 @@
>
> const char* path = (*env)->GetStringUTFChars(env, file_path,
> JNI_FALSE);
>
> - int fd = open(path, 'r');
> + int fd = open(path, 'r', 0600);
>
> (*env)->ReleaseStringUTFChars(env, file_path, path);
>
> All five tests pass in my Ubuntu 16.04 64-bit VM.
>
> On my macOS system I also observed this failure:
>
> java.lang.RuntimeException: DirectIO is not working properly with write.
> File still exists in cache!
> at DirectIOTest.main(DirectIOTest.java:117)
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:564)
> at
> com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:230)
> at java.base/java.lang.Thread.run(Thread.java:844)
>
> Neither this nor the other failure on macOS occurs every time, i.e., they
> appear to be intermittent.
>
> Thanks,
>
> Brian
>
> On Sep 15, 2017, at 3:45 PM, Lu, Yingqi <yingqi.lu at intel.com> wrote:
>
> Could you please replace the line 78 in
> jdk/test/java/nio/channels/FileChannel/directio/libDirectIO.c with the
> following line and give it a try on your Ubuntu box? I tested it on my
> CentOS system, it does not complain.
>
> int fd = open(path, 'r', 0600);
>
>
More information about the nio-dev
mailing list