lkml.org 
[lkml]   [2011]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Allow O_SYNC to be set by fcntl(F_SETFL)
On Fri, 08 Apr 2011 13:39:16 -0400
Steve Rago <sar@nec-labs.com> wrote:

> > I wonder if we should sync the file when someone sets O_SYNC this way.
> > If we don't then there is a period during which we have an fd which has
> > O_SYNC set, but it has pending unwritten data. An O_SYNC fd should
> > never be in such a state!
>
> Why not?

Because it's inconsistent. An O_SYNC fd never has outstanding writeout.
Except for in this one new and special time window between a setfl()
and the next write().

It's not a big deal, but it's somewhat ugly and merits thinking about.

> If I write something in non-synchronous mode, then change the file descriptor to synchronous mode, I should
> not make any assumptions about what was written prior to this point. If I care that much, I'll call fsync.

Well. You can call fsync() after every write() too.

> All that
> matters is that the operating system honors the contract as specified by the system call API.

There's a lot more to it than that. Things like
quality-of-implementation and principle-of-least-surprise. We used to
have a particular relationship between an O_SYNC fd and the state of
the inode which it represents. With this patch, that relationship no
longer holds.

As I say: not a big deal IMO, but it should be aired and thought about.


\
 
 \ /
  Last update: 2011-04-08 19:59    [W:0.039 / U:2.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site