2 ms·
I think the man page http://linux.die.net/man/2/fsync http://linux.die.net/man/2/fsync answers the questions the article asks about fsync(). fsync() = YES met
by ape4 11y ago
I think the man page
http://linux.die.net/man/2/fsync http://linux.die.net/man/2/fsync
answers the questions the article asks about fsync().
fsync() = YES metadata, YES data, NO dir entry
fdatasync() = NO metadata, YES data, NO dir entry
fsync() of dir = NO metadata, NO data, YES dir entry
- kr7 11y agoFor Linux, but it's not portable across all Unixes. fsync is allowed to do nothing (1) and does not need to work on directories (2). On Mac OSX, fsync will not flush the disk cache, which can lead to data loss (3). (1) http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html http://pubs.opengroup.org/onlinepubs/9699919799/functions/fs... (2) http://austingroupbugs.net/view.php?id=672 http://austingroupbugs.net/view.php?id=672 (3) https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/fsync.2.html https://developer.apple.com/library/mac/documentation/Darwin...
- valleyer 11y agofsync(2) on OS X and other Darwins also does not sync metadata. You need to use fcntl(2) with F_FULLFSYNC for that.
- ryao 11y agoIt looks like doing `sysctl -w kern.always_do_fullfsync=1` Will produce a sane behavior: https://opensource.apple.com/source/xnu/xnu-2422.1.72/bsd/hfs/hfs_vnops.c https://opensource.apple.com/source/xnu/xnu-2422.1.72/bsd/hf... Alternatively, you could just use the ZFS driver for Mac OS X. It will do fsync properly.