fsync, rename, O_ATOMIC/O_PONIES

Olaf van der Spek olaf at xwis.net
Sun Mar 4 11:14:39 CST 2012


On 2-3-2012 14:12, Christoph Hellwig wrote:
>> I'd like to ask:
>> - Is there a tool to log all unsafe operations?
>
> What is an unsafe operation?  Anything that's dumb and might lose data?

For example

> The possibilities are sheer endless.

And?

>> - What is the *right* way to update a file?
>
>   fd = open(tmpfile, ...);
>   write(fd, ...);  // or any other update
>   fdatasync(fd);
>   rename(tmpfile, realfile);

Argh, come on.
That's not real and it's not complete. tmpfile is undefined, errors 
aren't handled and you have lots of unlisted assumptions or regressions.

Olaf



More information about the xfs mailing list