Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.