Database on JFFS2?

Thomas Gleixner tglx at linutronix.de
Wed Apr 16 07:35:50 EDT 2003


On Wednesday 16 April 2003 12:04, Esben Nielsen wrote:
> 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."

No, JFFS2 writes all data immidiately to the FLASH chip. GC takes care of 
reusing blocks, where obsolete information is stored. This happens, if you 
change the contents of a file. This space is garbage collected at some point 
and valid nodes, which reside on the same block are moved to a different 
block. If the block, which is gc'ed contains no more valid information it is 
erased and can be used for writing again.

> 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!).

Erase is always a full block (e.g. 128K), but writes happen in small chunks. 

Have you really thought about the numbers ?
20 years, 365 days
Erasecycles max. 10E5:	13,6 erases per day
Erasecycles max. 10E6:	136 erases per day

I assume a compressed database size of 1MB and a FLASH size of 8MB.
Even if you have to write the full database every time you will be allowed
to do it 
108,8 times for max. Erasecycles of 10E5 and
1088 times for  max. Erasecycles of 10E6

which means a write every
13 minutes  for max. Erasecycles of 10E5 and
1,3 minutes  for max. Erasecycles of 10E6

assumed, that your device operates 20 years, 365 days/year and 24h /day.

If you buffer your small changes in sqlite or on a ramfs, which maybe located 
in a buffered SRAM, you can reduce the write cycles further and expand the 
lifetime beyond your retirement age. :)

> 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 :-(

JFSS2 does no write on fsync, as data are already written.

-- 
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: tglx at linutronix.de




More information about the linux-mtd mailing list