public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Esben Nielsen <esn@cotas.dk>
To: "Jörn Engel" <joern@wohnheim.fh-wedel.de>,
	"Jasmine Strong" <jasmine@regolith.co.uk>
Cc: linux-mtd@lists.infradead.org
Cc: Holger Schurig <h.schurig@mn-logistik.de>
Subject: Re: Database on JFFS2?
Date: Wed, 16 Apr 2003 12:04:32 +0200	[thread overview]
Message-ID: <200304161204.32557.esn@cotas.dk> (raw)
In-Reply-To: <20030415171123.GH7721@wohnheim.fh-wedel.de>

I appreciate that you look into my problem and get a good discussion out of it 
:-)

I did try to follow it and as far as I can see it JFFS2 _only_ writes to flash 
in the GC thread? That contradicts the manual page for fsync(): "fsync copies 
all in core parts of a file to disk, and waits  until  the device  reports  
that all parts are on stable storage."

I am not much into flash technology itself (NOR contra NAND), but I know that 
on our device one write erases and rewrites one block of 128k. Each block can 
only be erased between 1E5 and 1E6 times. We thus have to be carefull as our 
device have to live for 20 years (yes, that is what a promise our 
customers!).

If JFFS2 does do a real write on fsync() we will get too many physical writes 
unless we buffer our inserts/updates into one big transaction in the 
application layer above the database. On the other hand if JFFS2 doesn't 
commit changes we risc getting our database file inconsistant if we loose 
power in the middle :-(

Now in our application the most important thing is that our database file is 
self-consistant at reboot such we can get up running again. If we loose the 
last few inserts before the reboot we wont go out of buisness. The most 
optimal was if we could tweak sqlite to syncronice it's fsync with JFFS2 such 
the last written data resides purely in memory until we have enough to erase 
a full page on flash and then we sync it all. That way we can minimalize the 
number of writes and at the same time avoid inconsistant data at boot.

Another option was to have JFFS2 use battery backed up SRAM as temporately 
storage. fsync() would then work "correcty" by just writing to that SRAM. 
Is it in possible to do make JFFS2 use a specific part of memory as "cache" 
before the GC thread writes it to flash? Is it even possible to make JFFS2 
reestablish that cache at mount such no data would be lost if it was synced 
with the cache before a crash?

Esben

On Tuesday 15 April 2003 19:11, Jörn Engel wrote:
> On Tue, 15 April 2003 17:23:59 +0100, Jasmine Strong wrote:
> > On Tuesday, Apr 15, 2003, at 17:14 Europe/London, Jörn Engel wrote:
> > >On Tue, 15 April 2003 17:11:44 +0100, Jasmine Strong wrote:
> > >>Unless it would cause many erases, which would slow things down a
> > >>lot...
> > >
> > >Erases get triggered by garbage collection, which depends on the
> > >amount of data written, not the chunk size.
> >
> > yes.  I think my two points were actually the same point taken twice :-)
> > If you're only updating a few bytes of data you will end up writing
> > a large proportion of log control data.  That'll end up being
> > responsible for most of the erase traffic.
>
> Actually, that shouldn't matter too much. For comparison, I did some
> benchmarks using jffs2 (without compression) as a filesystem for a
> ramdisk.
>
> The benchmark wrote data to jffs2, deleted it and repeated this
> several times to remove statistical noise. Horrible results.
> Then I got a clue and added "sleep 6" after both writing and deleting,
> getting roughly twice the performance. Why?
>
> Under normal operation, the system is idle a lot and the garbage
> collector (GC) has plenty of time to clean up the mess you made. But
> the first benchmark was measuring a system without idle times, so all
> writes were waiting for GC to finally free some space. Wrong.
>
> Back to the Database:
> Even if you write data in very small chunks, the system should have
> enough free time to GC those fragments and reassemble them into larger
> chunks with less overhead, so this doesn't matter.
>
> Unless you permanently operate near the limit. Without the free time
> for GC, this does matter.
>
> > Still, if you need to be powerfail-safe, I can't see any way of not
> > doing this.
>
> Right.
>
> Jörn

       reply	other threads:[~2003-04-16 10:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030415171123.GH7721@wohnheim.fh-wedel.de>
2003-04-16 10:04 ` Esben Nielsen [this message]
2003-04-16 11:35   ` Database on JFFS2? Thomas Gleixner
2003-04-16 11:13     ` Jörn Engel
2003-04-16 14:05       ` Thomas Gleixner
2003-04-16 13:08         ` Jörn Engel
2003-04-16 14:30         ` matsunaga
2003-04-16 18:19           ` Thomas Gleixner
2003-04-17 16:02             ` matsunaga
2003-04-22  8:07     ` Esben Nielsen
2003-04-22  8:24       ` Jörn Engel
     [not found] <00512BA4F9D3D311912A009027E9B8F407E4D9@NT>
2003-04-16 15:23 ` Jörn Engel
2003-04-14  8:08 Esben Nielsen
2003-04-14 23:03 ` Charles Manning
2003-04-15  8:06   ` Esben Nielsen
2003-04-15  8:51     ` Holger Schurig
2003-04-15 15:06       ` Esben Nielsen
2003-04-15 15:39         ` Jörn Engel
2003-04-15 16:11           ` Jasmine Strong
2003-04-15 16:14             ` Jörn Engel
2003-04-15 16:23               ` Jasmine Strong
2003-04-16 11:16                 ` Jörn Engel
2003-04-15  9:13     ` Jörn Engel

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=200304161204.32557.esn@cotas.dk \
    --to=esn@cotas.dk \
    --cc=jasmine@regolith.co.uk \
    --cc=joern@wohnheim.fh-wedel.de \
    --cc=linux-mtd@lists.infradead.org \
    /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