On Tue, Oct 16, 2018 at 02:09:27PM +0000, Romain Le Disez wrote: > > > Le 16 oct. 2018 à 15:53, Stefan Ring <stefanrin@xxxxxxxxx> a écrit : > > > > But in what order? If I understood correctly, with the single sync() > > call, he might end up with a directory entry referencing an incomplete > > file. Which should not be possible in the case with the two fsyncs. > > In what order, this is exactly my question :) > > We are creating hundreds or thousands of files in a row. Converting thousands of fsync() to one sync() would be a great performance improvement, but I want to be sure we are not taking any risk with data consistency. I honestly don't remember on the top of my head, a sync() will cause the whole XFS log to be flushed, and the flush order, I believe, will be according to how the metadata got logged in. But, I do not believe it comes to the case. Reality is, doesn't matter which is flushed first, file or directory metadata. If sync() fails, you must assume nothing got flushed at all, and not 'guess' if something got flushed in. But, as I mentioned before, and also did Dave, unless you want to cause a whole filesystem flush every time you have a file modified, use fsync() on the specific files, instead a global sync(). Cheers > > -- > Romain > -- Carlos