* UBIFS sync question
@ 2008-09-30 22:28 Bruce_Leonard
2008-09-30 22:53 ` Bruce_Leonard
2008-10-01 5:40 ` Artem Bityutskiy
0 siblings, 2 replies; 8+ messages in thread
From: Bruce_Leonard @ 2008-09-30 22:28 UTC (permalink / raw)
To: linux-mtd
Artem,
We've run into a side effect that we think is probably a design choice in
UBIFS, but we want to make sure before we start trying to troubleshoot a
"bug". What we do is open an existing file in a UBIFS formated UBI
volume on a NAND flash, add a few lines to it, close the file, then
WITHOUT un-mounting the file system, reboot the box (simulating a power
outage). When the box reboots and we look at the file, it's zero length
and has no contents. I suspect it's because UBIFS does less frequent
syncs than say ext2 for performance reasons, and we're just losing the
contents of the file because there's no sync before the reboot.
Is this correct or do we need to start digging for something broken?
Thanks.
Bruce
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UBIFS sync question
2008-09-30 22:28 UBIFS sync question Bruce_Leonard
@ 2008-09-30 22:53 ` Bruce_Leonard
2008-10-01 5:40 ` Artem Bityutskiy
1 sibling, 0 replies; 8+ messages in thread
From: Bruce_Leonard @ 2008-09-30 22:53 UTC (permalink / raw)
To: Bruce_Leonard; +Cc: linux-mtd-bounces, linux-mtd
linux-mtd-bounces@lists.infradead.org wrote on 09/30/2008 03:28:10 PM:
> Artem,
>
> We've run into a side effect that we think is probably a design choice
in
> UBIFS, but we want to make sure before we start trying to troubleshoot a
> "bug". What we do is open an existing file in a UBIFS formated UBI
> volume on a NAND flash, add a few lines to it, close the file, then
> WITHOUT un-mounting the file system, reboot the box (simulating a power
> outage). When the box reboots and we look at the file, it's zero length
> and has no contents. I suspect it's because UBIFS does less frequent
> syncs than say ext2 for performance reasons, and we're just losing the
> contents of the file because there's no sync before the reboot.
>
> Is this correct or do we need to start digging for something broken?
>
> Thanks.
>
> Bruce
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
Ummm, never mind. Stupidity attack over. If I would RTFM that you went
to the trouble of writing all would be good with the world :).
Bruce
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UBIFS sync question
2008-09-30 22:28 UBIFS sync question Bruce_Leonard
2008-09-30 22:53 ` Bruce_Leonard
@ 2008-10-01 5:40 ` Artem Bityutskiy
2008-10-01 17:06 ` Bruce_Leonard
2008-10-02 12:55 ` Jamie Lokier
1 sibling, 2 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2008-10-01 5:40 UTC (permalink / raw)
To: Bruce_Leonard; +Cc: linux-mtd
On Tue, 2008-09-30 at 15:28 -0700, Bruce_Leonard@selinc.com wrote:
> Artem,
>
> We've run into a side effect that we think is probably a design choice in
> UBIFS, but we want to make sure before we start trying to troubleshoot a
> "bug". What we do is open an existing file in a UBIFS formated UBI
> volume on a NAND flash, add a few lines to it, close the file, then
> WITHOUT un-mounting the file system, reboot the box (simulating a power
> outage). When the box reboots and we look at the file, it's zero length
> and has no contents. I suspect it's because UBIFS does less frequent
> syncs than say ext2 for performance reasons, and we're just losing the
> contents of the file because there's no sync before the reboot.
>
> Is this correct or do we need to start digging for something broken?
Well, you should sync the file, see
http://www.linux-mtd.infradead.org/doc/ubifs.html#L_writeback
However, if you open a file, and just add few lines to it, then it
should not become empty after reboot. You should just loose whole or
part of new data.
I think you actually truncate the file, then re-write it, instead of
appending. This often happens in case of shell scripts - shell commands
like truncating files.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UBIFS sync question
2008-10-01 5:40 ` Artem Bityutskiy
@ 2008-10-01 17:06 ` Bruce_Leonard
2008-10-01 17:32 ` Josh Boyer
2008-10-02 12:55 ` Jamie Lokier
1 sibling, 1 reply; 8+ messages in thread
From: Bruce_Leonard @ 2008-10-01 17:06 UTC (permalink / raw)
To: dedekind; +Cc: linux-mtd
>
> Well, you should sync the file, see
> http://www.linux-mtd.infradead.org/doc/ubifs.html#L_writeback
>
Thanks for the reply. I found the article about ten minutes after I
posted the question :\. I've gotten so used to just posting questions
that I momentarily forgot that there's already a source of information out
there. Thanks for putting up with me and sorry for the noise.
Bruce
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UBIFS sync question
2008-10-01 17:06 ` Bruce_Leonard
@ 2008-10-01 17:32 ` Josh Boyer
2008-10-01 17:40 ` Bruce_Leonard
0 siblings, 1 reply; 8+ messages in thread
From: Josh Boyer @ 2008-10-01 17:32 UTC (permalink / raw)
To: Bruce_Leonard; +Cc: linux-mtd
On Wed, Oct 01, 2008 at 10:06:14AM -0700, Bruce_Leonard@selinc.com wrote:
>>
>> Well, you should sync the file, see
>> http://www.linux-mtd.infradead.org/doc/ubifs.html#L_writeback
>>
>
>Thanks for the reply. I found the article about ten minutes after I
>posted the question :\. I've gotten so used to just posting questions
>that I momentarily forgot that there's already a source of information out
>there. Thanks for putting up with me and sorry for the noise.
You're fine. No need to apologize. Artem is odd, in that he actually
writes and maintains documentation. Unlike the rest of us that just
code things and expect people to keep up ;).
josh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UBIFS sync question
2008-10-01 17:32 ` Josh Boyer
@ 2008-10-01 17:40 ` Bruce_Leonard
2008-10-02 5:21 ` Artem Bityutskiy
0 siblings, 1 reply; 8+ messages in thread
From: Bruce_Leonard @ 2008-10-01 17:40 UTC (permalink / raw)
To: Josh Boyer; +Cc: linux-mtd
Josh Boyer <jwboyer@gmail.com> wrote on 10/01/2008 10:32:12 AM:
> On Wed, Oct 01, 2008 at 10:06:14AM -0700, Bruce_Leonard@selinc.com
wrote:
> >>
> >> Well, you should sync the file, see
> >> http://www.linux-mtd.infradead.org/doc/ubifs.html#L_writeback
> >>
> >
> >Thanks for the reply. I found the article about ten minutes after I
> >posted the question :\. I've gotten so used to just posting questions
> >that I momentarily forgot that there's already a source of information
out
> >there. Thanks for putting up with me and sorry for the noise.
>
> You're fine. No need to apologize. Artem is odd, in that he actually
> writes and maintains documentation. Unlike the rest of us that just
> code things and expect people to keep up ;).
>
> josh
Even better, he writes documentation that you don't need intimate
knowledge of the code to understand and use. You can just read it and go
"well that makes sense". There's some documentation out there that worse
than having no documentation because it either makes no sense or tells you
absolutly nothing. So here's three cheers for Artem and all his hard
work. Thanks Artem.
Bruce
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UBIFS sync question
2008-10-01 17:40 ` Bruce_Leonard
@ 2008-10-02 5:21 ` Artem Bityutskiy
0 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2008-10-02 5:21 UTC (permalink / raw)
To: Bruce_Leonard; +Cc: Josh Boyer, linux-mtd
Bruce,
On Wed, 2008-10-01 at 10:40 -0700, Bruce_Leonard@selinc.com wrote:
> Even better, he writes documentation that you don't need intimate
> knowledge of the code to understand and use. You can just read it and go
> "well that makes sense". There's some documentation out there that worse
> than having no documentation because it either makes no sense or tells you
> absolutly nothing. So here's three cheers for Artem and all his hard
> work. Thanks Artem.
Thank you. However, I forward 2 of the 3 cheers to Adrian Hunter. We
were working with him shoulder to shoulder for a year. He implemented
the core and the most difficult parts of it. It is just that I am more
publicly visible.
Thanks.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UBIFS sync question
2008-10-01 5:40 ` Artem Bityutskiy
2008-10-01 17:06 ` Bruce_Leonard
@ 2008-10-02 12:55 ` Jamie Lokier
1 sibling, 0 replies; 8+ messages in thread
From: Jamie Lokier @ 2008-10-02 12:55 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: linux-mtd, Bruce_Leonard
Artem Bityutskiy wrote:
> However, if you open a file, and just add few lines to it, then it
> should not become empty after reboot. You should just loose whole or
> part of new data.
>
> I think you actually truncate the file, then re-write it, instead of
> appending. This often happens in case of shell scripts - shell commands
> like truncating files.
Generally when updating a file, then I write a new file under a
temporary name in the same directory, then fsync() the new file, then
rename() it over the original file, then fsync() the containing
directory.
That should be safe for any change to the file contents. After boot
during this process, you should see the old contents or the new
contents, nothing else. After the second fsync(), you should be
confident that any subsequent boot will always see the new contents.
O_APPEND should be ok too and is essential for log files, but there's
always a danger than after a boot in the middle of the update, you'll
see half the write.
-- Jamie
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-10-02 12:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-30 22:28 UBIFS sync question Bruce_Leonard
2008-09-30 22:53 ` Bruce_Leonard
2008-10-01 5:40 ` Artem Bityutskiy
2008-10-01 17:06 ` Bruce_Leonard
2008-10-01 17:32 ` Josh Boyer
2008-10-01 17:40 ` Bruce_Leonard
2008-10-02 5:21 ` Artem Bityutskiy
2008-10-02 12:55 ` Jamie Lokier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox