Subject: Re: bug#19681: [PATCH] sync: use syncfs(2) if any argument is specified

From: Pádraig Brady <[email-masked]>
Date: Sun, 25 Jan 2015 17:41:12 +0000

On 25/01/15 15:38, Paul Eggert wrote:
> If we're adding this sort of option, shouldn't we also give users the ability to 
> invoke fsync and fdatasync on a single file, as opposed to syncfs on an entire 
> file system?

Yes good point on also integrating per file syncing.
Per file syncing is already supported by dd,
but would be a natural fit to sync(1).

BTW I grepped my internal notes on sync and noticed http://lwn.net/Articles/433384/
which details syncfs() and also suggests `sync file...` as an interface.

So we have: fdatasync < fsync < syncfs < sync
referring to:: file data, file data + metadata, file system, all file systems

You'd need an option to distinguish between file and file system.
The option could refer to _what_ to sync, or what _method_ to use to sync.

An advantage of specifying the method is they're well
understood and described elsewhere:
  --mode={fdatasync, fsync, syncfs, sync}
The first two would give an error without arguments,
the last would give an error with arguments.

The alternative _what_ interface might look like:
  --what={data, file-system}
or split out to separate options like:
  -d,--data, -f,--file-system
An advantage of specifying what to sync is that
it's a bit more general, avoiding specifying implementation methods.
Also the options would not imply needing or not needing to specify files.

I'd be incline to go with the _what_ interface above.

thanks,
Pádraig