Re: adding proper O_SYNC/O_DSYNC, was Re: O_DIRECT and barriers

From: Ulrich Drepper
Date: Fri Aug 28 2009 - 16:51:45 EST

On 08/28/2009 09:41 AM, Christoph Hellwig wrote:
Yeah. The implementation really is trivial in 2.6.32 - we basically
just need to change one function to check the new O_REALLY_SYNC flag
and pass down a 0 instead of a 1 to another routine in the generic
fs code, plus doing the same in a few filesystems opencoding it instead
of using the generic helpers.

I don't think you have to change anything. As I wrote before, the kernel ignores unknown O_* flags. It's usually a problem. Here it is a positive thing.

So the logistics of doing the flags really is the biggest work here.
And I'm not entirely sure how to do it correctly. Can we just switch
the current O_SYNC defintion in the kernel headers to O_DSYNC while
adding the new O_SYNC and everything will continue to work?

No, that's not a good idea. This would mean a program compiled with newer headers is using O_SYNC which isn't known to old kernels and ignored. Such programs will then not even get the current O_DSYNC benefits.

That includes a write from another process? So O_RSYNC basically means
doing an range-fdatasync before the actual read request?

Yes. You can easily see how this can be useful.

Again, we could implement this easily if we care enough.

I think it can be useful at times.

â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at