fsync(2)

Konstantin Belousov kostikbel at gmail.com
Sun Jul 12 19:05:27 UTC 2020


On Mon, Jul 13, 2020 at 01:49:22AM +0700, Eugene Grosbein wrote:
> Hi!
> 
> Assume we have parent process that created a file and keeps it open not writing anything there.
> The parent spawns a child passing file name and the child opens it,
> fills it with data and exits without fsync()'ing the file.
> 
> In case of UFS there is upto 30 seconds time gap when file size is not updated,
> so if crash occurs, the file ends up empty.
> 
> The question: will fsync() in parent work for such still open file descriptor?

fsync() syncs the vnode, not the file or file descriptor. So fsync() on
any file descriptor referencing the same vnode, is enough to ensure that
the data is written to the underlying volume.


More information about the freebsd-hackers mailing list