[ECOS] Re: FTP runs out of JFFS2 nodes and trashes the file system

Jürgen Lambrecht J.Lambrecht@televic.com
Wed Apr 9 11:42:00 GMT 2008

Cause of error found! See below.

Andrew Lunn wrote:

>>But Gary says  
>>(http://ecos.sourceware.org/ml/ecos-discuss/2008-04/msg00102.html) that  
>>jffs2 automatically buffers data to fill a node, and I read yesterday  
>>something about that on infradead.org ???
>I don't think that is correct for eCos. On Linux the VFS maybe
>blocking together writes, but for eCos there is no VFS. Writes go
>directly to the filesystem. Enabling debugging may prove this.
>         Andrew
Here are my debug results:

- *jffs2 mount* debug output:
   I see there are nodes with a huge number of versions: 326, 628... . 
Each time of size 0x100 or 256B. The smallest versions are 100!
- *FTP* debug output:
   I see the buffer size is 2kB, and fwrite() is called per 2kB (untill 
the file is finished)
   Solution: I need to set the buffer size to 4kB to fit the jffs2 node 
size. I  guess this is a TCP/IP stack buffer size I have to set with ioctl()?
- *libc fwrite*:
   I see the data is written per 256B!! OK: the default value of 
   Solution: set buffer size with setbuf() to 4kB
- *jffs2_fo_write*
   Gets a request to allocate 256B, request a minimum of 196B, and gets 
much more.
   Writes a dnode of 256B.
   So indeed, jffs2 does not buffer to have the optimal node size.
   So this way, my 16000 raw nodes (costing 250kB RAM) can only store 4MB 
instead of 62.5MB!! This explains my problem with FTP.

To use a flash with jffs2 efficiently
- users should be aware they must call write with the jffs2 buffer size
- users should be aware they must set the stream libc buffer size to the 
jffs2 buffer size before using fwrite!
   -> even better: the default value of CYGNUM_LIBC_STDIO_BUFSIZE should 
be set to the jffs2 buffer size if jffs2 is used. OK, if you use 2 
different file systems this is not valid anymore...

Anyhow, ecos misses a good jffs2 usage manual.
If I want to write one, how should I do that? I don't know sgml.. OK, my 
xemacs knows it ;-).

Thanks for your help!,

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list