Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question

Try implementing your own garbage collection algorithm and try to run that in mount time,and when your run out of space to write start again a garbage collection thread separately.

It will be lot easier if you write your files as fragments so that when you erase a block or page with half of a file in it ,you can still write it to somewhere and get the page for future use.

The tricky part is how to open a file with multiple fragments span across the file system.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .