Re: Linux 2.6.29

From: Linus Torvalds
Date: Thu Apr 02 2009 - 12:50:55 EST




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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/