How to actually defragment a JFFS2 filesystem

Posted by Julie in Austin on Super User See other posts from Super User or by Julie in Austin
Published on 2012-09-22T01:18:18Z Indexed on 2012/09/22 3:40 UTC
Read the original article Hit count: 744

Filed under:

I have searched all over the Internet, including on a number of StackExchange forums, for a workable method for defragmenting a JFFS2 filesystem and cannot find an answer.

The system in question has a 256MB NAND flash part. It is being accessed as a MTD device which is divided into three partitions. The third partition is where the root file system is being stored as a JFFS2 file system. The issue is that writes to the root file system have non-deterministic performance due to the usual issues of the JFFS2 garbage collector deciding to run at the worst possible times. When that happens, the product is hung for some unknown length of time while the garbage collector (and pdflush) run.

Changing the file system isn't an option. The solution needs to be something that can run during off-hours that after having been run results in more predictable write performance. Right now I am working on a program that will attempt to force the garbage collector to run, then delete the file with the hope that all of the freed nodes are suddenly more readily available and make writes perform better.

Thoughts?

© Super User or respective owner

Related posts about defragment