From: "Albrecht Dreß" <albrecht.dress@arcor.de>
To: dedekind1@gmail.com
Cc: Sven <svenjaborek@gmx.de>, linux-mtd@lists.infradead.org
Subject: Re: JFFS2: truncated files after power loss scenario
Date: Sun, 06 Feb 2011 19:40:10 +0100 [thread overview]
Message-ID: <1297017610.1854.3@antares> (raw)
In-Reply-To: <1297013977.4460.78.camel@localhost> (from dedekind1@gmail.com on Sun Feb 6 18:39:37 2011)
[-- Attachment #1: Type: text/plain, Size: 1576 bytes --]
Am 06.02.11 18:39 schrieb(en) Artem Bityutskiy:
> 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.
Thanks a lot for the pointers!
Unfortunately, they are more more about ubi & ext4, but I am in particular interested in JFFS2's behaviour, so please excuse my questions, but it's a really critical point... Currently, I use the following sequence to write my configs to jffs2 (both NOR flash and mtd-ram):
open(scratch, O_RDWR | O_CREAT | O_TRUNC, perms);
write();
fsync();
close();
sync(); // #1
rename(scratch, realname);
sync(); // #2
As far as I understand the information you cited, this should be safe under all circumstances for jffs2. Is that assumption correct?
As calling sync() might be a lot more expensive than fsync() if other file systems are used simultaneously (I have a vfat fs on a CF card open), my question is now if I can safely omit either sync() #1 or #2 or both?
When reading, I first try realname, and if that fails scratch, as to cover the case that rename() was killed in mid-air so realname has already been removed from the directory, but scratch is still there. Can this case happen at all for jffs2?
Thanks in advance,
Albrecht.
[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]
next prev parent reply other threads:[~2011-02-06 18:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-06 14:59 JFFS2: truncated files after power loss scenario Sven
2011-02-06 15:25 ` Artem Bityutskiy
2011-02-06 15:47 ` Sven
2011-02-06 16:03 ` Artem Bityutskiy
2011-02-06 17:12 ` Albrecht Dreß
2011-02-06 17:39 ` Artem Bityutskiy
2011-02-06 18:40 ` Albrecht Dreß [this message]
2011-02-11 14:00 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1297017610.1854.3@antares \
--to=albrecht.dress@arcor.de \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=svenjaborek@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox