Question: how fsync works in linux?
Answer: fsync operates on a single file. It will flush all changes made to that file. If multiple processes are writing into a single file the process that made the fsync call will be paused until all the changes are written to disk. This is more complicated when some journaling filesystems come into play.