Bug in JFFS
Quoted 5 lines · Sébastien Côté
I have just found a bug in my port of JFFS (2.2).
If I mount a filesystem, do 'echo "Test" >> file' (file is an existing text file), the file gets appended correctly. However, once I open the file (cat file), the append I do next will not appear on the screen but the file size changes correctly.
Ok. Here's how this should be fixed:
We should use generic_file_write in jffs_file_operations instead of jffs_write_file. Then we should implement writepage, prepare_write and commit_write in address_space_operations. These should look quite like jffs_write_file, so this wouldn't be hard.
There is one problem here though. For each write the page of the file that is modified is read in, modified and written out in its entierty. This means several small writes to a file will become several 4Kb writes to the log.
Another doubt i have here is the log semantics given the page cache. I don't know if the page cache immediately does the writes or if it delays them (for better performance or something). That could possibly disturb the integrity of the log.
/ Alex
To unsubscribe, send "unsubscribe mtd" to [email protected]
Quoted 9 lines · Alexander Larsson
We should use
generic_file_writeinjffs_file_operationsinstead ofjffs_write_file. Then we should implement writepage,prepare_writeandcommit_writeinaddress_space_operations. These should look quite likejffs_write_file, so this wouldn't be hard.There is one problem here though. For each write the page of the file that is modified is read in, modified and written out in its entierty. This means several small writes to a file will become several 4Kb writes to the log.
That's why its unsymmetric from the beginning. It does not matter if the OS reads pages or files, but it matters if it writes pages or passes on writes directly. The latter is more or less required by JFFS design, while the former is not. If you start involving page-based file i/o, you're back at the block-based journaling that any other JFS uses, eventually.. but with more overhead :)
I thought we had correct page invalidation in the write mechanism. Did it disappear in the 2.2/2.3 port or was it never there ? :)
-Bjorn
To unsubscribe, send "unsubscribe mtd" to [email protected]