O_SYNC and filesystem updating

meissner at dg_rtp.UUCP meissner at dg_rtp.UUCP
Wed Feb 25 01:33:17 AEST 1987


In article <413 at yabbie.rmit.oz> rcodi at yabbie.rmit.oz (Ian Donaldson) writes:
> 
> It is not sensible to ensure that *every* write be syncronously updated
> to disk.  To do this would incurr enormous disk overheads.  Picture
> doing a write of 2 bytes here and then 3 bytes there -- both in the same
> disk block -- it requires 2 disk writes to do it.  If it wasn't important
> that the 2 bytes be syncronously written before the 3 bytes then why
> go to the effort to do it?  If it was important, then fine, we must live
> with it.  The thing is, that most times it *isn't* necessary.

Then don't set O_SYNC for that file.  For your typical database with
transactions, writes to the log file must be guaranteed.

> I suppose that you could open the file twice with SVR[23], one
> with O_SYNC and one without to acheive a similar effect, but then you 
> have all sorts of problems if you use a buffered package such as stdio 
> to do I/O on them, unless you use the O_SYNC fd for just flushing
> blocks (even that won't work properly unless you rewrite all the
> blocks you wrote with the non O_SYNC fd).

I believe you can also set O_SYNC on/off with fcntl at any time.  This
avoids the problems you mentioned above.
-- 
	Michael Meissner, Data General	Uucp: ...mcnc!rti-sel!dg_rtp!meissner

It is 11pm, do you know what your sendmail and uucico are doing?



More information about the Comp.unix.wizards mailing list