Re: Linux 2.6.29

Linus Torvalds
2009-04-02T16:50:55Z

On Thu, 2 Apr 2009, David Rees wrote:
>
> MythTV actually uses fdatasync, not fsync (or at least that's what it
> did last time I looked at the source). Not sure how the behavior of
> fdatasync compares to sync_file_range.

fdatasync() _waits_ for the data to hit the disk.

sync_file_range() just starts writeout.

It _can_ do more - you can also ask for it to wait for previous write-out
in order to start _new_ writeout, or wait for the result, but you wouldn't
want to, not for something like this.

sync_file_range() is really a much nicer interface, and is a more extended
fdatasync() that actually matches what the kernel does internally.

You can think of fdatasync(fd) as a

sync_file_range(fd, 0, ~0ull,
SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_AFTER);

and then you see why fdatasync is such a horrible interface.

Linus