-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
darwin: double-check that fsync should flush disk write cache using F_FULLFSYNC #9439
Comments
It seems that at least the implementation for Node's documentation for This is not in fact true for Node's |
Or perhaps |
Libuv just forwards to the libc function or system call of the same name. If Apple has a broken implementation, that's their problem. You could check what Apple's Libc does. |
I thought
I doubt Apple would consider their implementation broken. They provide Most users think of Would you or @saghul be open to a pull request from me to fix this in Otherwise we need to do a PR to make it clear in the docs that Node's |
I think I misunderstood your point. I have no issue with uv_fs_fsync() having stricter guarantees on OS X but see below.
That's not so different from other operating systems. fysnc() on Linux doesn't guarantee that data is on disk either (Ubuntu man pages notwithstanding), only that it's been handed off to the disk controller by the time the system call returns. Its exact semantics vary from file system to file system and is usually configurable by the system administrator.
That was for uv_fs_fdatasync() though, not uv_fs_fsync(), and only because there was no fdatasync system call in old XNU kernels. |
Thanks. Should
It's not just Ubuntu, but also Linux. There was an effort starting a few years back as far as I understand to make
In the same way, Apple's man pages encourage
Apple's Thus what most people think of as Node's
Yes, thanks. I saw the change to |
I'm okay with (effectively) making uv_fs_fdatasync an alias for uv_fs_fsync on OS X.
Yes, I'm aware but the current state of affairs is still a mixed bag. If you use one of the "big five" file systems you're probably safe but it's hit and miss with less popular ones. The HFS+ driver somewhat amusingly seems to be one of the file systems that doesn't get it right. |
Apple's fsync and fdatasync explicitly do NOT flush the drive write cache to the drive platters. This is in contrast to Linux's fsync and fdatasync which do, according to recent man pages. F_FULLFSYNC is Apple's equivalent for flushing buffered data to permanent storage. PR-URL: #1124 Refs: nodejs/node#9439 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Thanks, done. |
Refs: nodejs#9439 Fixes: nodejs#9464 Fixes: nodejs#9690 PR-URL: nodejs#10717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Refs: nodejs#9439 Fixes: nodejs#9464 Fixes: nodejs#9690 PR-URL: nodejs#10717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Refs: nodejs#9439 Fixes: nodejs#9464 Fixes: nodejs#9690 PR-URL: nodejs#10717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Refs: nodejs#9439 Fixes: nodejs#9464 Fixes: nodejs#9690 PR-URL: nodejs#10717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Refs: nodejs#9439 Fixes: nodejs#9464 Fixes: nodejs#9690 PR-URL: nodejs#10717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Refs: nodejs/node#9439 Fixes: nodejs/node#9464 Fixes: nodejs/node#9690 PR-URL: nodejs/node#10717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
I tried looking in the
Node
andlibuv
source but was unable to confirm whetherfs.fsync()
does in fact doF_FULLFSYNC
ondarwin
?According to http://xiayubin.com/blog/2014/06/20/does-fsync-ensure-data-persistency-when-disk-cache-is-enabled/ as of 14.04 Ubuntu has moved to a stronger
fsync
thatincludes writing through or flushing a disk cache if present
.To do this on
darwin
requiresF_FULLFSYNC
. Otherwise a Node app may callfsync
with nothing actually being flushed to disk ondarwin
systems.Obviously,
fsync
will always be broken on older operating systems, but at least the tendency is to move towards making stronger guarantees, not the other way round.The text was updated successfully, but these errors were encountered: