Subject: Re: fsync_range() system call
To: Bill Studenmund <wrstuden@netbsd.org>
From: Klaus Klein <kleink@reziprozitaet.de>
List: tech-kern
Date: 10/30/2003 12:07:35
On Thursday 30 October 2003 05:56, Bill Studenmund wrote:

> On Sat, Oct 25, 2003 at 03:53:30AM +0200, Klaus Klein wrote:
> > On Saturday 25 October 2003 00:23, Bill Studenmund wrote:
> > As a general observation, I think the FSYNC_DATAONLY flag name/value
> > should be recycled for FSYNC_DATASYNC semantics; the current
> > FSYNC_DATAONLY semantics are too aggressive for its (and
> > fdatasync(2)'s) own good.
>
> So if I understand your suggestion, now, fsync_range() should:
>
> For FDATASYNC (sync data and enough metadata to read the data), call
> VOP_FSYNC with FSYNC_DATAONLY.
>
> For FFILESYNC (sync data and all metadata), call VOP_FSYNC with FDATASYNC
>
> | FSYNC_WAIT. Or just FSYNC_WAIT.

Err, not quite.  For one, FSYNC_WAIT should be set in both cases since you 
don't want fsync*() to return until all relevant (meta-)data are writen.

For the FFILESYNC case, FSYNC_DATAONLY must not be set; it would hint that 
file data synchronization was sufficient while you actually requested file 
metadata to be synced by FFILESYNC.  To illustrate, the code fragment I had 
in mind is:

	/* As suggested earlier */
	if ((SCARG(uap, flags) & (FDATASYNC | FFILESYNC)) == 0) {
		FILE_UNUSE(fp, p);
		return (EINVAL);
	}

	if (SCARG(uap, flags) & FFILESYNC)
		flags = FSYNC_WAIT;
	else
		flags = FSYNC_WAIT | FSYNC_DATAONLY;

One might argue whether requesting both FFILESYNC and FDATASYNC should be 
permitted; I believe doing so will do no harm but FFILESYNC, being the 
stronger requirement, should take precedence over FDATASYNC.


- Klaus