[9] RFR of 8080589: (fs) FileChannel.force should use fcntl(F_FULLFSYNC) instead of fsync on OS X
Robert Muir
rcmuir at gmail.com
Tue May 19 19:55:59 UTC 2015
On Tue, May 19, 2015 at 2:33 PM, Brian Burkhalter
<brian.burkhalter at oracle.com> wrote:
>
> --- a/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
> +++ b/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
> @@ -144,14 +144,25 @@
> 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
> +#if defined(F_FULLFSYNC)
> + result = fcntl(fd, F_FULLFSYNC);
> + if (result == -1 && errno == ENOTSUP) {
> + /* Try fsync() in case F_FULLSYUNC is not implemented on the file
> system. */
> + result = fsync(fd);
> + }
> +#else
> + result = fsync(fd);
> +#endif /* defined(F_FULLSYNC) */
> +#else
> if (md == JNI_FALSE) {
> result = fdatasync(fd);
for the MACOSX case, fdatasync is not available (and mapped to fsync),
so in the case some code calls force(false) it appears it will make an
additional unnecessary call to fsync.
More information about the nio-dev
mailing list