Re:POSIX v. reality: A position on O_PONIES
by Joker_vD on Thursday November 23, 2023 @11:49PM
(#38400735)
Surely fsync() should at least initiate syncing the data to the disk? Otherwise, everything FS-related could theoretically still fit in the memory cache forever, and so fsync() will never return.
No. If you don't call fsync(), there's no guarantee that your data will _ever_ be written to disk.
Some file systems with some settings may write data to hardware after some delay or periodically, but others may not.
fsync() "performs" e.g. an ATA FLUSH command on the underlying hardware.
Now some people might not like how long it takes; maybe it's waiting for some unnecessary events that are not relevant to this file.