On Tue, Oct 16, 2018 at 2:57 PM Carlos Maiolino <cmaiolino@xxxxxxxxxx> wrote: LY); > > write(fd, ...); > > fsetxattr(fd, ...); > > linkat(AT_FDCWD, « /proc/self/fd/" + fd, AT_FDCWD, "/data/foobar", AT_SYMLINK_FOLLOW); > > sync(); > > IIRC, sync() on Linux is supposed to have the same guarantees of syncfs(), once > we wait for IO completion on sync (POSIX doesn't guarantee sync() will return > until everything is written to backing storage, but Linux does wait for IO > completion). > > Short answer is, sync() does work the same way as if you run fsync() on every > file on your filesystem. The question would be. Do you want to fsync() all files > in your filesystem? This may take way longer than a pair of fsync() on the file > and its directory. But it's your call, as I said sync() will behave as if you > have ran a fsyn() on every file/directory on your filesystem. 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.