[9] RFR of 8080589: (fs) FileChannel.force should use fcntl(F_FULLFSYNC) instead of fsync on OS X
Brian Burkhalter
brian.burkhalter at oracle.com
Tue May 19 01:24:07 UTC 2015
Please review at your convenience.
Issue: https://bugs.openjdk.java.net/browse/JDK-8080589
Path: see included diff below
JTREG passed locally on Mac OS 10.9.5; all other OSes passed on JPRT.
I don’t think the tests really verify whether any buffered data was actually synced to disk so if anyone has a suggestion in this regard it would be welcome.
Thanks,
Brian
— snip — valuable coupon — snip —
--- a/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
+++ b/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
@@ -144,14 +144,17 @@
JNIEXPORT jint JNICALL
Java_sun_nio_ch_FileDispatcherImpl_force0(JNIEnv *env, jobject this,
jobject fdo, jboolean md)
{
jint fd = fdval(env, fdo);
int result = 0;
+#ifdef MACOSX
+ result = fcntl(fd, F_FULLFSYNC);
+#else
if (md == JNI_FALSE) {
result = fdatasync(fd);
} else {
#ifdef _AIX
/* On AIX, calling fsync on a file descriptor that is opened only for
* reading results in an error ("EBADF: The FileDescriptor parameter is
* not a valid file descriptor open for writing.").
@@ -159,17 +162,18 @@
* 'writable' attribute of the corresponding file channel so we have to
* use 'fcntl'.
*/
int getfl = fcntl(fd, F_GETFL);
if (getfl >= 0 && (getfl & O_ACCMODE) == O_RDONLY) {
return 0;
}
-#endif
+#endif /* _AIX */
result = fsync(fd);
}
+#endif /* MACOSX */
return handle(env, result, "Force failed");
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20150518/9e3abe29/attachment-0001.html>
More information about the nio-dev
mailing list