JFFS2: truncated files after power loss scenario

Artem Bityutskiy dedekind1 at gmail.com
Sun Feb 6 12:39:37 EST 2011


On Sun, 2011-02-06 at 18:12 +0100, Albrecht Dreß wrote:
> Am 06.02.11 17:03 schrieb(en) Artem Bityutskiy:
> > The bottom line is that it is difficult to fix broken applications
> by
> > changing JFFS2. The right way to update configuration files is
> described
> > here:
> > http://www.linux-mtd.infradead.org/faq/ubifs.html#L_atomic_change
> 
> Dumb question: isn't it necessary to also run sync() after the fsync()
> - close() - rename() sequence, as to ensure that the directory entries
> are actually flushed to the flash?  Or does a call to
> 
> 	rename("configfile.tmp", "configfile");
> 
> *ensure* that after a crash during this call either the entry of the
> old file (configfile) or of the newly written contents
> (configfile.tmp) is accessible, independent of the moment when the
> crash happens?

Well, there was a huge debate about this. Rename does not ensure sync in
many file-systems, and posix does not require this. But user-spaces
relies on this and many people believe this should obviously be
guaranteed. So ext4 and may be some other FSes adjusted accordingly. I
wrote about this in UBIFS FAQ:

http://www.linux-mtd.infradead.org/doc/ubifs.html#L_sync_exceptions

You'll find all the relevant links there.


-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)




More information about the linux-mtd mailing list