Re: [ECOS] Stress testing JFFS2

Thomas Koeller
2003-10-15T10:08:53Z

In an attempt to understand what's really going on inside JFFS2, I
spent a day analyzing the code. Here's what I found. Please everybody
comment on this and correct any errors on my side.

- Every operation that changes the contents of the FLASH (even deleting files!)
is performed by writing new nodes to the FLASH. Every such node is represented
in RAM by a struct jffs2_raw_node_ref. The memory occupied by these structs
is never freed unless the file system is unmounted or garbage collection
takes place. Garbage collection starts when there are only five empty
erase blocks left. Since every data node on the flash can hold at most one
page (4KB) worth of data (uncompressed), the number of in-core instances of
struct jffs2_raw_node_ref can grow very large. So in order to support a larger
JFFS2 file system, an appropriate amount of RAM is absolutely required.

- The size of a single struct jffs2_raw_node_ref is 16 bytes. In ecos, these
structs are allocated through calls to malloc(). If the underlying implementation
is dlmalloc, as is probably the case most often, the minimum allocation size is
24 bytes, so some memory is wasted here. A fixed-size block allocator would be
more appropriate.

- In http://lists.infradead.org/pipermail/linux-mtd/2003-August/008372.html,
David Woodhouse comments on this, suggesting possible improvements. I do not
know if any work is going on to implement one of these (probably not).

When I originally decided to design my system around JFFS2 I was totally unaware
of these topics. Although everything I found is implicit in David Woodhouse's
paper 'JFFS : The Journalling Flash File System', it is not stated explicitly
anywhere, so I'm doing it here and now: Do not use large JFFS2 file systems if
RAM is a scarce resource!