safe writing in applications (was: Re: massively truncated files with XFS with sudden power loss on 2.6.27 and 2.6.28)

Christoph Hellwig hch at infradead.org
Mon Dec 29 13:54:06 CST 2008


On Mon, Dec 29, 2008 at 08:48:40PM +0100, Martin Steigerwald wrote:
> It might be wise however to file enhancement requests for the KDE 
> applications where I observed this behavior if safer writing within the 
> applications is possible. Any hints on what application developers should 
> keep in mind when writing out config files?

Preferably use O_SYNC.  Never truncate and then rewrite, in doubt write
a new file and rename it to the right place after it was fsync'ed (the
mailserver trick)

in the meantime a nice way to hack around this is do chattr +S for all
these files which forces synchronous writes.  Doesn't help if they
actually use the rename trick above sometimes.




More information about the xfs mailing list