Skip to content

Comment on Linux file write patterns: So you want to write to a file fastparent

Comments

write() guarantees that the bits have been sent to the disk, and the disk reports that they have been written (or, if a nonvolatile cache is available, it is in the cache).

At least for Linux, I think that's dangerously untrue. On my machine, 'man write' even includes an explicit warning:

   A successful return from write() does not make any 
   guarantee that data has been  committed to  disk.
   In  fact, on some buggy implementations, it does not
   even guarantee that space has successfully been reserved
   for the data.  The only way to be sure is to call
   fsync(2) after you are done writing all your data.
There are ways to configure a file system so this is not the case, but they are rare. Is there a reference you could point to that would clarify what you are saying?
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.