A JFFS2 optimization related to syslog

David Woodhouse dwmw2 at infradead.org
Wed Apr 19 07:00:26 EDT 2006


On Tue, 2006-04-18 at 13:32 +0200, Jörn Engel wrote:
> Very interesting idea.  I had another one which is more complicated
> and it looks like yours is much better.  Just for completeness, here
> is mine:
> o For every node with less than one page uncompressed size, account it
>   some dirty space for it.
> o Node header is 68 bytes (on 32bit).  Therefore, a node with 1/2 page
>   uncompressed size should cause 34 bytes of "dirty space".
> o Complete formula:
>   dirty_space = 68 * (PAGE_SIZE - ri->csize) / PAGE_SIZE
> o Possibly don't account dirty space if node is last node of a file.
> 
> With this little hack, tiny nodes would be garbage collected for being
> "dirty space".
> 
> Maybe both approaches would make sense, but yours is much simpler and
> should be used independently of whether mine makes sense.

My idea was similar to Jörn's but slightly simpler in the
implementation. We already make a distinction between REF_PRISTINE and
REF_NORMAL nodes, and I thought that we should keep track of those
counts in jeb->pristine_size and jeb->normal_size instead of the
existing jeb->used_size which holds them both. Then we should use that
information when selecting blocks to be garbage collected -- we should
tend to pick blocks with REF_NORMAL nodes for garbage collection.

This would fix the problem which Ferenc refers to, that none of the
nodes are obsoleted. However, it still only means that the nodes would
be garbage-collected in the fullness of time -- it's not clear how
_much_ of an effect that would have -- you could still end up with whole
eraseblocks full of these REF_NORMAL nodes, if there's plenty of free
space and garbage collection isn't being pressured.

So even if we do that, I think Ferenc's patch _also_ makes sense,
because it fixes the worst of the problem at its source. We could
perhaps make it conditional -- only write out the whole page if there's
more than N nodes already in the same page, or if the previous nodes for
the same page are in the same eraseblock _and_ the new 'full' node would
actually fit in the eraseblock.

-- 
dwmw2





More information about the linux-mtd mailing list