Proposal for adding O_DIRECT support into JDK 9

Lu, Yingqi yingqi.lu at intel.com
Mon Oct 9 21:13:58 UTC 2017


Hi Brian,

Thank you for testing the patch! The fix looks good to me. Do you want me to submit a newer version of the patch?

Thanks,
Lucy

From: Brian Burkhalter [mailto:brian.burkhalter at oracle.com]
Sent: Monday, October 09, 2017 2:04 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,

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<mailto: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/e6169677/attachment-0001.html>


More information about the nio-dev mailing list