OO Database question with FLASH drive

Dave Hylands dhylands at gmail.com
Fri Nov 17 15:23:36 UTC 2006


Hi Jon

> That is one of the silliest things I've ever read, re: fragmentation on a
> flash drive. Fragmentation is only a problem when you have a physical read
> head that has to traverse different areas of the media to read the data.
> When its just reading electronics, it shouldn't make an iota of difference.

It's a real issue. The issue is this, when you deal with flash memory,
you hve an erase size and a page size. The erase size is often quite
large, like 128K and the page size is usually 512 or 2048 bytes.

So the flash file systems use a model where they erase a page (clears
it to all 0xff's) and then write out pages. The pages may come from
different files and the fileystem deals with the fact that some of the
pages contain old data. When you say write the forst page of a file,
and then rewrite it, it adds a new page somewhere else on the
filesystem, and doesn't typically replace the old one. The old one
will eventually get garbage collected.

So you wind up with fragmentation because you've got lots of good data
and lots of useless data all intermingled together.

JFFS2 takes care of garbage collecting all of this stuff together and
doing the consolidation. It may be that flash drives don't.

Also, NAND chips can only take about N writes to an erase block before
you need to erase and rewrite (N is a small number probably around 10
- depends on the flash chip), Whereas with NOR chips you can writes
pages until you fill the erase block.

For more background, the "How does it work" section is a really good read:
http://sourceware.org/jffs2/

-- 
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/



More information about the Squeak-dev mailing list