Proposal for adding O_DIRECT support into JDK 9

Brian Burkhalter brian.burkhalter at oracle.com
Mon Oct 9 21:04:11 UTC 2017


Hi Lucy,

This patch has a compilation failure on macOS:

src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c:334:22: error: variable has incomplete type 'struct statvfs64'
    struct statvfs64 file_stat;
                     ^
src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c:334:12: note: forward declaration of 'struct statvfs64'
    struct statvfs64 file_stat;
           ^
src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c:362:14: error: implicit declaration of function 'fstatvfs64' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    result = fstatvfs64(fd, &file_stat);

The diff below appears to fix it.

Thanks,

Brian

--- a/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
+++ b/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
@@ -331,7 +331,11 @@
 {
     jint fd = fdval(env, fdo);
     jint result;
+#ifdef MACOSX
+    struct statvfs file_stat;
+#else
     struct statvfs64 file_stat;
+#endif
 
 #if defined(O_DIRECT) || defined(F_NOCACHE) || defined(DIRECTIO_ON)
 #ifdef O_DIRECT
@@ -359,7 +363,11 @@
         return result;
     }
 #endif
+#ifdef MACOSX
+    result = fstatvfs(fd, &file_stat);
+#else
     result = fstatvfs64(fd, &file_stat);
+#endif
     if(result == -1) {
         JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed");
         return result;

On Oct 9, 2017, at 1:07 PM, Lu, Yingqi <yingqi.lu at intel.com> wrote:

> Here is the version 18 of the patch. Following your suggestion, I changed statvfs to statvfs64 in FileDispatcherImpl.c.
>  
> http://cr.openjdk.java.net/~kkharbas/8164900/webrev.18/

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


More information about the nio-dev mailing list